Class: Chutney::FileNameDiffersFeatureName

Inherits:
Linter
  • Object
show all
Defined in:
lib/chutney/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

#configuration, #filename, #issues

Instance Method Summary collapse

Methods inherited from Linter

#add_issue, #and_word?, #background, #background_word?, #but_word?, descendants, #dialect, #dialect_word, #elements, #examples_word?, #feature, #feature_word?, #filled_scenarios, #given_word?, #initialize, linter_name, #linter_name, #location, #off_switch?, #render_step, #render_step_argument, #scenario_outline_word?, #scenarios, #steps, #tags_for, #then_word?, #type, #when_word?

Constructor Details

This class inherits a constructor from Chutney::Linter

Instance Method Details

#ignore_whitespaces(value) ⇒ Object



20
21
22
# File 'lib/chutney/linter/file_name_differs_feature_name.rb', line 20

def ignore_whitespaces(value)
  value.delete('-').delete('_').delete(' ')
end

#lintObject



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

def lint
  return unless feature

  expected_feature_name = title_case(filename)
  return if ignore_whitespaces(feature.name).casecmp(ignore_whitespaces(expected_feature_name)) == 0

  add_issue(I18n.t('linters.file_name_differs_feature_name', expected: expected_feature_name), feature)
end

#title_case(value) ⇒ Object



15
16
17
18
# File 'lib/chutney/linter/file_name_differs_feature_name.rb', line 15

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