1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/minitest/rails_plugin_test.rb
2018-02-19 11:23:47 +05:30

42 lines
1.3 KiB
Ruby

# 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
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
with_reporter Minitest::CompositeReporter.new do |reporter|
Minitest.plugin_rails_init({})
assert_empty reporter.reporters
end
end
private
def with_reporter(reporter)
old_reporter, Minitest.reporter = Minitest.reporter, reporter
yield reporter
ensure
Minitest.reporter = old_reporter
end
end