C0 code coverage information

Generated on Mon Aug 13 01:18:55 -0400 2007 with rcov 0.8.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
lib/spec/runner/formatter/html_formatter.rb 323 270
100.0% 
100.0% 
  1 require 'erb'
  2 
  3 module Spec
  4   module Runner
  5     module Formatter
  6       class HtmlFormatter < BaseTextFormatter
  7         include ERB::Util # for the #h method
  8         
  9         def initialize(output)
 10           super
 11           @current_behaviour_number = 0
 12           @current_example_number = 0
 13         end
 14 
 15         # The number of the currently running behaviour
 16         def current_behaviour_number
 17           @current_behaviour_number
 18         end
 19         
 20         # The number of the currently running example (a global counter)
 21         def current_example_number
 22           @current_example_number
 23         end
 24         
 25         def start(example_count)
 26           @example_count = example_count
 27 
 28           @output.puts html_header
 29           @output.puts report_header
 30           @output.flush
 31         end
 32 
 33         def add_behaviour(name)
 34           @behaviour_red = false
 35           @behaviour_red = false
 36           @current_behaviour_number += 1
 37           unless current_behaviour_number == 1
 38             @output.puts "  </dl>"
 39             @output.puts "</div>"
 40           end
 41           @output.puts "<div class=\"behaviour\">"
 42           @output.puts "  <dl>"
 43           @output.puts "  <dt id=\"behaviour_#{current_behaviour_number}\">#{h(name)}</dt>"
 44           @output.flush
 45         end
 46 
 47         def start_dump
 48           @output.puts "  </dl>"
 49           @output.puts "</div>"
 50           @output.flush
 51         end
 52 
 53         def example_started(example)
 54           @current_example_number = example.number
 55         end
 56 
 57         def example_passed(example)
 58           move_progress
 59           @output.puts "    <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span></dd>"
 60           @output.flush
 61         end
 62 
 63         def example_failed(example, counter, failure)
 64           extra = extra_failure_content(failure)
 65           failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
 66           @output.puts "    <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
 67           @header_red = true
 68           @output.puts "    <script type=\"text/javascript\">makeRed('behaviour_#{current_behaviour_number}');</script>" unless @behaviour_red
 69           @behaviour_red = true
 70           move_progress
 71           @output.puts "    <dd class=\"spec #{failure_style}\">"
 72           @output.puts "      <span class=\"failed_spec_name\">#{h(example.description)}</span>"
 73           @output.puts "      <div class=\"failure\" id=\"failure_#{counter}\">"
 74           @output.puts "        <div class=\"message\"><pre>#{h(failure.exception.message)}</pre></div>" unless failure.exception.nil?
 75           @output.puts "        <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
 76           @output.puts extra unless extra == ""
 77           @output.puts "      </div>"
 78           @output.puts "    </dd>"
 79           @output.flush
 80         end
 81 
 82         def example_pending(behaviour_name, example_name, message)
 83           @output.puts "    <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
 84           @output.puts "    <script type=\"text/javascript\">makeYellow('behaviour_#{current_behaviour_number}');</script>" unless @behaviour_red
 85           move_progress
 86           @output.puts "    <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example_name)}</span></dd>"
 87           @output.flush
 88         end
 89 
 90         # Override this method if you wish to output extra HTML for a failed spec. For example, you
 91         # could output links to images or other files produced during the specs.
 92         #
 93         def extra_failure_content(failure)
 94           "    <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(failure.exception)}</code></pre>"
 95         end
 96         
 97         def move_progress
 98           percent_done = @example_count == 0 ? 100.0 : ((current_example_number + 1).to_f / @example_count.to_f * 1000).to_i / 10.0
 99           @output.puts "    <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
100           @output.flush
101         end
102 
103         def dump_failure(counter, failure)
104         end
105 
106         def dump_summary(duration, example_count, failure_count, pending_count)
107           if @dry_run
108             totals = "This was a dry-run"
109           else
110             totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
111             totals << ", #{pending_count} pending" if pending_count > 0  
112           end
113           @output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{duration} seconds</strong>\";</script>"
114           @output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
115           @output.puts "</div>"
116           @output.puts "</div>"
117           @output.puts "</body>"
118           @output.puts "</html>"
119           @output.flush
120         end
121 
122         def html_header 
123           <<-EOF
124 <?xml version="1.0" encoding="iso-8859-1"?>
125 <!DOCTYPE html
126      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
127      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
128 
129 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
130 <head>
131   <title>RSpec results</title>
132   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
133   <meta http-equiv="Expires" content="-1" />
134   <meta http-equiv="Pragma" content="no-cache" />
135   <style type="text/css">
136   body {
137     margin: 0;
138     padding: 0;
139     background: #fff;
140     font-size: 80%;
141   }
142   </style>
143 </head>
144 <body>
145 EOF
146         end
147 
148         def report_header
149           <<-EOF
150 <div class="rspec-report">
151   <script type="text/javascript">
152     // <![CDATA[
153 #{global_scripts}
154     // ]]>
155   </script>
156   <style type="text/css">
157 #{global_styles}
158   </style>
159 
160 <div id="rspec-header">
161   <h1>RSpec Results</h1>
162 
163   <div id="summary">
164     <p id="totals">&nbsp;</p>
165     <p id="duration">&nbsp;</p>
166   </div>
167 </div>
168 
169 <div class="results">
170 EOF
171         end
172 
173         def global_scripts
174           <<-EOF
175 function moveProgressBar(percentDone) {
176   document.getElementById("rspec-header").style.width = percentDone +"%";
177 }
178 function makeRed(element_id) {
179   document.getElementById(element_id).style.background = '#C40D0D';
180   document.getElementById(element_id).style.color = '#FFFFFF';
181 }
182 
183 function makeYellow(element_id) {
184   if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
185   {
186     document.getElementById(element_id).style.background = '#FAF834';
187     document.getElementById(element_id).style.color = '#000000';
188   }
189   else
190   {
191     document.getElementById(element_id).style.background = '#FAF834';
192     document.getElementById(element_id).style.color = '#000000';
193   }
194 }
195 EOF
196         end
197         
198         def global_styles
199           <<-EOF
200 #rspec-header {
201   background: #65C400; color: #fff;
202 }
203 
204 .rspec-report h1 {
205   margin: 0px 10px 0px 10px;
206   padding: 10px;
207   font-family: "Lucida Grande", Helvetica, sans-serif;
208   font-size: 1.8em;
209 }
210 
211 #summary {
212   margin: 0; padding: 5px 10px;
213   font-family: "Lucida Grande", Helvetica, sans-serif;
214   text-align: right;
215   position: absolute;
216   top: 0px;
217   right: 0px;
218 }
219 
220 #summary p {
221   margin: 0 0 0 2px;
222 }
223 
224 #summary #totals {
225   font-size: 1.2em;
226 }
227 
228 .behaviour {
229   margin: 0 10px 5px;
230   background: #fff;
231 }
232 
233 dl {
234   margin: 0; padding: 0 0 5px;
235   font: normal 11px "Lucida Grande", Helvetica, sans-serif;
236 }
237 
238 dt {
239   padding: 3px;
240   background: #65C400;
241   color: #fff;
242   font-weight: bold;
243 }
244 
245 dd {
246   margin: 5px 0 5px 5px;
247   padding: 3px 3px 3px 18px;
248 }
249 
250 dd.spec.passed {
251   border-left: 5px solid #65C400;
252   border-bottom: 1px solid #65C400;
253   background: #DBFFB4; color: #3D7700;
254 }
255 
256 dd.spec.failed {
257   border-left: 5px solid #C20000;
258   border-bottom: 1px solid #C20000;
259   color: #C20000; background: #FFFBD3;
260 }
261 
262 dd.spec.not_implemented {
263   border-left: 5px solid #FAF834;
264   border-bottom: 1px solid #FAF834;
265   background: #FCFB98; color: #131313;
266 }
267 
268 dd.spec.pending_fixed {
269   border-left: 5px solid #0000C2;
270   border-bottom: 1px solid #0000C2;
271   color: #0000C2; background: #D3FBFF;
272 }
273 
274 .backtrace {
275   color: #000;
276   font-size: 12px;
277 }
278 
279 a {
280   color: #BE5C00;
281 }
282 
283 /* Ruby code, style similar to vibrant ink */
284 .ruby {
285   font-size: 12px;
286   font-family: monospace;
287   color: white;
288   background-color: black;
289   padding: 0.1em 0 0.2em 0;
290 }
291 
292 .ruby .keyword { color: #FF6600; }
293 .ruby .constant { color: #339999; }
294 .ruby .attribute { color: white; }
295 .ruby .global { color: white; }
296 .ruby .module { color: white; }
297 .ruby .class { color: white; }
298 .ruby .string { color: #66FF00; }
299 .ruby .ident { color: white; }
300 .ruby .method { color: #FFCC00; }
301 .ruby .number { color: white; }
302 .ruby .char { color: white; }
303 .ruby .comment { color: #9933CC; }
304 .ruby .symbol { color: white; }
305 .ruby .regex { color: #44B4CC; }
306 .ruby .punct { color: white; }
307 .ruby .escape { color: white; }
308 .ruby .interp { color: white; }
309 .ruby .expr { color: white; }
310 
311 .ruby .offending { background-color: gray; }
312 .ruby .linenum {
313   width: 75px;
314   padding: 0.1em 1em 0.2em 0;
315   color: #000000;
316   background-color: #FFFBD3;
317 }
318 EOF
319         end
320       end
321     end
322   end
323 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.

Valid XHTML 1.0! Valid CSS!