rails test VS rake test in Rails 5
Asked Answered
L

1

6

So I'm trying out Rails 5, and there are few differences, such as I can use rails instead of rake for commands like test and db:* However, I've run into a weird snag:

If I run: $ rails test I get the following errors:

Running via Spring preloader in process 30936
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': cannot load such file -- minitest/reporters (LoadError)
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /home/ubuntu/workspace/stitched_up_site/test/test_helper.rb:4:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /home/ubuntu/workspace/stitched_up_site/test/controllers/static_pages_controller_test.rb:1:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/test_unit/test_requirer.rb:10:in `each'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/test_unit/minitest_plugin.rb:76:in `plugin_rails_init'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.9.0/lib/minitest.rb:80:in `block in init_plugins'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.9.0/lib/minitest.rb:78:in `each'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.9.0/lib/minitest.rb:78:in `init_plugins'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.9.0/lib/minitest.rb:129:in `run'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/test.rb:9:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:95:in `test'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /home/ubuntu/workspace/stitched_up_site/bin/rails:9:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
    from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

However, if i run $ rake test under the same conditions, it runs the way I expect.

Lheureux answered 10/9, 2016 at 18:13 Comment(2)
i'm running into weird things here too, it's not just you. I thought rails test and rake test were supposed to be identical, but they clearly are not. I haven't been able to figure out what's going on either.Marmolada
just to be sure: bundle exec rake test also works fine? (rails test already makes sure it uses the gems as specified in Gemfile.lock)Necessaries
B
0

I guess:

  • rake test executes some dependent tasks before executing test.
  • rails test doesn't.
Bowl answered 1/3, 2023 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.