Class: RSpec::Risky::JsonEventFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/risky/json_event_formatter.rb,
sig/rspec/risky.rbs

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ JsonEventFormatter

Returns a new instance of JsonEventFormatter.



11
12
13
# File 'lib/rspec/risky/json_event_formatter.rb', line 11

def initialize(output)
  @output = output
end

Instance Method Details

#example_finished(notification) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/rspec/risky/json_event_formatter.rb', line 15

def example_finished(notification)
  result = notification.example.[:rspec_risky]
  return unless result

  result[:verdicts].each do |verdict|
    @output.write(JSON.generate(event_payload(notification.example, result, verdict)))
    @output.write("\n")
  end
end