Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/reporter.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/reporter.rb 171 131
68.42%
59.54%

Key

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.

Coverage Details

1 module Spec
2   module Runner
3     class Reporter
4       attr_reader :options
5       
6       def initialize(options)
7         @options = options
8         @options.reporter = self
9         @failures = []
10         @pending_count = 0
11         @example_count = 0
12         @start_time = nil
13         @end_time = nil
14       end
15       
16       def example_group_started(example_group)
17         @example_group = example_group
18         formatters.each do |f|
19           f.example_group_started(example_group)
20         end
21       end
22       
23       def example_started(example)
24         formatters.each{|f| f.example_started(example)}
25       end
26       
27       def example_finished(example, error=nil)
28         @example_count += 1
29         
30         if error.nil?
31           example_passed(example)
32         elsif Spec::Example::ExamplePendingError === error
33           example_pending(example, example.location, error.message)
34         else
35           example_failed(example, error)
36         end
37       end
38 
39       def example_failed(example, error)
40         backtrace_tweaker.tweak_backtrace(error)
41         failure = Failure.new(@example_group.description, example.description, error)
42         @failures << failure
43         formatters.each do |f|
44           f.example_failed(example, @failures.length, failure)
45         end
46       end
47 
48       def start(number_of_examples)
49         @start_time = Time.new
50         formatters.each{|f| f.start(number_of_examples)}
51       end
52   
53       def end
54         @end_time = Time.new
55       end
56   
57       # Dumps the summary and returns the total number of failures
58       def dump
59         formatters.each{|f| f.start_dump}
60         dump_pending
61         dump_failures
62         formatters.each do |f|
63           f.dump_summary(duration, @example_count, @failures.length, @pending_count)
64           f.close
65         end
66         @failures.length
67       end
68 
69       class Failure
70         def initialize(group_description, example_description, exception)  # :nodoc:
71           @example_name = "#{group_description} #{example_description}"
72           @exception = exception
73         end
74         
75         # The Exception object raised
76         attr_reader :exception
77         
78         # Header messsage for reporting this failure, including the name of the
79         # example and an indicator of the type of failure. FAILED indicates a
80         # failed expectation. FIXED indicates a pending example that passes, and
81         # no longer needs to be pending. RuntimeError indicates that a
82         # RuntimeError occured.
83         # 
84         # == Examples
85         #
86         #   'A new account should have a zero balance' FAILED
87         #   'A new account should have a zero balance' FIXED
88         #   RuntimeError in 'A new account should have a zero balance'
89         def header
90           if expectation_not_met?
91             "'#{@example_name}' FAILED"
92           elsif pending_fixed?
93             "'#{@example_name}' FIXED"
94           else
95             "#{@exception.class.name} in '#{@example_name}'"
96           end
97         end
98         
99         def pending_fixed? # :nodoc:
100           @exception.is_a?(Spec::Example::PendingExampleFixedError)
101         end
102 
103         def expectation_not_met?  # :nodoc:
104           @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
105         end
106       end
107 
108     private
109 
110       def formatters
111         @options.formatters
112       end
113 
114       def backtrace_tweaker
115         @options.backtrace_tweaker
116       end
117   
118       def dump_failures
119         return if @failures.empty?
120         @failures.inject(1) do |index, failure|
121           formatters.each{|f| f.dump_failure(index, failure)}
122           index + 1
123         end
124       end
125 
126       def dump_pending
127         formatters.each{|f| f.dump_pending}
128       end
129 
130       def duration
131         return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?)
132         return "0.0"
133       end
134       
135       def example_passed(example)
136         formatters.each{|f| f.example_passed(example)}
137       end
138 
139       EXAMPLE_PENDING_DEPRECATION_WARNING = <<-WARNING
140 
141 *********************************************************************
142 DEPRECATION WARNING: RSpec's formatters have changed example_pending
143 to accept two arguments instead of three. Please see the rdoc
144 for Spec::Runner::Formatter::BaseFormatter#example_pending
145 for more information.
146   
147 Please update any custom formatters to accept only two arguments
148 to example_pending. Support for example_pending with two arguments
149 and this warning message will be removed after the RSpec 2.0 release.
150 *********************************************************************      
151 WARNING
152       
153       def example_pending(example, ignore, message="Not Yet Implemented")
154         @pending_count += 1
155         formatters.each do |formatter|
156           if formatter_uses_deprecated_example_pending_method?(formatter)
157             Spec.warn EXAMPLE_PENDING_DEPRECATION_WARNING
158             formatter.example_pending(example, message, example.location)
159           else
160             formatter.example_pending(example, message)
161           end
162         end
163       end
164       
165       def formatter_uses_deprecated_example_pending_method?(formatter)
166         formatter.method(:example_pending).arity == 3
167       end
168       
169     end
170   end
171 end

Generated on Mon May 10 23:40:28 -0700 2010 with rcov 0.9.8