Parses a spec file and finds the nearest example for a given line number.
# File lib/spec/runner/line_number_query.rb, line 27 def example_line_for(file, line_number) determine_best_match(file, line_number) best_match[:line] end
# File lib/spec/runner/line_number_query.rb, line 12 def spec_name_for(file, line_number) best_match.clear file = File.expand_path(file) determine_best_match(file, line_number) if best_match[:example_group] if best_match[:example] "#{best_match[:example_group].description} #{best_match[:example].description}" else best_match[:example_group].description end else nil end end
# File lib/spec/runner/line_number_query.rb, line 56 def consider_example_for_best_match(example, example_group, file, line_number) example_file, example_line = parse_location(example.location) if is_best_match?(file, line_number, example_file, example_line) best_match.clear best_match[:example_group] = example_group best_match[:example] = example best_match[:line] = example_line end end
# File lib/spec/runner/line_number_query.rb, line 47 def consider_example_group_for_best_match(example_group, file, line_number) example_group_file, example_group_line = parse_location(example_group.location) if is_best_match?(file, line_number, example_group_file, example_group_line) best_match.clear best_match[:example_group] = example_group best_match[:line] = example_group_line end end
# File lib/spec/runner/line_number_query.rb, line 34 def determine_best_match(file, line_number) best_match.clear file = File.expand_path(file) @run_options.example_groups.each do |example_group| next unless example_group.location consider_example_group_for_best_match(example_group, file, line_number) example_group.examples.each do |example| consider_example_for_best_match(example, example_group, file, line_number) end end end
# File lib/spec/runner/line_number_query.rb, line 66 def is_best_match?(file, line_number, example_file, example_line) file == File.expand_path(example_file) && example_line <= line_number && example_line > best_match[:line].to_i end
Generated with the Darkfish Rdoc Generator 2.