Class: GherkinLint::AvoidOutlineForSingleExample

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

Overview

service class to lint for avoiding outline for single example

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
15
16
17
# File 'lib/gherkin_lint/linter/avoid_outline_for_single_example.rb', line 6

def lint
  scenarios do |file, feature, scenario|
    next unless scenario[:type] == :ScenarioOutline

    next unless scenario.key? :examples
    next if scenario[:examples].length > 1
    next if scenario[:examples].first[:tableBody].length > 1

    references = [reference(file, feature, scenario)]
    add_error(references, 'Better write a scenario')
  end
end