bullet_train
bullet_train copied to clipboard
Do people run tests with `ruby -Ilib:test`?
Had someone reach out because running tests with the following invocation doesn't work:
ruby -Ilib:test test/models/user_test.rb
Is that a normal way to invoke tests? I've always used rails test ...
or rake test TEST=...
.
I also just run rails test
I just tried the ruby -Ilib:test
method of invocation and this is the error, just for reference:
$ ruby -I"lib:test" test/models/user_test.rb
/Users/jgreen/projects/bullet-train-co/bullet_train/config/initializers/bullet_train.rb:1:in `<main>': undefined method `configure' for BulletTrain:Module (NoMethodError)
BulletTrain.configure do |config|
^^^^^^^^^^
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:667:in `load'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:667:in `block in load_config_initializer'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications.rb:208:in `instrument'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:666:in `load_config_initializer'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:619:in `each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/engine.rb:619:in `block in <class:Engine>'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:32:in `run'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:50:in `each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:50:in `tsort_each_child'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `call'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.7.2/lib/rails/application.rb:372:in `initialize!'
from /Users/jgreen/projects/bullet-train-co/bullet_train/config/environment.rb:5:in `<top (required)>'
from /Users/jgreen/projects/bullet-train-co/bullet_train/test/test_helper.rb:2:in `require_relative'
from /Users/jgreen/projects/bullet-train-co/bullet_train/test/test_helper.rb:2:in `<top (required)>'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/Users/jgreen/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from test/models/user_test.rb:1:in `<main>'
I really don't think that's a valid way to run a single test if you're inside of a rails application. It seems to skip some of the Rails Magic around loading of gems, or something.
I think we can close this one.
Just here to confirm that I got the same error.
If it's an eager loading issue, that's been one of the big problems we've encountered with tests across the whole bt architecture. Also in favor of closing this one.