Sha256: 414490d8114a0f1208cfa9fedb0656df8ade5b8fe2b7661da3c417dba695240e

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

require 'gherkin_lint/linter'

module GherkinLint
  # service class to lint for unique scenario names
  class UniqueScenarioNames < Linter
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gherkin_lint-0.3.1 lib/gherkin_lint/linter/unique_scenario_names.rb
gherkin_lint-0.3.0 lib/gherkin_lint/linter/unique_scenario_names.rb