funkwerk/gherkin_lint

View on GitHub
lib/gherkin_lint/linter/missing_example_name.rb

Summary

Maintainability
A
2 hrs
Test Coverage
require 'gherkin_lint/linter'

module GherkinLint
  # service class to lint for missing example names
  class MissingExampleName < Linter
    def lint
      scenarios do |file, feature, scenario|
        next unless scenario.key? :examples
        next unless scenario[:examples].length > 1
        scenario[:examples].each do |example|
          name = example.key?(:name) ? example[:name].strip : ''
          next unless name.empty?
          references = [reference(file, feature, scenario)]
          add_error(references, 'No Example Name')
        end
      end
    end
  end
end