4 attr_reader :options, :example_groups
6 def initialize(options)
8 @options.reporter = self
12 def add_example_group(example_group)
13 formatters.each do |f|
14 f.add_example_group(example_group)
16 example_groups << example_group
19 def example_started(example)
20 formatters.each{|f| f.example_started(example)}
23 def example_finished(example, error=nil)
27 example_passed(example)
28 elsif Spec::Example::ExamplePendingError === error
29 example_pending(example_groups.last, example, error.message)
31 example_failed(example, error)
35 def failure(example, error)
36 backtrace_tweaker.tweak_backtrace(error)
37 example_name = "#{example_groups.last.description} #{example.description}"
38 failure = Failure.new(example_name, error)
40 formatters.each do |f|
41 f.example_failed(example, @failures.length, failure)
44 alias_method :example_failed, :failure
46 def start(number_of_examples)
48 @start_time = Time.new
49 formatters.each{|f| f.start(number_of_examples)}
56 # Dumps the summary and returns the total number of failures
58 formatters.each{|f| f.start_dump}
61 formatters.each do |f|
62 f.dump_summary(duration, @examples.length, @failures.length, @pending_count)
75 @options.backtrace_tweaker
88 return if @failures.empty?
89 @failures.inject(1) do |index, failure|
90 formatters.each{|f| f.dump_failure(index, failure)}
95 formatters.each{|f| f.dump_pending}
99 return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?)
103 def example_passed(example)
104 formatters.each{|f| f.example_passed(example)}
107 def example_pending(example_group, example, message="Not Yet Implemented")
109 formatters.each do |f|
110 f.example_pending(example_group.description, example, message)
115 attr_reader :exception
117 def initialize(example_name, exception)
118 @example_name = example_name
119 @exception = exception
123 if expectation_not_met?
124 "'#{@example_name}' FAILED"
126 "'#{@example_name}' FIXED"
128 "#{@exception.class.name} in '#{@example_name}'"
133 @exception.is_a?(Spec::Example::PendingExampleFixedError)
136 def expectation_not_met?
137 @exception.is_a?(Spec::Expectations::ExpectationNotMetError)