aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/minitest
diff options
context:
space:
mode:
authorKevin Robatel <kevinrob2@gmail.com>2018-02-05 12:04:25 +0100
committerKevin Robatel <kevin.robatel@qoqa.com>2018-02-15 10:02:26 +0100
commit40a5ba30fb41eba633106509c5b362761b18d497 (patch)
treeb3b82b19cdf8dea29d8da30dc3fabbf09bf35aba /railties/test/minitest
parent4865f6b58965078e314a22fdcefdf57ee56675b1 (diff)
downloadrails-40a5ba30fb41eba633106509c5b362761b18d497.tar.gz
rails-40a5ba30fb41eba633106509c5b362761b18d497.tar.bz2
rails-40a5ba30fb41eba633106509c5b362761b18d497.zip
Add SuppressedSummaryReporter and TestUnitReporter only if necessary
Diffstat (limited to 'railties/test/minitest')
-rw-r--r--railties/test/minitest/rails_plugin_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/minitest/rails_plugin_test.rb b/railties/test/minitest/rails_plugin_test.rb
new file mode 100644
index 0000000000..423e74fc66
--- /dev/null
+++ b/railties/test/minitest/rails_plugin_test.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require "abstract_unit"
+
+class Minitest::RailsPluginTest < ActiveSupport::TestCase
+ setup do
+ @options = Minitest.process_args []
+ @output = StringIO.new("".encode("UTF-8"))
+ 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) }
+ end
+
+ test "no custom reporters are added if nothing to replace" do
+ reporter = Minitest::CompositeReporter.new
+
+ Minitest::plugin_rails_replace_reporters(reporter, {})
+
+ assert_equal 0, reporter.reporters.count
+ end
+
+ test "handle the case when reporter is not CompositeReporter" do
+ reporter = Minitest::Reporter.new
+
+ Minitest::plugin_rails_replace_reporters(reporter, {})
+ end
+end