Class: InspecRspecMiniJson
- Inherits:
-
RSpec::Core::Formatters::JsonFormatter
- Object
- RSpec::Core::Formatters::JsonFormatter
- InspecRspecMiniJson
- Defined in:
- lib/inspec/rspec_json_formatter.rb
Overview
Minimal JSON formatter for inspec. Only contains limited information about examples without any extras.
Direct Known Subclasses
Instance Method Summary collapse
-
#dump_summary(summary) ⇒ Object
Called after stop has been called and the run is complete.
-
#stop(notification) ⇒ Object
Called at the end of a complete RSpec run.
Instance Method Details
#dump_summary(summary) ⇒ Object
Called after stop has been called and the run is complete.
38 39 40 41 42 43 |
# File 'lib/inspec/rspec_json_formatter.rb', line 38 def dump_summary(summary) @output_hash[:version] = Inspec::VERSION @output_hash[:statistics] = { duration: summary.duration, } end |
#stop(notification) ⇒ Object
Called at the end of a complete RSpec run.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/inspec/rspec_json_formatter.rb', line 46 def stop(notification) # This might be a bit confusing. The results are not actually organized # by control. It is organized by test. So if a control has 3 tests, the # output will have 3 control entries, each one with the same control id # and different test results. An rspec example maps to an inspec test. @output_hash[:controls] = notification.examples.map do |example| format_example(example).tap do |hash| e = example.exception next unless e hash[:message] = e. next if e.is_a? RSpec::Expectations::ExpectationNotMetError hash[:exception] = e.class.name hash[:backtrace] = e.backtrace end end end |