2011-03-03 47 views

回答

7

您可以按工作圍繞這個使用環境變量:

SimpleCov.start if ENV["COVERAGE"] 

然後,運行耙測試/ RSpec的/黃瓜

$ COVERAGE=true rake test 
+0

and in /environments/coverage.rb我只是從test.rb複製和粘貼設置? – Mattherick 2011-03-04 10:56:13

+0

好的,它的工作原理。謝謝! – Mattherick 2011-03-04 12:35:55

+0

你不需要在單獨的Rails環境中運行它,我的意思是隻是一個shell環境變量:) – TheDeadSerious 2011-03-04 19:23:22

0

另一種方式來運行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