【发布时间】:2017-03-24 08:40:37
【问题描述】:
在运行测试时,是否有可能在 rake 任务上运行 simplecov coverage-tool for rails 而不是每次都运行?
【问题讨论】:
标签: ruby-on-rails gem
在运行测试时,是否有可能在 rake 任务上运行 simplecov coverage-tool for rails 而不是每次都运行?
【问题讨论】:
标签: ruby-on-rails gem
您可以使用环境变量来解决这个问题:
SimpleCov.start if ENV["COVERAGE"]
然后,运行 rake test / rspec / cucumber with
$ COVERAGE=true rake test
【讨论】:
SimpleCov.start放在哪里?在 rakefile 的顶部?
另一种仅使用 rake 任务运行 SimpleCov 的方法是将设置代码从规范帮助程序中移出到 Rakefile。
# Rakefile
... # normal Rakefile stuff
if defined? RSpec
task(:spec).clear
RSpec::Core::RakeTask.new(:spec) do |t|
require 'simplecov'
SimpleCov.start 'rails'
end
end
【讨论】: