Class: Chutney::MissingExampleName
- Defined in:
- lib/chutney/linter/missing_example_name.rb
Overview
service class to lint for missing example names
Instance Attribute Summary
Attributes inherited from Linter
#configuration, #filename, #issues
Instance Method Summary collapse
Methods inherited from Linter
#add_issue, #and_word?, #background, #background_word?, #but_word?, descendants, #dialect, #dialect_word, #elements, #examples_word?, #feature, #feature_word?, #filled_scenarios, #given_word?, #initialize, linter_name, #linter_name, #location, #off_switch?, #render_step, #render_step_argument, #scenario_outline_word?, #scenarios, #steps, #tags_for, #then_word?, #type, #when_word?
Constructor Details
This class inherits a constructor from Chutney::Linter
Instance Method Details
#check_example(scenario, example) ⇒ Object
19 20 21 22 23 |
# File 'lib/chutney/linter/missing_example_name.rb', line 19 def check_example(scenario, example) name = example.name.strip duplicate_name_count = scenario.examples.filter { |e| e.name == name }.count add_issue(I18n.t('linters.missing_example_name'), feature, scenario, example) if duplicate_name_count >= 2 end |
#lint ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/chutney/linter/missing_example_name.rb', line 6 def lint scenarios do |_feature, scenario| next unless scenario.is_a? CukeModeler::Outline scenario.examples.each do |example| example_count = scenario.examples&.length || 0 next unless example_count > 1 check_example(scenario, example) end end end |