2018-02-05 06:04:25 -05:00
|
|
|
# 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
|
2018-02-18 15:35:30 -05:00
|
|
|
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
|
2018-02-05 06:04:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "no custom reporters are added if nothing to replace" do
|
2018-02-18 15:35:30 -05:00
|
|
|
with_reporter Minitest::CompositeReporter.new do |reporter|
|
|
|
|
Minitest.plugin_rails_init({})
|
2018-02-05 06:04:25 -05:00
|
|
|
|
2018-02-18 15:35:30 -05:00
|
|
|
assert_empty reporter.reporters
|
|
|
|
end
|
2018-02-05 06:04:25 -05:00
|
|
|
end
|
|
|
|
|
2018-02-18 15:35:30 -05:00
|
|
|
private
|
|
|
|
def with_reporter(reporter)
|
2018-02-19 00:53:47 -05:00
|
|
|
old_reporter, Minitest.reporter = Minitest.reporter, reporter
|
2018-02-05 06:04:25 -05:00
|
|
|
|
2018-02-18 15:35:30 -05:00
|
|
|
yield reporter
|
|
|
|
ensure
|
|
|
|
Minitest.reporter = old_reporter
|
|
|
|
end
|
2018-02-05 06:04:25 -05:00
|
|
|
end
|