Class: Ask::Ruby::Harness::MinitestJsonReporter
- Inherits:
-
Minitest::AbstractReporter
- Object
- Minitest::AbstractReporter
- Ask::Ruby::Harness::MinitestJsonReporter
- Defined in:
- lib/ask/ruby/harness/minitest_json_reporter.rb
Overview
Writes a machine-readable JSON summary of a minitest run.
Registered by the ask_ruby_harness minitest plugin when the ASK_TEST_JSON_PATH env var is set (see the run_tests tool). Produces stable structured results — test name, klass, source file/line, status, and a message head — so the harness never has to parse terminal output.
The reporter is inert unless ASK_TEST_JSON_PATH is set, so ordinary
rake test / bin/rails test runs in projects that ship the harness
are unaffected.
Instance Method Summary collapse
-
#initialize(path = ENV["ASK_TEST_JSON_PATH"]) ⇒ MinitestJsonReporter
constructor
A new instance of MinitestJsonReporter.
-
#passed? ⇒ Boolean
Never influences the process exit status — pass/fail is decided by minitest's own summary reporter.
- #record(result) ⇒ Object
- #report ⇒ Object
Constructor Details
#initialize(path = ENV["ASK_TEST_JSON_PATH"]) ⇒ MinitestJsonReporter
Returns a new instance of MinitestJsonReporter.
20 21 22 23 24 |
# File 'lib/ask/ruby/harness/minitest_json_reporter.rb', line 20 def initialize(path = ENV["ASK_TEST_JSON_PATH"]) super() @path = path @results = [] end |
Instance Method Details
#passed? ⇒ Boolean
Never influences the process exit status — pass/fail is decided by minitest's own summary reporter.
37 38 39 |
# File 'lib/ask/ruby/harness/minitest_json_reporter.rb', line 37 def passed? true end |
#record(result) ⇒ Object
26 27 28 |
# File 'lib/ask/ruby/harness/minitest_json_reporter.rb', line 26 def record(result) @results << result end |
#report ⇒ Object
30 31 32 33 |
# File 'lib/ask/ruby/harness/minitest_json_reporter.rb', line 30 def report return if @path.nil? || @path.to_s.empty? File.write(@path, JSON.pretty_generate(build_report)) end |