Sha256: d520bebe118a6f0eacc78dcdf1e22b629275ed6222dd0f5ef09f0131b99e6ed7

Contents?: true

Size: 905 Bytes

Versions: 5

Compression:

Stored size: 905 Bytes

Contents

module Chutney
  # Mixin to lint for tags that have certain string contraints
  module TagConstraint
    def lint
      scenarios do |file, feature, scenario|
        next if match_pattern? tags(feature)
        next if match_pattern? tags(scenario)
        
        references = [reference(file, feature, scenario)]
        add_error(references, 'Required Tag not found')
      end
    end

    def tags(element)
      return [] unless element.include? :tags
      
      element[:tags].map { |a| a[:name] }
    end

    def matcher(pattern)
      @pattern = pattern
      validate_input
    end

    def match_pattern?(_tags)
      raise NoMethodError, 'This is an abstraction that must be implemented by the includer'
    end

    def validate_input
      raise 'No Tags provided in the YAML' if @pattern.nil?
      
      warn 'Required Tags matcher has no value' if @pattern.empty?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chutney-1.6.3 lib/chutney/linter/tag_constraint.rb
chutney-1.6.2 lib/chutney/linter/tag_constraint.rb
chutney-1.6.1 lib/chutney/linter/tag_constraint.rb
chutney-1.6.0 lib/chutney/linter/tag_constraint.rb
chutney-0.5.0 lib/chutney/linter/tag_constraint.rb