1

I've recently joined a team on a Ruby-on-Rails application, and I try to audit the tests. There were no tests, so I decided to implement them in the app.

After seeing around what was there, I have seen there were no command to run the tests available. I ran the following command:

 rails --tasks

In the output, there is no command such as rails test, rails test:system. Surprisingly, I can run the command rails test with success. But the command rails test:system --trace fails with following output:

 rails aborted!
 Don't know how to build task 'test:system' (see --tasks)
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task_manager.rb:59:in `[]'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:159:in `invoke_task'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
 bin/rails:9:in `require'
 bin/rails:9:in `<main>'

I have tried running the command in a freshly created app, and I can see the available commands rails test and rails test:system.

rails --tasks

Any idea why the command rails test:system fails? Thanks.

Ruby version: 2.3.3

Rails version: 5.2.0

EDIT:

I'm using MiniTest

Rémi Doolaeghe
  • 2,262
  • 3
  • 31
  • 50
  • you are using the same rake version on both applications? – Fabrizio Bertoglio Aug 24 '18 at 08:45
  • Well, I have just discovered there were an upgrade from rails 5.0 to 5.2 which had not been performed completely. Just had to follow [Upgrade rails guide](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html) and everything worked fine. Actually, I just had to run `rails app:update` – Rémi Doolaeghe Aug 24 '18 at 08:53

1 Answers1

1

To run all specs in a single go:

rspec

To execute a specific test file:

rspec <path to the file>  # rspec spec/controllers/mytest_spec.rb

Use --format documentation for a formatted output.

Prepend bundle exec if rspec throws a dependency error.