module Minitest::Line
def describes_with_lines(target_file)
def describes_with_lines(target_file) runnables.map do |runnable| next unless caller = runnable.instance_variable_defined?(:@minitest_line_caller) && runnable.instance_variable_get(:@minitest_line_caller) next unless line = caller.detect { |l| l.include?(target_file) } ["/#{Regexp.escape(runnable.name)}/", line[/:(\d+):in/, 1].to_i] end.compact end
def methods_with_lines(target_file)
def methods_with_lines(target_file) runnables.flat_map do |runnable| rname = runnable.name runnable.runnable_methods.map do |name| file, line = runnable.instance_method(name).source_location next unless file == target_file test_name = (rname ? "#{rname}##{name}" : name) [test_name, line] end end.uniq.compact end
def runnables
def runnables Minitest::Runnable.runnables end
def tests_with_lines
def tests_with_lines target_file = $0 methods_with_lines(target_file).concat describes_with_lines(target_file) end