Class: GherkinLint::FileNameDiffersFeatureName

Inherits:
Linter
  • Object
show all
Defined in:
lib/gherkin_lint/linter/file_name_differs_feature_name.rb

Overview

service class to lint for file name differs feature name

Instance Attribute Summary

Attributes inherited from Linter

#issues

Instance Method Summary collapse

Methods inherited from Linter

#add_error, #add_warning, #backgrounds, #elements, #features, #files, #filled_scenarios, #filter_tag, #gather_tags, #initialize, #line, #lint_files, #name, #reference, #render_step, #scenarios, #steps, #suppress, #suppress_tags, #tag?

Constructor Details

This class inherits a constructor from GherkinLint::Linter

Instance Method Details

#lintObject



6
7
8
9
10
11
12
13
14
# File 'lib/gherkin_lint/linter/file_name_differs_feature_name.rb', line 6

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

#title_case(value) ⇒ Object



16
17
18
19
# File 'lib/gherkin_lint/linter/file_name_differs_feature_name.rb', line 16

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