Method: InspecRspecCli#close

Defined in:
lib/inspec/rspec_json_formatter.rb

#close(_notification) ⇒ Object

rubocop:disable Metrics/AbcSize



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/inspec/rspec_json_formatter.rb', line 294

def close(_notification) # rubocop:disable Metrics/AbcSize
  flush_current_control
  output.puts('') unless @current_control.nil?
  print_tests
  output.puts('')

  print_profiles_info if !@profile_printed
  controls_res = controls_summary
  tests_res = tests_summary

  s = format('Profile Summary: %s%d successful%s, %s%d failures%s, %s%d skipped%s',
             COLORS['passed'], controls_res['passed'], COLORS['reset'],
             COLORS['failed'], controls_res['failed']['total'], COLORS['reset'],
             COLORS['skipped'], controls_res['skipped'], COLORS['reset'])
  output.puts(s) if controls_res['total'] > 0

  s = format('Test Summary: %s%d successful%s, %s%d failures%s, %s%d skipped%s',
             COLORS['passed'], tests_res['passed'], COLORS['reset'],
             COLORS['failed'], tests_res['failed'], COLORS['reset'],
             COLORS['skipped'], tests_res['skipped'], COLORS['reset'])
  output.puts(s) if !@anonymous_tests.empty? || @current_control.nil?
end