【发布时间】:2019-07-16 08:50:54
【问题描述】:
当adding RSpec to Rails 时,我们终于可以运行rails spec(或bundle exec rspec)来运行RSpec 测试了。
然而,rails test 仍然令人困惑地尝试运行(不存在的)Minitest 测试。
如何将“test”rake 任务配置为运行 RSpec 测试?
【问题讨论】:
标签: ruby-on-rails rspec rake minitest
当adding RSpec to Rails 时,我们终于可以运行rails spec(或bundle exec rspec)来运行RSpec 测试了。
然而,rails test 仍然令人困惑地尝试运行(不存在的)Minitest 测试。
如何将“test”rake 任务配置为运行 RSpec 测试?
【问题讨论】:
标签: ruby-on-rails rspec rake minitest
您可以像这样覆盖test 任务:
# Add the code below in the Rakefile
require File.expand_path(‘config/application’, __dir__)
Rails.application.load_tasks
Rake::Task['test'].clear
task :test do
Rake::Task['rspec’].invoke
end
另一种方式(我只在我的控制台中尝试了一个放置一些东西但它应该与 rspec 一起使用的任务):
# Add the code below in the Rakefile
require File.expand_path(‘config/application’, __dir__)
Rails.application.load_tasks
task(:test).clear.enhance([‘rspec’])
【讨论】:
rake test 工作,但rails test 仍将运行 minitest。