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
Instance Attribute Summary
Attributes inherited from InspecRspecJson
Instance Method Summary collapse
- #close(_notification) ⇒ Object
-
#initialize(*args) ⇒ InspecRspecCli
constructor
A new instance of InspecRspecCli.
- #start(_notification) ⇒ Object
Methods inherited from InspecRspecJson
#add_profile, #dump_one_example, #dump_summary, #profile_info
Methods inherited from InspecRspecMiniJson
Constructor Details
#initialize(*args) ⇒ InspecRspecCli
Returns a new instance of InspecRspecCli.
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/inspec/rspec_json_formatter.rb', line 172 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
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/inspec/rspec_json_formatter.rb', line 188 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 |
#start(_notification) ⇒ Object
184 185 186 |
# File 'lib/inspec/rspec_json_formatter.rb', line 184 def start(_notification) @profiles_info ||= Hash[@profiles.map { |x| profile_info(x) }] end |