Class: Minitest::LineReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/maxitest/vendor/line.rb

Instance Method Summary collapse

Constructor Details

#initializeLineReporter



68
69
70
71
# File 'lib/maxitest/vendor/line.rb', line 68

def initialize(*)
  super
  @failures = []
end

Instance Method Details

#record(result) ⇒ Object



73
74
75
76
77
# File 'lib/maxitest/vendor/line.rb', line 73

def record(result)
  if !result.skipped? && !result.passed?
    @failures << result
  end
end

#reportObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/maxitest/vendor/line.rb', line 79

def report
  return unless @failures.any?
  io.puts
  io.puts "Focus on failing tests:"
  pwd = Pathname.new(Dir.pwd)
  @failures.each do |res|
    meth = res.method(res.name)
    file, line = meth.source_location
    if file
      file = Pathname.new(file)
      file = file.relative_path_from(pwd) if file.absolute?
      output = "ruby #{file} -l #{line}"
      output = "\e[31m#{output}\e[0m" if $stdout.tty?
      io.puts output
    end
  end
end