class Minitest::Failed::FileReporter
Public Instance Methods
report()
click to toggle source
Calls superclass method
# File lib/minitest/failed/file_reporter.rb, line 5 def report super failing_results = results.reject(&:skipped?) if failing_results.any? replay_commands = failing_results.map { |result| display_replay_command(result) } end IO.write_to_file(replay_commands || []) end
Private Instance Methods
backtrace(backtrace)
click to toggle source
# File lib/minitest/failed/file_reporter.rb, line 32 def backtrace(backtrace) backtrace = filter_backtrace(backtrace).map {|line| location(line, true) } return if backtrace.empty? backtrace.join("\n").gsub(/^(\s+)/, "\\1# ") end
display_replay_command(result)
click to toggle source
# File lib/minitest/failed/file_reporter.rb, line 18 def display_replay_command(result) location = find_test_file(result) return if location.empty? %(rake TEST=#{location} TESTOPTS="--name=#{result.name}") end
filter_backtrace(backtrace)
click to toggle source
# File lib/minitest/failed/file_reporter.rb, line 47 def filter_backtrace(backtrace) Minitest.backtrace_filter.filter(backtrace) end
find_test_file(result)
click to toggle source
# File lib/minitest/failed/file_reporter.rb, line 25 def find_test_file(result) filter_backtrace(result.failure.backtrace) .find { |line| line.match(%r((test|spec)/.*?_(test|spec).rb)) } .to_s .gsub(/:\d+.*?$/, '') end
location(location, include_line_number = false)
click to toggle source
# File lib/minitest/failed/file_reporter.rb, line 38 def location(location, include_line_number = false) regex = include_line_number ? /^([^:]+:\d+)/ : /^([^:]+)/ location = File.expand_path(location[regex, 1]) return location unless location.start_with?(Dir.pwd) location.gsub(%r[^#{Regexp.escape(Dir.pwd)}/], '') end