Class: Spec::Runner::Reporter
Defined Under Namespace
Classes: Failure
Instance Attribute Summary collapse
-
#example_groups ⇒ Object
readonly
Returns the value of attribute example_groups.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add_example_group(example_group) ⇒ Object
-
#dump ⇒ Object
Dumps the summary and returns the total number of failures.
- #end ⇒ Object
- #example_failed(example, error) ⇒ Object
- #example_finished(example, error = nil) ⇒ Object
- #example_started(example) ⇒ Object
-
#initialize(options) ⇒ Reporter
constructor
A new instance of Reporter.
- #start(number_of_examples) ⇒ Object
Constructor Details
#initialize(options) ⇒ Reporter
Returns a new instance of Reporter.
6 7 8 9 10 |
# File 'lib/spec/runner/reporter.rb', line 6 def initialize() @options = @options.reporter = self clear end |
Instance Attribute Details
#example_groups ⇒ Object (readonly)
Returns the value of attribute example_groups.
4 5 6 |
# File 'lib/spec/runner/reporter.rb', line 4 def example_groups @example_groups end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/spec/runner/reporter.rb', line 4 def @options end |
Instance Method Details
#add_example_group(example_group) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/spec/runner/reporter.rb', line 12 def add_example_group(example_group) formatters.each do |f| f.add_example_group(example_group) end example_groups << example_group end |
#dump ⇒ Object
Dumps the summary and returns the total number of failures
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/spec/runner/reporter.rb', line 55 def dump formatters.each{|f| f.start_dump} dump_pending dump_failures formatters.each do |f| f.dump_summary(duration, @examples.length, @failures.length, @pending_count) f.close end @failures.length end |
#end ⇒ Object
50 51 52 |
# File 'lib/spec/runner/reporter.rb', line 50 def end @end_time = Time.new end |
#example_failed(example, error) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/spec/runner/reporter.rb', line 35 def example_failed(example, error) backtrace_tweaker.tweak_backtrace(error) failure = Failure.new(example_groups.empty? ? "" : example_groups.last.description, example, error) @failures << failure formatters.each do |f| f.example_failed(example, @failures.length, failure) end end |
#example_finished(example, error = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/spec/runner/reporter.rb', line 23 def example_finished(example, error=nil) @examples << example if error.nil? example_passed(example) elsif Spec::Example::ExamplePendingError === error example_pending(example, error.pending_caller, error.) else example_failed(example, error) end end |
#example_started(example) ⇒ Object
19 20 21 |
# File 'lib/spec/runner/reporter.rb', line 19 def example_started(example) formatters.each{|f| f.example_started(example)} end |
#start(number_of_examples) ⇒ Object
44 45 46 47 48 |
# File 'lib/spec/runner/reporter.rb', line 44 def start(number_of_examples) clear @start_time = Time.new formatters.each{|f| f.start(number_of_examples)} end |