Skip to content

Instantly share code, notes, and snippets.

@williamn
Created September 6, 2010 07:32
Show Gist options
  • Save williamn/566752 to your computer and use it in GitHub Desktop.
Save williamn/566752 to your computer and use it in GitHub Desktop.
Rakefile (shoulda + rcov)
## add this to test/test_helper.rb
require 'shoulda/rails'
## add this to Rakefile
require 'shoulda/tasks'
namespace :test do
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
rm_f "coverage.data"
rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\""
system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb")
system("#{rcov} --no-html test/functional/*_test.rb")
system("#{rcov} --html test/integration/*_test.rb") unless Dir.glob("test/integration/*_test.rb").empty?
system("open coverage/index.html") if PLATFORM['darwin']
end
end
## usage
rake test:coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment