class CukeLinter::BackgroundDoesMoreThanSetupLinter

A linter that detects backgrounds that have non-setup steps

Public Instance Methods

configure(options) click to toggle source

Changes the linting settings on the linter using the provided configuration

# File lib/cuke_linter/linters/background_does_more_than_setup_linter.rb, line 8
def configure(options)
  @when_keywords = options['When']
  @then_keywords = options['Then']
end
message() click to toggle source

The message used to describe the problem that has been found

# File lib/cuke_linter/linters/background_does_more_than_setup_linter.rb, line 21
def message
  'Background has non-setup steps'
end
rule(model) click to toggle source

The rule used to determine if a model has a problem

# File lib/cuke_linter/linters/background_does_more_than_setup_linter.rb, line 14
def rule(model)
  return false unless model.is_a?(CukeModeler::Background)

  model.steps.map(&:keyword).any? { |keyword| when_keywords.include?(keyword) || then_keywords.include?(keyword) }
end

Private Instance Methods

then_keywords() click to toggle source
# File lib/cuke_linter/linters/background_does_more_than_setup_linter.rb, line 31
def then_keywords
  @then_keywords || [DEFAULT_THEN_KEYWORD]
end
when_keywords() click to toggle source
# File lib/cuke_linter/linters/background_does_more_than_setup_linter.rb, line 27
def when_keywords
  @when_keywords || [DEFAULT_WHEN_KEYWORD]
end