Sha256: 11f84e8b51c849bc7170207a2e4996fdbecf4da9818e3d721a878c29be40d177

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 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 unless feature['name'].downcase != expected_feature_name.downcase
        references = [reference(file, feature)]
        add_issue(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.1.1 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.1.0 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.0.14 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.0.13 lib/gherkin_lint/linter/file_name_differs_feature_name.rb
gherkin_lint-0.0.12 lib/gherkin_lint/linter/file_name_differs_feature_name.rb