Class: Chutney::AvoidTags

Inherits:
Linter
  • Object
show all
Defined in:
lib/chutney/linter/avoid_tags.rb

Overview

service class to lint for avoiding tags

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

#lintObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chutney/linter/avoid_tags.rb', line 6

def lint
  return if feature.nil?

  feature_tags = tags_for(feature)
  feature_tags_to_avoid_found = feature_tags & tags_to_avoid

  unless feature_tags_to_avoid_found.empty?
    feature_tags_to_avoid_found = feature_tags_to_avoid_found.map { |tag| tag.prepend('@') }
    add_issue(I18n.t('linters.avoid_tags', tags: feature_tags_to_avoid_found.join(', ')), feature)
  end

  scenarios do |_feature, scenario|
    scenario_tags = tags_for(scenario)
    scenario_tags_to_avoid_found = scenario_tags & tags_to_avoid

    unless scenario_tags_to_avoid_found.empty?
      scenario_tags_to_avoid_found = scenario_tags_to_avoid_found.map { |tag| tag.prepend('@') }
      add_issue(I18n.t('linters.avoid_tags', tags: scenario_tags_to_avoid_found.join(', ')), feature, scenario)
    end
  end
end

#tags_to_avoidObject



28
29
30
31
32
33
34
# File 'lib/chutney/linter/avoid_tags.rb', line 28

def tags_to_avoid
  tags_to_avoid = configuration['Tags'] || []

  return [] unless tags_to_avoid.is_a?(Array)

  tags_to_avoid
end