Class: AirborneReport::RspecJsonFormatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/airborne_report/rspec_json_formatter.rb

Instance Method Summary collapse

Instance Method Details

#craft_json(report) ⇒ Object



22
23
24
25
26
# File 'lib/airborne_report/rspec_json_formatter.rb', line 22

def craft_json(report)
  File.open('report.json', 'w') do |file|
    file.write(MultiJson.dump(report))
  end
end

#start(_notification) ⇒ Object



10
11
12
# File 'lib/airborne_report/rspec_json_formatter.rb', line 10

def start(_notification)
  AirborneReport::JsonFile.save(Report.blank)
end

#stop(notification) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/airborne_report/rspec_json_formatter.rb', line 14

def stop(notification)
  tests = AirborneReport::JsonFile.tests
  AirborneReport::JsonFile.destroy

  report = Report.new(tests, notification).to_hash
  craft_json(report)
end