5 def initialize(formatters, backtrace_tweaker)
6 @formatters = formatters
7 @backtrace_tweaker = backtrace_tweaker
11 def add_behaviour(name)
12 @formatters.each{|f| f.add_behaviour(name)}
13 @behaviour_names << name
16 def example_started(name)
17 @formatters.each{|f| f.example_started(name)}
20 def example_finished(name, error=nil, failure_location=nil, not_implemented = false)
21 @example_names << name
24 example_not_implemented(name)
28 example_failed(name, error, failure_location)
32 def start(number_of_examples)
34 @start_time = Time.new
35 @formatters.each{|f| f.start(number_of_examples)}
42 # Dumps the summary and returns the total number of failures
44 @formatters.each{|f| f.start_dump}
46 @formatters.each{|f| f.dump_summary(duration, @example_names.length, @failures.length, @not_implemented_count)}
55 @not_implemented_count = 0
62 return if @failures.empty?
63 @failures.inject(1) do |index, failure|
64 @formatters.each{|f| f.dump_failure(index, failure)}
70 return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?)
74 def example_passed(name)
75 @formatters.each{|f| f.example_passed(name)}
78 def example_failed(name, error, failure_location)
79 @backtrace_tweaker.tweak_backtrace(error, failure_location)
80 example_name = "#{@behaviour_names.last} #{name}"
81 failure = Failure.new(example_name, error)
83 @formatters.each{|f| f.example_failed(name, @failures.length, failure)}
86 def example_not_implemented(name)
87 @not_implemented_count += 1
88 @formatters.each{|f| f.example_not_implemented(name)}
92 attr_reader :exception
94 def initialize(example_name, exception)
95 @example_name = example_name
96 @exception = exception
100 if expectation_not_met?
101 "'#{@example_name}' FAILED"
103 "#{@exception.class.name} in '#{@example_name}'"
107 def expectation_not_met?
108 @exception.is_a?(Spec::Expectations::ExpectationNotMetError)