Class: Verity::Reporters::DocumentationReporter
- Inherits:
-
Object
- Object
- Verity::Reporters::DocumentationReporter
- Includes:
- Verity::Reporter
- Defined in:
- lib/verity/reporters/documentation_reporter.rb
Overview
Public: Verbose reporter that prints one indented line per test, nesting output under group headers. Uses ANSI colors (green/red/yellow/magenta) when outputting to a TTY, unless suppressed by NO_COLOR or forced via FORCE_COLOR / VERITY_FORCE_COLOR.
Constant Summary collapse
- ESC =
"\e["- RESET =
"#{ESC}0m"- PASS_STYLE =
"#{ESC}32m"- FAIL_STYLE =
"#{ESC}31m"- SKIP_STYLE =
"#{ESC}33m"- ERROR_STYLE =
"#{ESC}35m"
Instance Method Summary collapse
-
#initialize(io = $stdout, color: nil) ⇒ DocumentationReporter
constructor
Public: Create a new DocumentationReporter.
-
#on_parallel_complete(counts:, problem_rows:) ⇒ Object
Public: Delegate to ParallelSummaryReporter for the multi-worker summary.
-
#on_run_finish(summary:, worker_id:) ⇒ Object
Public: Print the final summary line with counts and optional color.
-
#on_run_start(total:, worker_id:) ⇒ Object
Public: Print a “Running N tests…” header.
-
#on_test_complete(result:, worker_id:) ⇒ Object
Public: Print a status-labeled line for the completed test, indented under its group headers.
Constructor Details
#initialize(io = $stdout, color: nil) ⇒ DocumentationReporter
Public: Create a new DocumentationReporter.
io - IO object for output (default $stdout). color - Boolean to force color on/off, or nil for auto-detect.
23 24 25 26 |
# File 'lib/verity/reporters/documentation_reporter.rb', line 23 def initialize(io = $stdout, color: nil) @io = io @color_override = color end |
Instance Method Details
#on_parallel_complete(counts:, problem_rows:) ⇒ Object
Public: Delegate to ParallelSummaryReporter for the multi-worker summary.
81 82 83 |
# File 'lib/verity/reporters/documentation_reporter.rb', line 81 def on_parallel_complete(counts:, problem_rows:) ParallelSummaryReporter.new(@io).emit(counts:, problem_rows:) end |
#on_run_finish(summary:, worker_id:) ⇒ Object
Public: Print the final summary line with counts and optional color.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/verity/reporters/documentation_reporter.rb', line 57 def on_run_finish(summary:, worker_id:) t = summary[:total] p = summary[:passed] f = summary[:failed] e = summary[:errored] sk = summary[:skipped].to_i if color? parts = [ "\n#{t} tests:", "#{paint("#{p} passed", PASS_STYLE)},", "#{paint("#{f} failed", FAIL_STYLE)},", "#{paint("#{e} errored", ERROR_STYLE)}" ] parts << ", #{paint("#{sk} skipped", SKIP_STYLE)}" if sk.positive? line = "#{parts.join(" ")}#{RESET}" else line = "\n#{t} tests: #{p} passed, #{f} failed, #{e} errored" line += ", #{sk} skipped" if sk.positive? end line += " (focus)" if summary[:focus] @io.puts line end |
#on_run_start(total:, worker_id:) ⇒ Object
Public: Print a “Running N tests…” header.
29 30 31 32 33 34 35 |
# File 'lib/verity/reporters/documentation_reporter.rb', line 29 def on_run_start(total:, worker_id:) @last_group_path = nil return if total.nil? @io.puts "Running #{total} tests..." @io.puts end |
#on_test_complete(result:, worker_id:) ⇒ Object
Public: Print a status-labeled line for the completed test, indented under its group headers.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/verity/reporters/documentation_reporter.rb', line 39 def on_test_complete(result:, worker_id:) path = Array(result.test.group_path) emit_group_headers(path) indent = " " * (path.size + 1) case result.status when :pass @io.puts "#{indent}#{paint("pass", PASS_STYLE)} #{result.test.description}" when :fail @io.puts "#{indent}#{paint("FAIL", FAIL_STYLE)} #{result.test.description}\n #{result.error.}" when :error msg = "#{result.error.class}: #{result.error.}" @io.puts "#{indent}#{paint("ERROR", ERROR_STYLE)} #{result.test.description}\n #{msg}" when :skip @io.puts "#{indent}#{paint("skip", SKIP_STYLE)} #{result.test.description}" end end |