Class: GherkinLint::UniqueScenarioNames
- Defined in:
- lib/gherkin_lint/linter/unique_scenario_names.rb
Overview
service class to lint for unique scenario names
Instance Attribute Summary
Attributes inherited from Linter
Instance Method Summary collapse
Methods inherited from Linter
#add_error, #add_warning, #backgrounds, descendants, #elements, #features, #files, #filled_scenarios, #filter_tag, #initialize, #line, #lint_files, #name, #reference, #render_step, #render_step_argument, #scenarios, #steps, #suppress, #suppress_tags, #tag?
Constructor Details
This class inherits a constructor from GherkinLint::Linter
Instance Method Details
#lint ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gherkin_lint/linter/unique_scenario_names.rb', line 6 def lint references_by_name = Hash.new [] scenarios do |file, feature, scenario| next unless scenario.key? :name scenario_name = "#{feature[:name]}.#{scenario[:name]}" references_by_name[scenario_name] = references_by_name[scenario_name] + [reference(file, feature, scenario)] end references_by_name.each do |name, references| next if references.length <= 1 add_error(references, "'#{name}' used #{references.length} times") end end |