SimpleCov: Not run every time, just with rake task
Is there a possibility to run simplecov coverage-tool for rails just over a开发者_开发百科n rake task and not every time, when running the tests?
You can sort of work around this using an environment variable:
SimpleCov.start if ENV["COVERAGE"]
And then, running rake test / rspec / cucumber with
$ COVERAGE=true rake test
Another way to run SimpleCov
with rake task only is to move the setup code out of the spec helper into 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
精彩评论