Module: Minitest

Defined in:
lib/minitest/nicetest_plugin.rb,
lib/minitest/reporters_plugin.rb,
lib/minitest/superdiff_plugin.rb

Class Method Summary collapse

Class Method Details

.plugin_nicetest_init(_options) ⇒ Object



13
14
15
# File 'lib/minitest/nicetest_plugin.rb', line 13

def plugin_nicetest_init(_options)
  Minitest.backtrace_filter = Nicetest::BacktraceFilter.new
end

.plugin_nicetest_options(opts, options) ⇒ Object



8
9
10
11
# File 'lib/minitest/nicetest_plugin.rb', line 8

def plugin_nicetest_options(opts, options)
  opts.banner = ::Nicetest::Cli::BANNER
  Nicetest::NicetestPlugin::ValidateMinitestFocus.apply!
end

.plugin_reporters_init(options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/minitest/reporters_plugin.rb', line 23

def plugin_reporters_init(options)
  return if options[:reporters].nil? || options[:reporters].empty?

  require "minitest/reporters"

  reporters = options[:reporters].map do |reporter|
    Nicetest::ReportersPlugin::MAPPING.fetch(reporter).call(options)
  end.compact

  Minitest::Reporters.use!(reporters, ENV, Minitest.backtrace_filter) unless reporters.empty?
end

.plugin_reporters_options(opts, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/minitest/reporters_plugin.rb', line 5

def plugin_reporters_options(opts, options)
  options[:reporters] = ["progress"]

  vals = Nicetest::ReportersPlugin::MAPPING.keys.join(",")
  description = <<~DESC.strip
    The reporters to use for test output as comma-seperated list.
  DESC

  opts.on("-r", "--reporter #{vals}", Array, description) do |reporters|
    reporters = options[:reporters] + reporters if reporters == ["junit"]

    is_subset = (reporters - Nicetest::ReportersPlugin::MAPPING.keys).empty?
    raise OptionParser::InvalidArgument, "Invalid reporter: #{reporters.join(", ")}" unless is_subset

    options[:reporters] = reporters
  end
end

.plugin_superdiff_init(options) ⇒ Object



11
12
13
14
15
16
# File 'lib/minitest/superdiff_plugin.rb', line 11

def plugin_superdiff_init(options)
  return if options[:no_superdiff]

  require "super_diff"
  Minitest::Assertions.prepend(Nicetest::SuperdiffPlugin)
end

.plugin_superdiff_options(opts, options) ⇒ Object



5
6
7
8
9
# File 'lib/minitest/superdiff_plugin.rb', line 5

def plugin_superdiff_options(opts, options)
  opts.on("--no-superdiff", "Disable superdiff") do
    options[:no_superdiff] = true
  end
end