lib/minitest/utils/reporter.rb in minitest-utils-0.4.6 vs lib/minitest/utils/reporter.rb in minitest-utils-0.4.7

- old
+ new

@@ -1,10 +1,10 @@ # frozen_string_literal: true module Minitest module Utils - class Reporter < Minitest::StatisticsReporter # rubocop:disable Metrics/ClassLength + class Reporter < Minitest::StatisticsReporter COLOR_FOR_RESULT_CODE = { "." => :green, "E" => :red, "F" => :red, "S" => :yellow @@ -33,11 +33,11 @@ io.puts io.puts "# Running:" io.puts end - def report # rubocop:disable Metrics/MethodLength + def report super io.sync = true failing_results = results.reject(&:skipped?) skipped_results = results.select(&:skipped?) @@ -146,11 +146,15 @@ return if backtrace.empty? indent(backtrace.join("\n")).gsub(/^(\s+)/, "\\1# ") end - private def location(location, include_line_number = false) + private def location(location, include_line_number = false) # rubocop:disable Style/OptionalBooleanParameter + matches = location.match(/^(<.*?>)/) + + return matches[1] if matches + regex = include_line_number ? /^([^:]+:\d+)/ : /^([^:]+)/ location = File.expand_path(location[regex, 1]) return location unless location.start_with?(Dir.pwd) @@ -162,10 +166,10 @@ end private def result_name(name) name .gsub(/^test(_\d+)?_/, "") - .gsub(/_/, " ") + .tr("_", " ") end private def print_result_code(result_code) result_code = color(result_code, COLOR_FOR_RESULT_CODE[result_code]) io.print result_code