lib/tasks/coverage.rake in indirect-metric_fu-0.8.2 vs lib/tasks/coverage.rake in indirect-metric_fu-0.9.0
- old
+ new
@@ -1,7 +1,6 @@
require 'fileutils'
-
begin
require 'rcov'
require 'rcov/rcovtask'
require 'spec/rake/spectask'
@@ -16,29 +15,39 @@
desc "Delete aggregate coverage data."
task(:clean) { rm_f("rcov_tmp", :verbose => false) }
desc "RCov task to generate report"
- Spec::Rake::SpecTask.new(:do => :clean) do |t|
+ Rcov::RcovTask.new(:do => :clean) do |t|
FileUtils.mkdir_p(MetricFu::BASE_DIRECTORY) unless File.directory?(MetricFu::BASE_DIRECTORY)
- t.ruby_opts = ['-rtest/unit']
- t.spec_files = FileList['test/**/*_test.rb', 'spec/**/*spec.rb']
- t.spec_opts = ["--format", "html:#{SPEC_HTML_FILE}", "--diff"]
- t.rcov = true
- t.rcov_opts = ["--sort coverage", "--html", "--rails", "--exclude /gems/,/Library/"]
- t.rcov_dir = COVERAGE_DIR
+ t.test_files = FileList[*MetricFu.coverage[:test_files]]
+ t.rcov_opts = MetricFu.coverage[:rcov_opts]
+ t.output_dir = COVERAGE_DIR
+ # this line is a fix for Rails 2.1 relative loading issues
+ t.libs << 'test'
end
+ # TODO not sure what this improves but it requires the diff-lcs gem
+ # http://github.com/indirect/metric_fu/commit/b9c1cf75f09d5b531b388cd01661eb16b5126968#diff-1
+ # Spec::Rake::SpecTask.new(:do => :clean) do |t|
+ # FileUtils.mkdir_p(MetricFu::BASE_DIRECTORY) unless File.directory?(MetricFu::BASE_DIRECTORY)
+ # t.ruby_opts = ['-rtest/unit']
+ # t.spec_files = FileList['test/**/*_test.rb', 'spec/**/*spec.rb']
+ # t.spec_opts = ["--format", "html:#{SPEC_HTML_FILE}", "--diff"]
+ # t.rcov = true
+ # t.rcov_opts = ["--sort coverage", "--html", "--rails", "--exclude /gems/,/Library/"]
+ # t.rcov_dir = COVERAGE_DIR
+ # end
end
desc "Generate and open coverage report"
task :coverage => ['coverage:do'] do
- system("open #{COVERAGE_DIR}/index.html") if PLATFORM['darwin']
+ system("open #{COVERAGE_DIR}/index.html") if MetricFu.open_in_browser?
end
end
rescue LoadError
if RUBY_PLATFORM =~ /java/
puts 'running in jruby - rcov tasks not available'
else
puts 'sudo gem install rcov # if you want the rcov tasks'
end
-end
\ No newline at end of file
+end