Module: Minitest::Rerun

Defined in:
lib/minitest/rerun/version.rb,
lib/minitest/rerun.rb

Defined Under Namespace

Modules: M4, M5

Constant Summary collapse

VERSION =
"0.1.5"
ASCII_COLORS =
{:red => 31, :cyan => 36}

Class Method Summary collapse

Class Method Details

.rerun_command(msg) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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