cover_me 1.0.0.rc6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,15 @@ class CoverMe::Index
21
21
  end
22
22
  return @total_loc
23
23
  end
24
-
24
+
25
+ # Returns the total number of untested lines of code across all files.
26
+ def total_untested_loc
27
+ unless @total_untested_loc
28
+ @total_untested_loc = self.reports.inject(0) {|sum, x| sum += (x.lines_of_code - x.lines_executed); sum}
29
+ end
30
+ return @total_untested_loc
31
+ end
32
+
25
33
  # Returns an average percent across all files.
26
34
  def percent_tested
27
35
  unless @percent_tested
@@ -16,7 +16,12 @@ class CoverMe::Report
16
16
  self.lines = self.coverage.size
17
17
  self.lines_of_code = self.coverage.reject{|x| x.nil?}.size
18
18
  self.lines_executed = self.coverage.reject{|x| x.nil? || x < 1}.size
19
- self.executed_percent = ((self.lines_executed.to_f / self.lines_of_code.to_f) * 100).round(1)
19
+
20
+ # Handling 0.0% coverage on files without divide-by-0 bugs
21
+ ratio = (self.lines_executed.to_f / self.lines_of_code.to_f)
22
+ ratio = ratio.nan? ? 0.0 : ratio
23
+ self.executed_percent = (ratio * 100).round(1)
24
+
20
25
  self.unexecuted_percent = (100 - self.executed_percent).round(1)
21
26
  end
22
27
 
@@ -105,4 +110,4 @@ class CoverMe::Report
105
110
  return @short_test_file_name
106
111
  end
107
112
 
108
- end
113
+ end
@@ -102,6 +102,7 @@
102
102
  <th>File</th>
103
103
  <th>Lines</th>
104
104
  <th>Lines Of Code</th>
105
+ <th>Untested Lines of Code</th>
105
106
  <th>Tested %</th>
106
107
  </tr>
107
108
  </thead>
@@ -118,6 +119,9 @@
118
119
  <td>
119
120
  <%= report.lines_of_code %>
120
121
  </td>
122
+ <td>
123
+ <%= report.lines_of_code - report.lines_executed %>
124
+ </td>
121
125
  <td>
122
126
  <%= report.executed_percent %>%
123
127
  </td>
@@ -129,6 +133,7 @@
129
133
  <th>Total</th>
130
134
  <th><%= index.total_lines %></th>
131
135
  <th><%= index.total_loc %></th>
136
+ <th><%= index.total_untested_loc %></th>
132
137
  <th><%= index.percent_tested %>%</th>
133
138
  </tr>
134
139
  </table>
@@ -52,6 +52,7 @@
52
52
  <th>File</th>
53
53
  <th>Lines</th>
54
54
  <th>Lines Of Code</th>
55
+ <th>Untested Lines of Code</th>
55
56
  <th>Tested %</th>
56
57
  </tr>
57
58
  <tr valign='top'>
@@ -64,6 +65,7 @@
64
65
  </td>
65
66
  <td><%= report.lines %></td>
66
67
  <td><%= report.lines_of_code %></td>
68
+ <td><%= report.lines_of_code - report.lines_executed %></td>
67
69
  <td><%= report.executed_percent %>%</td>
68
70
  </tr>
69
71
  </table>
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cover_me
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.0.0.rc6
4
+ prerelease:
5
+ version: 1.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - markbates
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-24 00:00:00 -05:00
14
- default_executable:
13
+ date: 2011-05-26 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: configatron
@@ -42,7 +41,6 @@ executables: []
42
41
  extensions: []
43
42
 
44
43
  extra_rdoc_files:
45
- - README
46
44
  - LICENSE
47
45
  files:
48
46
  - lib/cover_me/config.rb
@@ -66,9 +64,7 @@ files:
66
64
  - lib/cover_me.rb
67
65
  - lib/generators/cover_me/install/install_generator.rb
68
66
  - lib/generators/cover_me/install/templates/cover_me.rake
69
- - README
70
67
  - LICENSE
71
- has_rdoc: true
72
68
  homepage: http://www.metabates.com
73
69
  licenses: []
74
70
 
@@ -102,13 +98,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
98
  required_rubygems_version: !ruby/object:Gem::Requirement
103
99
  none: false
104
100
  requirements:
105
- - - ">"
101
+ - - ">="
106
102
  - !ruby/object:Gem::Version
107
- version: 1.3.1
103
+ version: "0"
108
104
  requirements: []
109
105
 
110
106
  rubyforge_project: magrathea
111
- rubygems_version: 1.5.0
107
+ rubygems_version: 1.8.2
112
108
  signing_key:
113
109
  specification_version: 3
114
110
  summary: CoverMe - Code Coverage for Ruby 1.9
data/README DELETED
@@ -1,87 +0,0 @@
1
- =CoverMe - Code Coverage for Ruby 1.9
2
-
3
- Ruby 1.9(.2) is an amazing language to develop applications in. It's faster, more powerful, cleaner, and a huge improvement over Ruby 1.8.x. Because of those reasons every Ruby developer should move to this exciting new version of our language.
4
-
5
- When making a move of this size it's important to have the right tools to help us along. Unfortunately, one of the most useful tools as a Ruby developer, RCov, does not work with Ruby 1.9.
6
-
7
- RCov, for those unfamiliar analyzes your code and tells you which part of your code was not executed. This is INCREDIBLY useful when hooked up to your test suite. While, it's not the only metric you should use when determining how good your test coverage it, it certainly is a great first step to point out exactly which parts of your code haven't been touched at all!
8
-
9
- Enter CoverMe.
10
-
11
- ==History
12
-
13
- While working on a Ruby 1.9/Rails 3 project, and loving everything about it (except for the lack of RCov), I came across a "post":http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/ by Aaron Patterson (of Nokogiri fame). In this post he quickly outlined a very basic coverage tool using the new built-in Coverage module in Ruby 1.9.
14
-
15
- After spending a morning playing with it, I was quickly able to grow the idea into something useful for the project. Later that day the company I was consulting for ("BiddingForGood.com":http://www.biddingforgood.com), and in particular their chief architect, Stuart Garner, told me to take a day or two and clean it up and release it for the world to use, and so here it is.
16
-
17
- ==Features
18
-
19
- ===Index Page
20
-
21
- * Sortable column headers (File, Lines, Lines of Code, Tested %).
22
- * Searching/filtering by file name.
23
- * Filtering by coverage percent.
24
- * Color coded list of files to quickly see which ones are 100% covered, > 90% covered, or less than 90% covered.
25
- * Large color coded average coverage percent, for quick reference.
26
-
27
- ===Detail Page
28
-
29
- * Line by line coverage report
30
- * Color coded lines to quickly see which lines where executed and which ones were not.
31
- * Side by side viewing with the corresponding test/spec file (if one exists).
32
-
33
- ==Use
34
-
35
- CoverMe is pretty easy to use, and has been tested with Ruby 1.9.2 and Rails 3. First, add CoverMe to your Gemfile:
36
-
37
- gem 'cover_me', '>= 1.0.0.rc5', :group => :test
38
-
39
- Now make sure to install the gem with Bundler:
40
-
41
- $ bundle install
42
-
43
- All that's left now is to require it as the first line of your 'spec_helper.rb' or 'test_helper.rb' file:
44
-
45
- require 'cover_me'
46
-
47
- Now the next time your run your test suite it will create a series of HTML files in the _coverage_ folder at the root of your project. Open _coverage/index.html_ and you're off and running.
48
-
49
- ===Rails 3
50
-
51
- If you are using CoverMe with Rails 3 run the following to get the cover me Rake task:
52
-
53
- $ rails g cover_me:install
54
-
55
- ==Configuration
56
-
57
- CoverMe is easily configurable, under the covers it uses the "Configatron":http://github.com/markbates/configatron library. Here are a few quick config options you might want to play with:
58
-
59
- CoverMe.config do |c|
60
- # where is your project's root:
61
- c.project.root # => "Rails.root" (default)
62
-
63
- # what files are you interested in coverage for:
64
- c.file_pattern # => /(#{CoverMe.config.project.root}\/app\/.+\.rb|#{CoverMe.config.project.root}\/lib\/.+\.rb)/ix (default)
65
-
66
- # where do you want the HTML generated:
67
- c.html_formatter.output_path # => File.join(CoverMe.config.project.root, 'coverage') (default)
68
-
69
- # what do you want to happen when it finishes:
70
- c.at_exit # => Proc.new {
71
- if CoverMe.config.formatter == CoverMe::HtmlFormatter
72
- index = File.join(CoverMe.config.html_formatter.output_path, 'index.html')
73
- if File.exists?(index)
74
- `open #{index}`
75
- end
76
- end
77
- } (default)
78
- end
79
-
80
- ==Contributors
81
-
82
- * Mark Bates
83
- * Alex Crichton
84
- * Andrea Campi
85
- * Rob Zolkos
86
- * jmthomas
87
- * Lasse Koskela