Class: RSpec::Formatters::JsonFormatter
- Inherits:
-
Object
- Object
- RSpec::Formatters::JsonFormatter
- Defined in:
- lib/rspec_formatter_json.rb
Instance Method Summary collapse
- #dump_summary(notification) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(output) ⇒ JsonFormatter
constructor
A new instance of JsonFormatter.
- #start(notification) ⇒ Object
Constructor Details
#initialize(output) ⇒ JsonFormatter
Returns a new instance of JsonFormatter.
15 16 17 18 19 |
# File 'lib/rspec_formatter_json.rb', line 15 def initialize(output) @output = output @results = { examples: [], summary: {} } _ci_harvest end |
Instance Method Details
#dump_summary(notification) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rspec_formatter_json.rb', line 37 def dump_summary(notification) @results[:summary] = { duration: notification.duration, example_count: notification.example_count, failure_count: notification.failure_count, pending_count: notification.pending_count, } @output.puts @results.to_json end |
#example_failed(notification) ⇒ Object
29 30 31 |
# File 'lib/rspec_formatter_json.rb', line 29 def example_failed(notification) @results[:examples] << _example_to_h(notification.example, 'failed') end |
#example_passed(notification) ⇒ Object
25 26 27 |
# File 'lib/rspec_formatter_json.rb', line 25 def example_passed(notification) @results[:examples] << _example_to_h(notification.example, 'passed') end |
#example_pending(notification) ⇒ Object
33 34 35 |
# File 'lib/rspec_formatter_json.rb', line 33 def example_pending(notification) @results[:examples] << _example_to_h(notification.example, 'pending') end |
#start(notification) ⇒ Object
21 22 23 |
# File 'lib/rspec_formatter_json.rb', line 21 def start(notification) @start_time = Time.now end |