Class: Minitest::Sprint::SprintReporter

Inherits:
AbstractReporter 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

Methods inherited from AbstractReporter

#passed?, #prerecord, #start, #synchronize

Constructor Details

#initialize(style = :regexp) ⇒ SprintReporter

:nodoc:



41
42
43
44
# File 'lib/minitest/sprint.rb', line 41

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

Instance Attribute Details

#resultsObject

:nodoc:



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

def results
  @results
end

#styleObject

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



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

def style
  @style
end

Instance Method Details

:nodoc:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/minitest/sprint.rb', line 60

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:



46
47
48
# File 'lib/minitest/sprint.rb', line 46

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

#reportObject

:nodoc:



50
51
52
53
54
55
56
57
58
# File 'lib/minitest/sprint.rb', line 50

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

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