Class: Minitest::Reporters::OrderedSpecReporter

Inherits:
BaseReporter
  • Object
show all
Includes:
ANSI::Code, RelativePosition
Defined in:
lib/minitest/reporters/ordered_spec_reporter.rb

Overview

inherit from BaseReporter, not SpecReporter, in case the latter is updated

Constant Summary collapse

@@default_options =
{
  indentation: 0,
  spaces: 2,
  justification: TEST_SIZE + TEST_PADDING, # match output of SpecReporter
  truncate: false,
  loose: false,
  color: {
    suite: :yellow,
    test: :cyan,
    match: {},
  },
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OrderedSpecReporter

Returns a new instance of OrderedSpecReporter.



24
25
26
# File 'lib/minitest/reporters/ordered_spec_reporter.rb', line 24

def initialize options = {}
  super(@@default_options.merge(options))
end

Instance Method Details

#reportObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/minitest/reporters/ordered_spec_reporter.rb', line 34

def report
  super

  tree = {}

  self.tests.each do |test|
    branch = tree

    test.klass.split(/(?<!:)::/).each do |klass|
      branch = (branch[klass] ||= {})
    end

    (branch[:tests] ||= []) << test
  end

  tree.sort.to_h.each { |k, v| print_suite(k, v) }

  puts unless options[:loose] # already printed by last suite if true
  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

#startObject



28
29
30
31
32
# File 'lib/minitest/reporters/ordered_spec_reporter.rb', line 28

def start
  super
  puts('Started with run options %s' % options[:args])
  puts
end