Module: GherkinLint::TagConstraint
- Included in:
- RequiredTagsStartsWith
- Defined in:
- lib/gherkin_lint/linter/tag_constraint.rb
Overview
Mixin to lint for tags that have certain string contraints
Instance Method Summary collapse
- #lint ⇒ Object
- #match_pattern?(_tags) ⇒ Boolean
- #matcher(pattern) ⇒ Object
- #tags(element) ⇒ Object
- #validate_input ⇒ Object
Instance Method Details
#lint ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/gherkin_lint/linter/tag_constraint.rb', line 4 def lint scenarios do |file, feature, scenario| next if match_pattern? (feature) next if match_pattern? (scenario) references = [reference(file, feature, scenario)] add_error(references, 'Required Tag not found') end end |
#match_pattern?(_tags) ⇒ Boolean
23 24 25 |
# File 'lib/gherkin_lint/linter/tag_constraint.rb', line 23 def match_pattern?() raise NoMethodError, 'This is an abstraction that must be implemented by the includer' end |
#matcher(pattern) ⇒ Object
18 19 20 21 |
# File 'lib/gherkin_lint/linter/tag_constraint.rb', line 18 def matcher(pattern) @pattern = pattern validate_input end |
#tags(element) ⇒ Object
13 14 15 16 |
# File 'lib/gherkin_lint/linter/tag_constraint.rb', line 13 def (element) return [] unless element.include? :tags element[:tags].map { |a| a[:name] } end |
#validate_input ⇒ Object
27 28 29 30 |
# File 'lib/gherkin_lint/linter/tag_constraint.rb', line 27 def validate_input raise 'No Tags provided in the YAML' if @pattern.nil? warn 'Required Tags matcher has no value' if @pattern.empty? end |