Class: GherkinLint::InvalidStepFlow
- Inherits:
-
Linter
- Object
- Linter
- GherkinLint::InvalidStepFlow
show all
- Defined in:
- lib/gherkin_lint/linter/invalid_step_flow.rb
Overview
service class to lint for invalid step flow
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?
Instance Method Details
#given_after_non_given(file, feature, scenario, steps) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/gherkin_lint/linter/invalid_step_flow.rb', line 20
def given_after_non_given(file, feature, scenario, steps)
last_step = steps.first
steps.each do |step|
references = [reference(file, feature, scenario, step)]
description = 'Given after Action or Verification'
add_error(references, description) if step['keyword'] == 'Given ' && last_step['keyword'] != 'Given '
last_step = step
end
end
|
#last_step_is_an_action(file, feature, scenario, steps) ⇒ Object
15
16
17
18
|
# File 'lib/gherkin_lint/linter/invalid_step_flow.rb', line 15
def last_step_is_an_action(file, feature, scenario, steps)
references = [reference(file, feature, scenario, steps.last)]
add_error(references, 'Last step is an action') if steps.last['keyword'] == 'When '
end
|
#lint ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/gherkin_lint/linter/invalid_step_flow.rb', line 6
def lint
filled_scenarios do |file, feature, scenario|
steps = scenario['steps'].select { |step| step['keyword'] != 'And ' && step['keyword'] != 'But ' }
last_step_is_an_action(file, feature, scenario, steps)
given_after_non_given(file, feature, scenario, steps)
verification_before_action(file, feature, scenario, steps)
end
end
|
#verification_before_action(file, feature, scenario, steps) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/gherkin_lint/linter/invalid_step_flow.rb', line 30
def verification_before_action(file, feature, scenario, steps)
steps.each do |step|
break if step['keyword'] == 'When '
references = [reference(file, feature, scenario, step)]
add_error(references, 'Missing Action') if step['keyword'] == 'Then '
end
end
|