Class: ZSpec::Formatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- ZSpec::Formatter
- Defined in:
- lib/zspec/formatter.rb
Instance Method Summary collapse
- #close(_notification) ⇒ Object
- #dump_summary(summary) ⇒ Object
- #example_failed(failure) ⇒ Object
-
#initialize(queue:, tracker:, stdout:, message:) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(queue:, tracker:, stdout:, message:) ⇒ Formatter
Returns a new instance of Formatter.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/zspec/formatter.rb', line 5 def initialize(queue:, tracker:, stdout:, message:) super @output_hash = { failures: [] } @failed = false @errors_outside_of_examples = false @message = @queue = queue @tracker = tracker @stdout = stdout end |
Instance Method Details
#close(_notification) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/zspec/formatter.rb', line 31 def close(_notification) @queue.resolve( @failed, @message, @output_hash.to_json, @stdout.string ) @tracker.track_runtime(@message, @duration) @tracker.track_failures(@output_hash[:failures]) if @failed @tracker.track_sequence(@message) raise if @errors_outside_of_examples end |
#dump_summary(summary) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/zspec/formatter.rb', line 21 def dump_summary(summary) @duration = summary.duration # only set to true if there is a failure, otherwise it will override the failures from example_failed if summary.errors_outside_of_examples_count.to_i > 0 @failed = true @errors_outside_of_examples = true end @output_hash[:summary] = format_summary(summary) end |
#example_failed(failure) ⇒ Object
16 17 18 19 |
# File 'lib/zspec/formatter.rb', line 16 def example_failed(failure) @failed = true @output_hash[:failures] << format_example(failure.example) end |