Sha256: d2d5489875fd84f1618da19a59f95649a3495312d14a361ebab84de8c1070c67

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

require 'gherkin_lint/linter'

module GherkinLint
  # service class to lint for file name differs feature name
  class FileNameDiffersFeatureName < Linter
    def lint
      features do |file, feature|
        next unless feature.include? 'name'
        expected_feature_name = title_case file
        next if feature['name'].casecmp(expected_feature_name) == 0
        references = [reference(file, feature)]
        add_error(references, "Feature name should be '#{expected_feature_name}'")
      end
    end

    def title_case(value)
      value = File.basename(value, '.feature')
      value.split('_').collect(&:capitalize).join(' ')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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