Sha256: 8f6b6238994ba9643a4662a4711f6611c7331608a05b343704bcf5106518c71c
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'gherkin_lint/linter' module GherkinLint # service class to lint for invalid step flow class InvalidStepFlow < Linter 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 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 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gherkin_lint-0.3.1 | lib/gherkin_lint/linter/invalid_step_flow.rb |
gherkin_lint-0.3.0 | lib/gherkin_lint/linter/invalid_step_flow.rb |