Sha256: 9763c41a40d3ff697754be62e22a98e6b42ec716a8a0c4388b0a9cadc4488b1f

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

module Cucumber
  class Filter
    def initialize(lines, options)
      @lines = lines
      @include_tags = options[:include_tags] || []
      @exclude_tags = options[:exclude_tags] || []
      @name_regexps = options[:name_regexps] || []
    end

    def accept?(syntax_node)
      at_line?(syntax_node) &&
      matches_tags?(syntax_node) &&
      matches_names?(syntax_node)
    end

    def accept_example?(syntax_node, outline)
      (at_line?(syntax_node) || outline_at_line?(outline)) && 
      (matches_names?(syntax_node) || outline_matches_names?(outline))
    end
    
    def at_line?(syntax_node)
      @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)}
    end

    def outline_at_line?(syntax_node)
       @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.outline_at_line?(line)}
    end

    def matches_tags?(syntax_node)
      !excluded_by_tags?(syntax_node) &&
      included_by_tags?(syntax_node)
    end

    def included_by_tags?(syntax_node)
      @include_tags.empty? || syntax_node.has_tags?(@include_tags)
    end

    def excluded_by_tags?(syntax_node)
      @exclude_tags.any? && syntax_node.has_tags?(@exclude_tags)
    end
    
    def outline_matches_names?(syntax_node)
      @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.outline_matches_name?(name_regexp)}
    end
    
    def matches_names?(syntax_node)
      @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)}
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.3.11.5 lib/cucumber/filter.rb
aslakhellesoy-cucumber-0.3.11.6 lib/cucumber/filter.rb
jwilger-cucumber-0.3.11.200906161550 lib/cucumber/filter.rb
square-cucumber-0.3.12.2 lib/cucumber/filter.rb
squirrel-cucumber-0.3.12.1 lib/cucumber/filter.rb
squirrel-cucumber-0.3.12 lib/cucumber/filter.rb