aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/minitest/rails_plugin_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/minitest/rails_plugin_test.rb')
-rw-r--r--railties/test/minitest/rails_plugin_test.rb42
1 files changed, 23 insertions, 19 deletions
diff --git a/railties/test/minitest/rails_plugin_test.rb b/railties/test/minitest/rails_plugin_test.rb
index 423e74fc66..1620bc312f 100644
--- a/railties/test/minitest/rails_plugin_test.rb
+++ b/railties/test/minitest/rails_plugin_test.rb
@@ -9,30 +9,34 @@ class Minitest::RailsPluginTest < ActiveSupport::TestCase
end
test "default reporters are replaced" do
- reporter = Minitest::CompositeReporter.new
- reporter << Minitest::SummaryReporter.new(@output, @options)
- reporter << Minitest::ProgressReporter.new(@output, @options)
- reporter << Minitest::Reporter.new(@output, @options)
-
- Minitest::plugin_rails_replace_reporters(reporter, {})
-
- assert_equal 3, reporter.reporters.count
- assert reporter.reporters.any? { |candidate| candidate.kind_of?(Minitest::SuppressedSummaryReporter) }
- assert reporter.reporters.any? { |candidate| candidate.kind_of?(::Rails::TestUnitReporter) }
- assert reporter.reporters.any? { |candidate| candidate.kind_of?(Minitest::Reporter) }
+ with_reporter Minitest::CompositeReporter.new do |reporter|
+ reporter << Minitest::SummaryReporter.new(@output, @options)
+ reporter << Minitest::ProgressReporter.new(@output, @options)
+ reporter << Minitest::Reporter.new(@output, @options)
+
+ Minitest.plugin_rails_init({})
+
+ assert_equal 3, reporter.reporters.count
+ assert reporter.reporters.any? { |candidate| candidate.kind_of?(Minitest::SuppressedSummaryReporter) }
+ assert reporter.reporters.any? { |candidate| candidate.kind_of?(::Rails::TestUnitReporter) }
+ assert reporter.reporters.any? { |candidate| candidate.kind_of?(Minitest::Reporter) }
+ end
end
test "no custom reporters are added if nothing to replace" do
- reporter = Minitest::CompositeReporter.new
+ with_reporter Minitest::CompositeReporter.new do |reporter|
+ Minitest.plugin_rails_init({})
- Minitest::plugin_rails_replace_reporters(reporter, {})
-
- assert_equal 0, reporter.reporters.count
+ assert_empty reporter.reporters
+ end
end
- test "handle the case when reporter is not CompositeReporter" do
- reporter = Minitest::Reporter.new
+ private
+ def with_reporter(reporter)
+ old_reporter, Minitest.reporter = Minitest.reporter, reporter
- Minitest::plugin_rails_replace_reporters(reporter, {})
- end
+ yield reporter
+ ensure
+ Minitest.reporter = old_reporter
+ end
end