Class: GherkinLint::FileNameDiffersFeatureName
- 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
Instance Method Summary collapse
Methods inherited from Linter
#add_error, #add_warning, #backgrounds, descendants, #elements, #features, #files, #filled_scenarios, #filter_tag, #initialize, #line, #lint_files, #name, #reference, #render_step, #render_step_argument, #scenarios, #steps, #suppress, #suppress_tags, #tag?
Constructor Details
This class inherits a constructor from GherkinLint::Linter
Instance Method Details
#ignore_whitespaces(value) ⇒ Object
21 22 23 |
# File 'lib/gherkin_lint/linter/file_name_differs_feature_name.rb', line 21 def ignore_whitespaces(value) value.delete('-').delete('_').delete(' ') end |
#lint ⇒ Object
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 ignore_whitespaces(feature[:name]).casecmp(ignore_whitespaces(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 |