-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid loading Rails or ActiveSupport in tests #510
base: main
Are you sure you want to change the base?
Conversation
@vinistock any thoughts? |
4a88962
to
78f45b1
Compare
553d5c2
to
cbc1e25
Compare
|
||
require "test_helper" | ||
|
||
require_relative "../test/dummy/config/environment" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the key culprit here. I don't even think we need to switch fully to just Minitest.
As long as we require only the parts of Active Support related to testing, we can continue with the same setup.
But we can't load the dummy app for every test because that will load everything and get us into trouble.
t.test_files = ["test/ruby_lsp_rails/server_test.rb"] | ||
end | ||
|
||
task default: [:"db:setup", :test, "test:server"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test if adding a present?
in the add-on code breaks when running bundle exec rake
?
I think because test:server
is last, then the related test helper only gets required at the end, but I'm not 100% sure.
task default: [:"db:setup", :test, "test:server"] | |
task default: ["db:setup", :test, "test:server"] |
To prevent issues such as #509 we can switch to using
Minitest::Test
instead ofActiveSupport::TestCase
for the test files.I have temporarily added the
test_declarative
gem to avoid editing all the test declarations, but if we decide to go ahead then I can do that.We have one test file (
server_test.rb
) that does need to load Rails so I have split that out.There is currently one failing test that I need to look into.fixed