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.
1 module Spec
2 module Runner
3 class Reporter
4
5 def initialize(formatters, backtrace_tweaker)
6 @formatters = formatters
7 @backtrace_tweaker = backtrace_tweaker
8 clear!
9 end
10
11 def add_behaviour(name)
12 @formatters.each{|f| f.add_behaviour(name)}
13 @behaviour_names << name
14 end
15
16 def example_started(name)
17 @formatters.each{|f| f.example_started(name)}
18 end
19
20 def example_finished(name, error=nil, failure_location=nil, not_implemented = false)
21 @example_names << name
22
23 if not_implemented
24 example_pending(@behaviour_names.last, name)
25 elsif error.nil?
26 example_passed(name)
27 elsif Spec::DSL::ExamplePendingError === error
28 example_pending(@behaviour_names.last, name, error.message)
29 else
30 example_failed(name, error, failure_location)
31 end
32 end
33
34 def start(number_of_examples)
35 clear!
36 @start_time = Time.new
37 @formatters.each{|f| f.start(number_of_examples)}
38 end
39
40 def end
41 @end_time = Time.new
42 end
43
44 # Dumps the summary and returns the total number of failures
45 def dump
46 @formatters.each{|f| f.start_dump}
47 dump_failures
48 @formatters.each do |f|
49 f.dump_summary(duration, @example_names.length, @failures.length, @pending_count)
50 f.close
51 end
52 @failures.length
53 end
54
55 private
56
57 def clear!
58 @behaviour_names = []
59 @failures = []
60 @pending_count = 0
61 @example_names = []
62 @start_time = nil
63 @end_time = nil
64 end
65
66 def dump_failures
67 return if @failures.empty?
68 @failures.inject(1) do |index, failure|
69 @formatters.each{|f| f.dump_failure(index, failure)}
70 index + 1
71 end
72 end
73
74 def duration
75 return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?)
76 return "0.0"
77 end
78
79 def example_passed(name)
80 @formatters.each{|f| f.example_passed(name)}
81 end
82
83 def example_failed(name, error, failure_location)
84 @backtrace_tweaker.tweak_backtrace(error, failure_location)
85 example_name = "#{@behaviour_names.last} #{name}"
86 failure = Failure.new(example_name, error)
87 @failures << failure
88 @formatters.each{|f| f.example_failed(name, @failures.length, failure)}
89 end
90
91 def example_pending(behaviour_name, example_name, message="Not Yet Implemented")
92 @pending_count += 1
93 @formatters.each{|f| f.example_pending(behaviour_name, example_name, message)}
94 end
95
96 class Failure
97 attr_reader :exception
98
99 def initialize(example_name, exception)
100 @example_name = example_name
101 @exception = exception
102 end
103
104 def header
105 if expectation_not_met?
106 "'#{@example_name}' FAILED"
107 elsif pending_fixed?
108 "'#{@example_name}' FIXED"
109 else
110 "#{@exception.class.name} in '#{@example_name}'"
111 end
112 end
113
114 def pending_fixed?
115 @exception.is_a?(Spec::DSL::PendingFixedError)
116 end
117
118 def expectation_not_met?
119 @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
120 end
121
122 end
123 end
124 end
125 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.