Class: Spec::Runner::SpecParser
- Defined in:
- lib/gems/rspec-1.1.12/lib/spec/runner/spec_parser.rb
Overview
Parses a spec file and finds the nearest example for a given line number.
Instance Attribute Summary collapse
-
#best_match ⇒ Object
readonly
Returns the value of attribute best_match.
Instance Method Summary collapse
-
#initialize(run_options) ⇒ SpecParser
constructor
A new instance of SpecParser.
- #spec_name_for(file, line_number) ⇒ Object
Constructor Details
#initialize(run_options) ⇒ SpecParser
Returns a new instance of SpecParser.
7 8 9 10 |
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/spec_parser.rb', line 7 def initialize() @best_match = {} @run_options = end |
Instance Attribute Details
#best_match ⇒ Object (readonly)
Returns the value of attribute best_match.
5 6 7 |
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/spec_parser.rb', line 5 def best_match @best_match end |
Instance Method Details
#spec_name_for(file, line_number) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/spec_parser.rb', line 12 def spec_name_for(file, line_number) best_match.clear file = File.(file) @run_options.example_groups.each do |example_group| 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 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 |