Class: CukeLinter::ElementWithCommonTagsLinter
- Defined in:
- lib/cuke_linter/linters/element_with_common_tags_linter.rb
Overview
A linter that detects Gherkin elements that have the same tag on all of their taggable child elements
Instance Attribute Summary
Attributes inherited from Linter
Instance Method Summary collapse
-
#message ⇒ Object
The message used to describe the problem that has been found.
-
#rule(model) ⇒ Object
The rule used to determine if a model has a problem.
Methods inherited from Linter
Constructor Details
This class inherits a constructor from CukeLinter::Linter
Instance Method Details
#message ⇒ Object
The message used to describe the problem that has been found
22 23 24 25 26 27 28 29 30 |
# File 'lib/cuke_linter/linters/element_with_common_tags_linter.rb', line 22 def class_name = @linted_model_class.name.split('::').last if class_name == 'Feature' "All tests in Feature have tag '#{@common_tag}'. Move tag to #{class_name} level." else "All Examples in Outline have tag '#{@common_tag}'. Move tag to #{class_name} level." end end |
#rule(model) ⇒ Object
The rule used to determine if a model has a problem
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cuke_linter/linters/element_with_common_tags_linter.rb', line 7 def rule(model) return false unless relevant_model?(model) @linted_model_class = model.class child_models = model.send(child_accessor_method(model)) || [] tag_sets = child_models.collect { |child_model| child_model. || [] } tag_name_sets = tag_sets.collect { || .map(&:name) } return false if tag_name_sets.count < 2 !find_common_tag(tag_name_sets).nil? end |