Class: NoradSpecRunner::CustomJsonFormatter

Inherits:
RSpec::Core::Formatters::JsonFormatter
  • Object
show all
Defined in:
lib/norad_spec_runner/formatter.rb

Instance Method Summary collapse

Instance Method Details

#stop(notification) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/norad_spec_runner/formatter.rb', line 8

def stop(notification)
  @output_hash[:examples] = notification.examples.map do |example|
     format_example(example).tap do |hash|
       # Add custom fields to output json hash.
       hash[:norad_nid] = example.norad_nid
       hash[:norad_description] = example.norad_description
       hash[:norad_output] = example.norad_output
       if (ex=example.exception)
         hash[:exception] =  {
           :class => ex.class.name,
           :message => ex.message,
           :backtrace => ex.backtrace,
         }
       end
     end
  end
end