Class: SpecGuard::Minitest::Reporter
- Inherits:
-
Object
- Object
- SpecGuard::Minitest::Reporter
- Defined in:
- lib/specguard/minitest/reporter.rb
Class Method Summary collapse
-
.repo_root ⇒ Object
Dir.pwdat load time, not per row: a reporter constructed inside a test that changes the working directory would otherwise relativize one suite's rows against two different roots.
Instance Method Summary collapse
-
#initialize(configuration: SpecGuard::RSpec.configuration, transport: nil, output: $stderr, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }) ⇒ Reporter
constructor
A new instance of Reporter.
-
#passed? ⇒ Boolean
Constant by contract — see the class comment.
-
#prerecord(_klass, _name) ⇒ Object
Minitest's
CompositeReportercalls this before every runnable, and minitest 6 requires it on every reporter in the composite — a duck type without it is not "a reporter that ignores prerecords", it is a crash insideRunnable#runthat takes the suite's exit code with it, which is the one thing this class may never do. -
#record(result) ⇒ Object
One
Minitest::Resultin, one wire row out. -
#report ⇒ Object
Minitest calls this after every runnable has reported, on the same reporter — the delivery point.
- #start ⇒ Object
Constructor Details
#initialize(configuration: SpecGuard::RSpec.configuration, transport: nil, output: $stderr, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }) ⇒ Reporter
Returns a new instance of Reporter.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/specguard/minitest/reporter.rb', line 52 def initialize(configuration: SpecGuard::RSpec.configuration, transport: nil, output: $stderr, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }) @configuration = configuration # Injected for the specs; the real thing is built the same way the # RSpec formatter builds it, from the same configuration object. @transport = transport @output = output @clock = clock @rows = [] @started_at = nil @warned = false end |
Class Method Details
.repo_root ⇒ Object
Dir.pwd at load time, not per row: a reporter constructed inside a
test that changes the working directory would otherwise relativize
one suite's rows against two different roots.
47 48 49 |
# File 'lib/specguard/minitest/reporter.rb', line 47 def repo_root Dir.pwd end |
Instance Method Details
#passed? ⇒ Boolean
Constant by contract — see the class comment. Public because
CompositeReporter#passed? is all? over its reporters and this one
must never be the reporter that flips a green suite red.
104 105 106 |
# File 'lib/specguard/minitest/reporter.rb', line 104 def passed? true end |
#prerecord(_klass, _name) ⇒ Object
Minitest's CompositeReporter calls this before every runnable, and
minitest 6 requires it on every reporter in the composite — a duck
type without it is not "a reporter that ignores prerecords", it is a
crash inside Runnable#run that takes the suite's exit code with it,
which is the one thing this class may never do. A no-op records
nothing: the row this adapter wants is the finished Result, not the
promise of one.
77 |
# File 'lib/specguard/minitest/reporter.rb', line 77 def prerecord(_klass, _name); end |
#record(result) ⇒ Object
One Minitest::Result in, one wire row out. Guarded rather than
trusted for the same reason the RSpec formatter guards capture:
nothing a result object does while being read may cost the suite its
exit code.
83 84 85 86 87 88 |
# File 'lib/specguard/minitest/reporter.rb', line 83 def record(result) row = row_for(result) @rows << row if row rescue ScriptError, StandardError nil end |
#report ⇒ Object
Minitest calls this after every runnable has reported, on the same reporter — the delivery point. A run that recorded nothing ships nothing, mirroring the RSpec formatter's stance on an empty suite.
93 94 95 96 97 98 99 |
# File 'lib/specguard/minitest/reporter.rb', line 93 def report return if @rows.empty? deliver(payload) rescue ScriptError, StandardError => e warn_once("could not ship test telemetry (#{e.class}: #{e.}). The test run is unaffected.") end |
#start ⇒ Object
66 67 68 |
# File 'lib/specguard/minitest/reporter.rb', line 66 def start @started_at = @clock.call end |