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



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

def plugin_silence_init(options)
  unless options[:disable_silence]
    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



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

def plugin_silence_options(opts, options)
  opts.on('--disable-silence', "Do not rebind standard IO") do
    options[:disable_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