@@ -0,0 +1,44 | |||
|
1 | ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake | |
|
2 | ||
|
3 | ### Inspired by http://blog.labratz.net/articles/2006/12/2/a-rake-task-for-rcov | |
|
4 | begin | |
|
5 | require 'rcov/rcovtask' | |
|
6 | ||
|
7 | namespace :test do | |
|
8 | desc "Aggregate code coverage for all tests" | |
|
9 | Rcov::RcovTask.new('coverage') do |t| | |
|
10 | t.libs << 'test' | |
|
11 | t.test_files = FileList['test/{unit,integration,functional}/*_test.rb'] | |
|
12 | t.verbose = true | |
|
13 | t.rcov_opts << '--rails --aggregate test/coverage.data' | |
|
14 | end | |
|
15 | ||
|
16 | namespace :coverage do | |
|
17 | desc "Delete coverage test data" | |
|
18 | task :clean do | |
|
19 | rm_f "test/coverage.data" | |
|
20 | rm_rf "test/coverage" | |
|
21 | end | |
|
22 | ||
|
23 | desc "Aggregate code coverage for all tests with HTML output" | |
|
24 | Rcov::RcovTask.new('html') do |t| | |
|
25 | t.libs << 'test' | |
|
26 | t.test_files = FileList['test/{unit,integration,functional}/*_test.rb'] | |
|
27 | t.output_dir = "test/coverage" | |
|
28 | t.verbose = true | |
|
29 | t.rcov_opts << '--rails --aggregate test/coverage.data' | |
|
30 | end | |
|
31 | ||
|
32 | desc "Open the HTML coverage report" | |
|
33 | task :show_results do | |
|
34 | system "open test/coverage/index.html" | |
|
35 | end | |
|
36 | ||
|
37 | task :full => "test:coverage:clean" | |
|
38 | task :full => "test:coverage:html" | |
|
39 | task :full => "test:coverage:show_results" | |
|
40 | end | |
|
41 | end | |
|
42 | rescue LoadError | |
|
43 | puts 'Rcov is not available. Proceeding without...' | |
|
44 | end |
General Comments 0
You need to be logged in to leave comments.
Login now