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' => ' ', }.freeze
- TEST_INDICATORS =
{ 'failed' => ' fail: ', 'skipped' => ' skip: ', 'empty' => ' ', }.freeze
- MULTI_TEST_CONTROL_SUMMARY_MAX_LEN =
60
Instance Attribute Summary
Attributes inherited from InspecRspecJson
Instance Method Summary collapse
- #close(_notification) ⇒ Object
-
#initialize(*args) ⇒ InspecRspecCli
constructor
A new instance of InspecRspecCli.
Methods inherited from InspecRspecJson
#add_profile, #dump_one_example, #dump_summary, #start, #stop
Methods inherited from InspecRspecMiniJson
Constructor Details
#initialize(*args) ⇒ InspecRspecCli
Returns a new instance of InspecRspecCli.
223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/inspec/rspec_json_formatter.rb', line 223 def initialize(*args) @colors = COLORS @indicators = INDICATORS @test_indicators = TEST_INDICATORS @format = '%color%indicator%id%summary' @current_control = nil @current_profile = nil @missing_controls = [] super(*args) end |
Instance Method Details
#close(_notification) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/inspec/rspec_json_formatter.rb', line 235 def close(_notification) flush_current_control output.puts('') unless @current_control.nil? @profiles_info.each do |_id, 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.' ) output.puts('') end res = @output_hash[:summary] passed = res[:example_count] - res[:failure_count] - res[:skip_count] s = format('Summary: %s%d successful%s, %s%d failures%s, %s%d skipped%s', COLORS['passed'], passed, COLORS['reset'], COLORS['failed'], res[:failure_count], COLORS['reset'], COLORS['skipped'], res[:skip_count], COLORS['reset']) output.puts(s) end |