Class: Greener::Checker::Style::FeatureName
- Inherits:
-
Base
- Object
- Base
- Greener::Checker::Style::FeatureName
show all
- Defined in:
- lib/greener/checker/style/feature_name.rb
Overview
Ensure .feature filename matches feature name in the Gherkin e.g. filename_of_feature.feature => “Feature: filename of feature”
Constant Summary
collapse
- MSG =
"feature title does not match file name"
Instance Attribute Summary
Attributes inherited from Base
#violations
Instance Method Summary
collapse
Methods inherited from Base
#feature, #initialize, #log_violation, #message, #raw_line
Instance Method Details
#allow_punctuation? ⇒ Boolean
38
39
40
|
# File 'lib/greener/checker/style/feature_name.rb', line 38
def allow_punctuation?
@config["AllowPunctuation"]
end
|
#enforce_title_case? ⇒ Boolean
42
43
44
|
# File 'lib/greener/checker/style/feature_name.rb', line 42
def enforce_title_case?
@config["EnforceTitleCase"]
end
|
#run ⇒ Object
12
13
14
15
16
17
|
# File 'lib/greener/checker/style/feature_name.rb', line 12
def run
return unless @config["Enabled"]
run_against_filename
run_against_titlecase
end
|
#run_against_filename ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/greener/checker/style/feature_name.rb', line 19
def run_against_filename
filename_without_extension = File.basename(@path, ".*")
expected = feature[:name]
expected = expected.gsub(/[^0-9a-z ]/i, "") if allow_punctuation?
expected = expected.downcase.gsub(" ", "_")
return if filename_without_extension == expected
log_violation(feature[:location][:line], feature[:location][:column])
end
|
#run_against_titlecase ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/greener/checker/style/feature_name.rb', line 28
def run_against_titlecase
return unless enforce_title_case?
return if feature[:name].titlecase == feature[:name]
log_violation(
feature[:location][:line],
feature[:location][:column],
"feature title is not title case. expected: #{feature[:name].titlecase}"
)
end
|