rcov for cucumber and shoulda
There seems to be a lot of bad info out there about this. It’s really quite simple, you just have to make use of the built in tasks provided by cucumber and rcov. The following task definitions will generate coverage reports for cucumber features and rails tests in coverage.features and converage.tests respectively. You’ll also get the overviews for the same reports at the command line when you run the tasks.
require 'cucumber/rake/task'
require 'rcov/rcovtask'
namespace :rcov do
rcov_opts = ['-T','--exclude /Library/Ruby/Site/*,.rip/*,gems/*,rcov*,features/step_definitions/webrat_steps.rb']
desc 'Measures cucumber coverage'
Cucumber::Rake::Task.new(:features) do |t|
t.rcov = true
t.rcov_opts = rcov_opts
t.rcov_opts << '-o coverage.features'
end
desc 'Measures shoulda coverage'
Rcov::RcovTask.new(:tests) do |t|
t.libs << 'test'
t.test_files = FileList['test/unit/*_test.rb','test/functional/*_test.rb','test/unit/helpers/*_test.rb']
t.rcov_opts = rcov_opts
t.output_dir = "coverage.tests"
end
desc 'Measures all coverage'
task :all do
["features", "tests"].each{ |task| Rake::Task["rcov:#{task}"].invoke }
end
end

16. April 2010 at 16:08
Very nice blog to get lots of information. i will certainly come back and read more..