Class: GherkinLint::AvoidScripting

Inherits:
Linter
  • Object
show all
Defined in:
lib/gherkin_lint/linter/avoid_scripting.rb

Overview

service class to lint for avoid scripting

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?

Constructor Details

This class inherits a constructor from GherkinLint::Linter

Instance Method Details

#filter_when_steps(steps) ⇒ Object



16
17
18
19
20
# File 'lib/gherkin_lint/linter/avoid_scripting.rb', line 16

def filter_when_steps(steps)
  steps = steps.drop_while { |step| step['keyword'] != 'When ' }
  steps = steps.reverse.drop_while { |step| step['keyword'] != 'Then ' }.reverse
  steps.select { |step| step['keyword'] != 'Then ' }
end

#lintObject



6
7
8
9
10
11
12
13
14
# File 'lib/gherkin_lint/linter/avoid_scripting.rb', line 6

def lint
  filled_scenarios do |file, feature, scenario|
    steps = filter_when_steps scenario['steps']

    next if steps.length <= 1
    references = [reference(file, feature, scenario)]
    add_error(references, 'Multiple Actions')
  end
end