1

我最近加入了一个Ruby-on-Rails应用程序团队,我尝试审核测试。没有测试,所以我决定在应用程序中实现它们。

在查看了那里的内容后,我发现没有运行可用测试的命令。我运行了以下命令:

 rails --tasks

在输出中,没有诸如rails test,之类的命令rails test:system。令人惊讶的是,我可以rails test成功运行该命令。但是该命令rails test:system --trace失败并显示以下输出:

 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>'

我尝试在新创建的应用程序中运行该命令,并且可以看到可用的命令rails testrails test:system.

rails --tasks

知道命令rails test:system失败的原因吗?谢谢。

红宝石版本:2.3.3

导轨版本:5.2.0

编辑:

我在用着MiniTest

4

1 回答 1

1

一次性运行所有规范:

rspec

要执行特定的测试文件:

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

用于--format documentation格式化输出。

bundle exec如果rspec抛出依赖错误,请预先添加。

于 2018-08-24T09:36:49.653 回答