-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31901 from Kevinrob/patch-1
Use SuppressedSummaryReporter and Rails::TestUnitReporter only if needed
- Loading branch information
Showing
3 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
* Fix minitest rails plugin. The custom reporters are added only if needed. This will fix conflicts with others plugins. *Kevin Robatel* | ||
|
||
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/railties/CHANGELOG.md) for previous changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |