From 40a5ba30fb41eba633106509c5b362761b18d497 Mon Sep 17 00:00:00 2001 From: Kevin Robatel Date: Mon, 5 Feb 2018 12:04:25 +0100 Subject: Add SuppressedSummaryReporter and TestUnitReporter only if necessary --- railties/lib/minitest/rails_plugin.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'railties/lib/minitest') diff --git a/railties/lib/minitest/rails_plugin.rb b/railties/lib/minitest/rails_plugin.rb index 6901b0bbc8..8b2f15a842 100644 --- a/railties/lib/minitest/rails_plugin.rb +++ b/railties/lib/minitest/rails_plugin.rb @@ -43,10 +43,19 @@ module Minitest Minitest.backtrace_filter = ::Rails.backtrace_cleaner if ::Rails.respond_to?(:backtrace_cleaner) end + self.plugin_rails_replace_reporters(reporter, options) + end + + def self.plugin_rails_replace_reporters(minitest_reporter, options) + return unless minitest_reporter.kind_of?(Minitest::CompositeReporter) + # Replace progress reporter for colors. - reporter.reporters.delete_if { |reporter| reporter.kind_of?(SummaryReporter) || reporter.kind_of?(ProgressReporter) } - reporter << SuppressedSummaryReporter.new(options[:io], options) - reporter << ::Rails::TestUnitReporter.new(options[:io], options) + if minitest_reporter.reporters.reject! { |reporter| reporter.kind_of?(SummaryReporter) } != nil + minitest_reporter << SuppressedSummaryReporter.new(options[:io], options) + end + if minitest_reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) } != nil + minitest_reporter << ::Rails::TestUnitReporter.new(options[:io], options) + end end # Backwardscompatibility with Rails 5.0 generated plugin test scripts -- cgit v1.2.3