Sha256: 8ccaccaab5b0a5b887161834636a755dfa3f4b9002953e1ef9d72a48422267bf

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 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

5 entries across 5 versions & 1 rubygems

Version Path
gherkin_lint-0.4.4 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.4.3 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.4.2 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.4.1 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.4.0 lib/gherkin_lint/linter/file_name_differs_feature_name.rb