"Cannot load such file" 升级到 Rails 5 后,在 CircleCI 中进行 rake 测试时出错

"Cannot load such file" error during rake test in CircleCI after upgrading to Rails 5

'bundle exec rake test' 在本地成功完成,但是当 运行 在 CircleCI 上时,它最终失败了,在所有测试都通过之后。 O.o

我刚从 rails 4.2.6 升级到 Rails 5,之前没问题。有些东西在寻找我什至没有的测试文件夹,有一个 spec 文件夹,因为我使用 rspec.

    Finished in 28.48 seconds (files took 3.67 seconds to load)
    329 examples, 0 failures

    Coverage report generated for RSpec to /tmp/circle-artifacts.PrVAaqN/coverage. 1425 / 1477 LOC (96.48%) covered.
    rake aborted!
    LoadError: cannot load such file -- /home/ubuntu/app_name/test
    /home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in `each'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:62:in `rake_run'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/testing.rake:15:in `block in <top (required)>'
/home/ubuntu/app_name/vendor/bundle/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/bin/bundle:22:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/bin/bundle:22:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/bin/ruby_executable_hooks:15:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.3.3@global/bin/ruby_executable_hooks:15:in `<main>'

似乎与 rake 任务命名冲突。首先,我们不应该再使用 rake,尽管它可以工作,它已更改为 rails 命令。 'test' 的默认 rake/rails 任务似乎把一切都搞砸了。当我将任务名称更改为 rspec 时,它修复了所有问题。现在就可以了。