Class: Minitest::Sprint::SprintReporter

Inherits:
AbstractReporter
  • Object
show all
Defined in:
lib/minitest/sprint.rb

Overview

An extra minitest reporter to output how to rerun failures in various styles.

Direct Known Subclasses

RakeReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style = :regexp) ⇒ SprintReporter

:nodoc:



34
35
36
37
# File 'lib/minitest/sprint.rb', line 34

def initialize style = :regexp # :nodoc:
  self.results = []
  self.style = style
end

Instance Attribute Details

#resultsObject

:nodoc:



32
33
34
# File 'lib/minitest/sprint.rb', line 32

def results
  @results
end

#styleObject

The style to report, either lines or regexp. Defaults to lines.



31
32
33
# File 'lib/minitest/sprint.rb', line 31

def style
  @style
end

Instance Method Details

:nodoc:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/minitest/sprint.rb', line 53

def print_list # :nodoc:
  case style
  when :regexp
    results.each do |result|
      puts "  minitest -n #{result.class_name}##{result.name}"
    end
  when :lines
    files = Hash.new { |h,k| h[k] = [] }
    results.each do |result|
      path, line = result.source_location
      path = path.delete_prefix "#{Dir.pwd}/"
      files[path] << line
    end

    files.sort.each do |path, lines|
      puts "  minitest %s:%s" % [path, lines.sort.join(",")]
    end
  else
    raise "unsupported style: %p" % [style]
  end
end

#record(result) ⇒ Object

:nodoc:



39
40
41
# File 'lib/minitest/sprint.rb', line 39

def record result # :nodoc:
  results << result unless result.passed? or result.skipped?
end

#reportObject

:nodoc:



43
44
45
46
47
48
49
50
51
# File 'lib/minitest/sprint.rb', line 43

def report # :nodoc:
  return if results.empty?

  puts
  puts "Happy Happy Sprint List:"
  puts
  print_list
  puts
end