class Minitest::Reporters::SpecReporter

Turn-like reporter that reads like a spec.

Based upon TwP’s turn (MIT License) and paydro’s monkey-patch.

@see github.com/TwP/turn turn @see gist.github.com/356945 paydro’s monkey-patch

Public Class Methods

new(options = {}) click to toggle source

The constructor takes an ‘options` hash @param options [Hash] @option options print_failure_summary [Boolean] wether to print the errors at the bottom of the

report or inline as they happen.
Calls superclass method Minitest::Reporters::BaseReporter::new
# File lib/minitest/reporters/spec_reporter.rb, line 18
def initialize(options = {})
  super
  @print_failure_summary = options[:print_failure_summary]
end

Public Instance Methods

record(test) click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 50
def record(test)
  super
  record_print_status(test)
  record_print_failures_if_any(test) unless @print_failure_summary
end
report() click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 29
def report
  super
  if @print_failure_summary
    failed_test_groups = tests.reject { |test| test.failures.empty? }
                              .sort_by { |test| [test_class(test).to_s, test.name] }
                              .group_by { |test| test_class(test).to_s }
    unless failed_test_groups.empty?
      print(red('Failures and errors:'))

      failed_test_groups.each { |name, tests| print_failure(name, tests) }
    end
  end

  puts('Finished in %.5fs' % total_time)
  print('%d tests, %d assertions, ' % [count, assertions])
  color = failures.zero? && errors.zero? ? :green : :red
  print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
  print(yellow { '%d skips' } % skips)
  puts
end
start() click to toggle source
Calls superclass method
# File lib/minitest/reporters/spec_reporter.rb, line 23
def start
  super
  puts('Started with run options %s' % options[:args])
  puts
end

Protected Instance Methods

after_suite(_suite) click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 62
def after_suite(_suite)
  puts
end
before_suite(suite) click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 58
def before_suite(suite)
  puts suite
end
print_failure(name, tests) click to toggle source
record_print_failures_if_any(test) click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 76
def record_print_failures_if_any(test)
  if !test.skipped? && test.failure
    print_info(test.failure, test.error?)
    puts
  end
end
record_print_status(test) click to toggle source
# File lib/minitest/reporters/spec_reporter.rb, line 83
def record_print_status(test)
  test_name = test.name.gsub(/^test_: /, 'test:')
  print pad_test(test_name)
  print_colored_status(test)
  print(" (%.2fs)" % test.time) unless test.time.nil?
  puts
end