diff --git a/Gemfile b/Gemfile index 48728dd..ece6c3d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,6 @@ source "http://rubygems.org" group :development do gem "bundler", "~> 1.0.0" gem "jeweler", "~> 1.6.4" - gem "rcov", ">= 0" gem "rdoc", ">= 0" gem "shoulda" @@ -12,4 +11,6 @@ group :development do gem "webmock" end +gem 'simplecov', :require => false, :group => :test + gem "nokogiri", ">= 0" diff --git a/README.rdoc b/README.rdoc index c3e2c04..79afb39 100644 --- a/README.rdoc +++ b/README.rdoc @@ -69,6 +69,7 @@ MusicBrainz::Track * Start a feature/bugfix branch * Commit and push until you are happy with your contribution * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. +* to get a coverage report for your Test Unit and RSpec tests use the rake tasks: test_coverage, rspec_coverage * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. === Copyright diff --git a/Rakefile b/Rakefile index 5e96f3a..67f24d9 100644 --- a/Rakefile +++ b/Rakefile @@ -32,12 +32,21 @@ Rake::TestTask.new(:test) do |test| test.verbose = true end -require 'rcov/rcovtask' -Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/test_*.rb' +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) do |test| test.verbose = true - test.rcov_opts << '--exclude "gems/*"' +end + +desc "Run Test Unit with code coverage" +task :test_coverage do + ENV['COVERAGE'] = 'true' + Rake::Task["test"].execute +end + +desc "Run RSpec with code coverage" +task :rspec_coverage do + ENV['COVERAGE'] = 'true' + Rake::Task["spec"].execute end task :default => :test diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d83f4ad..c644267 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,13 @@ +require 'simplecov' + +if ENV["COVERAGE"] + SimpleCov.start do + add_filter '/gems/' + add_filter '/test/' + add_filter '/spec/' + end +end + require 'rubygems' require 'bundler' begin diff --git a/test/helper.rb b/test/helper.rb index 50661f8..1fba407 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,3 +1,13 @@ +require 'simplecov' + +if ENV["COVERAGE"] + SimpleCov.start do + add_filter '/gems/' + add_filter '/test/' + add_filter '/spec/' + end +end + require 'rubygems' require 'bundler' begin