class CucumberLint::ScenarioOutlineLinter

A linter for a series of steps in a scenario outline (as parsed by Gherkin)

Public Class Methods

new(steps:, config:, linted_file: super config: config, linted_file: linted_file) click to toggle source
# File lib/cucumber_lint/linter/scenario_outline_linter.rb, line 7
def initialize steps:, config:, linted_file:
  super config: config, linted_file: linted_file

  @steps = steps
  @header_style = @config.consistent_table_headers.enforced_style.to_sym
end

Public Instance Methods

lint() click to toggle source
# File lib/cucumber_lint/linter/scenario_outline_linter.rb, line 15
def lint
  @steps.each do |step|
    step.name.scan(/<.+?>/).each do |placeholder|
      inconsistent_placeholder step.line, placeholder if bad_placeholder? placeholder
    end
  end
end

Private Instance Methods

bad_placeholder?(str) click to toggle source
# File lib/cucumber_lint/linter/scenario_outline_linter.rb, line 27
def bad_placeholder? str
  str != str.public_send(@header_style)
end
inconsistent_placeholder(line_number, str) click to toggle source
# File lib/cucumber_lint/linter/scenario_outline_linter.rb, line 32
def inconsistent_placeholder line_number, str
  return unless @config.consistent_table_headers.enabled

  if @config.fix
    add_fix line_number, -> (line) { line.sub(str, str.public_send(@header_style)) }
  else
    add_error "#{line_number}: #{@header_style} \"#{str}\""
  end
end