module Minitest::Rerun
Constants
- ASCII_COLORS
- VERSION
Public Class Methods
rerun_command(msg)
click to toggle source
# File lib/minitest/rerun.rb, line 7 def rerun_command(msg) info = msg.to_s.split("\n")[1] location_part = info[/ \[((.*?):\d+)\]:/] location = $1 file = $2 name = if location_part info.sub(location_part, "") else info.sub(/:$/, "") end # in minitest 5 we know file/line even for errors if !location && msg.respond_to?(:name) method = msg.method(msg.name) file, line = method.source_location location = "#{file}:#{line}" end file = test_file(file) line = colorize(:red, "ruby #{file || "unknown"} -n '#{name.gsub(%{'}, %{'"'"'})}' ") line << colorize(:cyan, "# #{relativize(location)}") if location line end
Private Class Methods
colorize(color, string)
click to toggle source
# File lib/minitest/rerun.rb, line 33 def colorize(color, string) if $stdout.tty? "\e[#{ASCII_COLORS[color]}m#{string}\e[0m" else string end end
relativize(location)
click to toggle source
# File lib/minitest/rerun.rb, line 41 def relativize(location) location.sub(/^\.\//, "").sub("#{Dir.pwd}/", "") end
test_file(location)
click to toggle source
# File lib/minitest/rerun.rb, line 45 def test_file(location) tests_run = $0.split(" ").select { |f| File.exist?(f) } location = tests_run.first if tests_run.size == 1 relativize(location) if location end