【问题标题】:No command "rails test" in my Ruby-on-Rails application我的 Ruby-on-Rails 应用程序中没有命令“rails test”
【发布时间】:2018-08-24 07:45:48
【问题描述】:

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

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

 rails --tasks

输出中没有rails testrails 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 会失败吗?谢谢。

Ruby 版本:2.3.3

Rails 版本:5.2.0

编辑:

我正在使用MiniTest

【问题讨论】:

  • 您在两个应用程序上使用相同的 rake 版本?
  • 好吧,我刚刚发现有一个从 rails 5.0 到 5.2 的升级尚未完全执行。只需关注Upgrade rails guide,一切正常。实际上,我只需要运行rails app:update

标签: ruby-on-rails system-testing


【解决方案1】:

一次性运行所有规范:

rspec

执行特定的测试文件:

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

使用--format documentation 进行格式化输出。

如果 rspec 引发依赖错误,则添加 bundle exec

【讨论】:

  • 我忘了说我用的是Minitest
猜你喜欢
  • 1970-01-01
  • 2015-01-13
  • 1970-01-01
  • 2011-05-15
  • 2017-12-09
  • 1970-01-01
  • 2017-07-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多