Method: Inspec::Formatters::Base#stop
- Defined in:
- lib/inspec/formatters/base.rb
#stop(notification) ⇒ Object
RSpec Override: #stop
Called at the end of a complete RSpec run. We use this to map tests to controls and flesh out the rest of the run_data hash to include details about the run, the platform, etc.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/inspec/formatters/base.rb', line 35 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. run_data[:controls] = notification.examples.map do |example| format_example(example).tap do |hash| e = example.exception next unless e if example.[:sensitive] hash[:message] = '*** sensitive output suppressed ***' else hash[:message] = (e) end next if e.is_a? RSpec::Expectations::ExpectationNotMetError hash[:exception] = e.class.name hash[:backtrace] = e.backtrace end end # include any tests that were run that were not part of a control run_data[:other_checks] = examples_without_controls examples_with_controls.each do |example| control = example2control(example) move_example_into_control(example, control) end # flesh out the profiles key with additional profile information run_data[:profiles] = profiles_info # add the platform information for this particular target run_data[:platform] = { name: platform(:name), release: platform(:release), target: backend_target, } end |