Sha256: 14917d75de77376a8fbbe9ab02667181afa1cc8671ed12fcc5903394003fe21b
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'delegate' module Minitest module Reporters class FailureFormatter < SimpleDelegator include ANSI::Code def initialize(test) @test = test super end def to_s [ header, body, "\n" ].flatten.compact.join("\n") end def to_h { test_and_module_name: "#{test.klass}##{test.name}", test_name: test.name, output: to_s, } end private attr_reader :test def header "#{red(status)} #{test.klass}##{test.name}" end def status if test.error? 'ERROR' elsif test.failure 'FAIL' else raise ArgumentError, "Couldn't infer test status" end end def body error = test.failure message = if error.is_a?(MiniTest::UnexpectedError) "#{error.exception.class}: #{error.exception.message}" else error.exception.message end backtrace = Minitest.filter_backtrace(error.backtrace).map { |line| ' ' + relativize(line) } [yellow(message), *backtrace].join("\n") end def relativize(trace_line) trace_line.sub(/\A#{Regexp.escape("#{Dir.pwd}/")}/, '') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ci-queue-0.10.1 | lib/minitest/reporters/failure_formatter.rb |
ci-queue-0.10.0 | lib/minitest/reporters/failure_formatter.rb |