Class: Spec::Runner::Reporter
Defined Under Namespace
Classes: Failure
Instance Method Summary collapse
- #add_context(name) ⇒ Object
-
#dump ⇒ Object
Dumps the summary and returns the total number of failures.
- #end ⇒ Object
-
#initialize(formatter, backtrace_tweaker) ⇒ Reporter
constructor
A new instance of Reporter.
- #spec_finished(name, error = nil, failure_location = nil) ⇒ Object
- #spec_started(name) ⇒ Object
- #start(number_of_specs) ⇒ Object
Constructor Details
#initialize(formatter, backtrace_tweaker) ⇒ Reporter
Returns a new instance of Reporter.
5 6 7 8 9 10 11 |
# File 'lib/spec/runner/reporter.rb', line 5 def initialize(formatter, backtrace_tweaker) @formatter = formatter @context_names = [] @failures = [] @spec_names = [] @backtrace_tweaker = backtrace_tweaker end |
Instance Method Details
#add_context(name) ⇒ Object
13 14 15 16 17 |
# File 'lib/spec/runner/reporter.rb', line 13 def add_context(name) #TODO - @context_names.empty? tells the formatter whether this is the first context or not - that's a little slippery @formatter.add_context(name, @context_names.empty?) @context_names << name end |
#dump ⇒ Object
Dumps the summary and returns the total number of failures
43 44 45 46 47 48 |
# File 'lib/spec/runner/reporter.rb', line 43 def dump @formatter.start_dump dump_failures @formatter.dump_summary(duration, @spec_names.length, @failures.length) @failures.length end |
#end ⇒ Object
38 39 40 |
# File 'lib/spec/runner/reporter.rb', line 38 def end @end_time = Time.new end |
#spec_finished(name, error = nil, failure_location = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/spec/runner/reporter.rb', line 24 def spec_finished(name, error=nil, failure_location=nil) if error.nil? spec_passed(name) else @backtrace_tweaker.tweak_backtrace(error, failure_location) spec_failed(name, Failure.new(@context_names.last, name, error)) end end |
#spec_started(name) ⇒ Object
19 20 21 22 |
# File 'lib/spec/runner/reporter.rb', line 19 def spec_started(name) @spec_names << name @formatter.spec_started(name) end |
#start(number_of_specs) ⇒ Object
33 34 35 36 |
# File 'lib/spec/runner/reporter.rb', line 33 def start(number_of_specs) @start_time = Time.new @formatter.start(number_of_specs) end |