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