Class: GherkinLint::BackgroundDoesMoreThanSetup

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

Overview

service class to lint for background that does more than setup

Instance Attribute Summary

Attributes inherited from Linter

#issues

Instance Method Summary collapse

Methods inherited from Linter

#add_error, #add_warning, #backgrounds, descendants, #elements, #features, #files, #filled_scenarios, #filter_tag, #initialize, #line, #lint_files, #name, #reference, #render_step, #render_step_argument, #scenarios, #steps, #suppress, #suppress_tags, #tag?

Constructor Details

This class inherits a constructor from GherkinLint::Linter

Instance Method Details

#lintObject



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

def lint
  backgrounds do |file, feature, background|
    next unless background.key? :steps
    invalid_steps = background[:steps].select { |step| step[:keyword] == 'When ' || step[:keyword] == 'Then ' }
    next if invalid_steps.empty?
    references = [reference(file, feature, background, invalid_steps[0])]
    add_error(references, 'Just Given Steps allowed')
  end
end