Class: Chutney::SameTagForAllScenarios
- Inherits:
-
Linter
- Object
- Linter
- Chutney::SameTagForAllScenarios
show all
- Defined in:
- lib/chutney/linter/same_tag_for_all_scenarios.rb
Overview
service class to lint for using same tag on all scenarios
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?
Instance Method Details
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/chutney/linter/same_tag_for_all_scenarios.rb', line 55
def example_tags(scenario)
result = nil
return result unless scenario.is_a?(CukeModeler::Outline) && scenario.examples
scenario.examples.each do |example|
return nil unless example.tags
tags = tags_for(example)
result = tags if result.nil?
result &= tags
end
result
end
|
#lint ⇒ Object
8
9
10
11
|
# File 'lib/chutney/linter/same_tag_for_all_scenarios.rb', line 8
def lint
lint_scenarios if feature&.scenarios
lint_examples if feature&.scenarios
end
|
#lint_examples ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/chutney/linter/same_tag_for_all_scenarios.rb', line 29
def lint_examples
scenarios do |_feature, scenario|
tags = example_tags(scenario)
next if tags.nil? || tags.empty?
next unless scenario.is_a? CukeModeler::Outline
next unless scenario.examples.length > 1
tags.each do |tag|
next if tag == 'skip'
add_issue(I18n.t('linters.same_tag_for_all_scenarios.example_level',
tag: tag), feature, scenario)
end
end
end
|
#lint_scenarios ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/chutney/linter/same_tag_for_all_scenarios.rb', line 13
def lint_scenarios
tags = scenario_tags
return if tags.nil? || tags.empty?
return unless feature.tests.length > 1
tags.each do |tag|
next if tag == 'skip'
add_issue(
I18n.t('linters.same_tag_for_all_scenarios.feature_level',
tag: tag),
feature
)
end
end
|
45
46
47
48
49
50
51
52
53
|
# File 'lib/chutney/linter/same_tag_for_all_scenarios.rb', line 45
def scenario_tags
result = nil
scenarios do |_feature, scenario|
tags = tags_for(scenario)
result ||= tags
result &= tags
end
result
end
|