Class: InspecRspecCli
- Inherits:
-
InspecRspecJson
- Object
- RSpec::Core::Formatters::JsonFormatter
- InspecRspecMiniJson
- InspecRspecJson
- InspecRspecCli
- Defined in:
- lib/inspec/rspec_json_formatter.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- STATUS_TYPES =
{ 'unknown' => -3, 'passed' => -2, 'skipped' => -1, 'minor' => 1, 'major' => 2, 'failed' => 2.5, 'critical' => 3, }.freeze
- COLORS =
{ 'critical' => "\033[31;1m", 'major' => "\033[31m", 'minor' => "\033[33m", 'failed' => "\033[31m", 'passed' => "\033[32m", 'skipped' => "\033[37m", 'reset' => "\033[0m", }.freeze
- INDICATORS =
{ 'critical' => ' ✖ ', 'major' => ' ✖ ', 'minor' => ' ✖ ', 'failed' => ' ✖ ', 'skipped' => ' ○ ', 'passed' => ' ✔ ', 'unknown' => ' ? ', 'empty' => ' ', 'small' => ' ', }.freeze
- MULTI_TEST_CONTROL_SUMMARY_MAX_LEN =
60
Instance Attribute Summary
Attributes inherited from InspecRspecJson
Instance Method Summary collapse
-
#close(_notification) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(*args) ⇒ InspecRspecCli
constructor
A new instance of InspecRspecCli.
Methods inherited from InspecRspecJson
#add_profile, #controls_summary, #dump_one_example, #start, #stop, #tests_summary
Methods inherited from InspecRspecMiniJson
Constructor Details
#initialize(*args) ⇒ InspecRspecCli
Returns a new instance of InspecRspecCli.
280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/inspec/rspec_json_formatter.rb', line 280 def initialize(*args) @colors = COLORS @indicators = INDICATORS @format = '%color%indicator%id%summary' @current_control = nil @current_profile = nil @missing_controls = [] @anonymous_tests = [] @control_tests = [] super(*args) end |
Instance Method Details
#close(_notification) ⇒ Object
rubocop:disable Metrics/AbcSize
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/inspec/rspec_json_formatter.rb', line 293 def close(_notification) # rubocop:disable Metrics/AbcSize flush_current_control output.puts('') unless @current_control.nil? print_tests output.puts('') @profiles_info.each do |profile| next if profile[:already_printed] @current_profile = profile next unless print_current_profile print_line( color: '', indicator: @indicators['empty'], id: '', profile: '', summary: 'No tests executed.' ) if @current_control.nil? output.puts('') end 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 |