Module: Minitest

Defined in:
lib/minitest/silence_plugin.rb,
lib/minitest/silence/version.rb,
lib/minitest/silence/boxed_output_reporter.rb,
lib/minitest/silence/fail_on_output_reporter.rb

Defined Under Namespace

Modules: Silence

Class Method Summary collapse

Class Method Details

.plugin_silence_init(options) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/minitest/silence_plugin.rb', line 65

def plugin_silence_init(options)
  if options[:enable_silence] || ENV["CI"]
    Minitest::Result.prepend(Minitest::Silence::ResultOutputPatch)
    Minitest.singleton_class.prepend(Minitest::Silence::RunOneMethodPatch)

    if options[:fail_on_output]
      # We have to make sure this reporter runs as the first reporter, so it can still adjust
      # the result and other reporters will take the change into account.
      reporter.reporters.unshift(Minitest::Silence::FailOnOutputReporter.new(options[:io], options))
    elsif options[:verbose]
      reporter << Minitest::Silence::BoxedOutputReporter.new(options[:io], options)
    end
  end
end

.plugin_silence_options(opts, options) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/minitest/silence_plugin.rb', line 56

def plugin_silence_options(opts, options)
  opts.on('--enable-silence', "Rebind standard IO") do
    options[:enable_silence] = true
  end
  opts.on('--fail-on-output', "Fail a test when it writes to STDOUT or STDERR") do
    options[:fail_on_output] = true
  end
end