Sha256: 45c5bb4b7c72d8509811f58350a0e15b4fc9d79debc47e7f9b598ded8cdf9756
Contents?: true
Size: 1.45 KB
Versions: 10
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module Chutney # Utility module to assist in locating the source of parts of a gherkin specification module Locator module_function def locate(feature, scenario, step) if step locate_step(step) elsif scenario locate_scenario(scenario) elsif feature locate_feature(feature) else feature end end 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 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 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 end end
Version data entries
10 entries across 10 versions & 1 rubygems