Class: Verity::Reporters::DotsReporter

Inherits:
Object
  • Object
show all
Includes:
Verity::Reporter
Defined in:
lib/verity/reporters/dots_reporter.rb

Overview

Public: Minimal reporter that prints a single character per test: “.” for pass, “F” for failure, “E” for error. No color.

Direct Known Subclasses

ColoredDotsReporter

Instance Method Summary collapse

Methods included from Verity::Reporter

#on_run_start

Constructor Details

#initialize(io = $stdout) ⇒ DotsReporter

Public: Create a new DotsReporter.

io - IO object for output (default $stdout).



13
14
15
# File 'lib/verity/reporters/dots_reporter.rb', line 13

def initialize(io = $stdout)
  @io = io
end

Instance Method Details

#on_parallel_complete(counts:, problem_rows:) ⇒ Object

Public: Delegate to ParallelSummaryReporter for the multi-worker summary.



43
44
45
# File 'lib/verity/reporters/dots_reporter.rb', line 43

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.



31
32
33
34
35
36
37
38
39
40
# File 'lib/verity/reporters/dots_reporter.rb', line 31

def on_run_finish(summary:, worker_id:)
  t = summary[:total]
  p = summary[:passed]
  f = summary[:failed]
  e = summary[:errored]
  line = "\n\n#{t} tests: #{p} passed, #{f} failed, #{e} errored"
  line += ", #{summary[:skipped]} skipped" if summary[:skipped].to_i.positive?
  line += " (focus)" if summary[:focus]
  @io.puts line
end

#on_test_complete(result:, worker_id:) ⇒ Object

Public: Print a dot, F, E, or S (skip) for the completed test.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/verity/reporters/dots_reporter.rb', line 18

def on_test_complete(result:, worker_id:)
  char =
    case result.status
    when :pass then "."
    when :fail then "F"
    when :error then "E"
    when :skip then "S"
    end
  @io.print char
  @io.flush
end