Class: Chutney::InvalidStepFlow
- Defined in:
- lib/chutney/linter/invalid_step_flow.rb
Overview
service class to lint for invalid step flow
Instance Attribute Summary
Attributes inherited from Linter
#configuration, #filename, #issues
Instance Method Summary collapse
- #given_after_non_given(feature, scenario, steps) ⇒ Object
- #last_step_is_an_action(feature, scenario, steps) ⇒ Object
- #lint ⇒ Object
- #verification_before_action(feature, scenario, steps) ⇒ Object
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
#given_after_non_given(feature, scenario, steps) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/chutney/linter/invalid_step_flow.rb', line 23 def given_after_non_given(feature, scenario, steps) last_step = steps.first steps.each do |step| if given_word?(step.keyword) && !given_word?(last_step.keyword) add_issue(I18n.t('linters.invalid_step_flow.given_order'), feature, scenario, step) end last_step = step end end |
#last_step_is_an_action(feature, scenario, steps) ⇒ Object
17 18 19 20 21 |
# File 'lib/chutney/linter/invalid_step_flow.rb', line 17 def last_step_is_an_action(feature, scenario, steps) return unless when_word?(steps.last.keyword) add_issue(I18n.t('linters.invalid_step_flow.action_last'), feature, scenario, steps.last) end |
#lint ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/chutney/linter/invalid_step_flow.rb', line 6 def lint filled_scenarios do |feature, scenario| steps = scenario.steps.select { |step| !and_word?(step.keyword) && !but_word?(step.keyword) } next if steps.empty? last_step_is_an_action(feature, scenario, steps) given_after_non_given(feature, scenario, steps) verification_before_action(feature, scenario, steps) end end |
#verification_before_action(feature, scenario, steps) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/chutney/linter/invalid_step_flow.rb', line 33 def verification_before_action(feature, scenario, steps) steps.each do |step| break if when_word?(step.keyword) add_issue(I18n.t('linters.invalid_step_flow.missing_action'), feature, scenario) if then_word?(step.keyword) end end |