Module: Chutney::Locator
- Defined in:
- lib/chutney/locator.rb
Overview
Utility module to assist in locating the source of parts of a gherkin specification
Class Method Summary collapse
- .locate(feature, scenario, step) ⇒ Object
- .locate_feature(feature) ⇒ Object
- .locate_scenario(scenario) ⇒ Object
- .locate_step(step) ⇒ Object
Class Method Details
.locate(feature, scenario, step) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chutney/locator.rb', line 8 def locate(feature, scenario, step) if step locate_step(step) elsif scenario locate_scenario(scenario) elsif feature locate_feature(feature) else feature end end |
.locate_feature(feature) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/chutney/locator.rb', line 39 def locate_feature(feature) return feature.parsing_data.location.to_h if feature.parsing_data.respond_to?(:location) return feature.parsing_data[:location] if feature.parsing_data.is_a?(Hash) raise UnsupportedCucumberError, 'This version of cucumber is unsupported (feature location)' end |
.locate_scenario(scenario) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chutney/locator.rb', line 27 def locate_scenario(scenario) parsing_data = scenario.parsing_data if parsing_data.is_a?(Hash) parsing_data.dig(:scenario, :location) || parsing_data.dig(:background, :location) elsif parsing_data.respond_to?(:scenario) (parsing_data.scenario || parsing_data.background).location.to_h else raise UnsupportedCucumberError, 'This version of cucumber is unsupported (scenario location)' end end |
.locate_step(step) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/chutney/locator.rb', line 20 def locate_step(step) return step.parsing_data.location.to_h if step.parsing_data.respond_to?(:location) return step.parsing_data[:location] if step.parsing_data.is_a?(Hash) raise UnsupportedCucumberError, 'This version of cucumber is unsupported (step location)' end |