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