File: rails_plugin_test.rb

package info (click to toggle)
rails 2%3A6.0.3.7%2Bdfsg-2%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 70,976 kB
  • sloc: ruby: 271,623; javascript: 19,043; yacc: 46; sql: 43; makefile: 28; sh: 18
file content (42 lines) | stat: -rw-r--r-- 1,335 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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