Module: Spinach::TagsMatcher

Defined in:
lib/spinach/tags_matcher.rb

Constant Summary collapse

NEGATION_SIGN =
'~'

Class Method Summary collapse

Class Method Details

.match(tags) ⇒ Object

Matches an array of tags (e.g. of a scenario) against the tags present in Spinach’s runtime options.

Spinach’s tag option is an array which consists of (possibly) multiple arrays containing tags provided by the user running the features and scenarios. Each of these arrays is considered a tag group.

When matching tags against the tags groups, the tags inside a tag group are OR-ed and the tag groups themselves are AND-ed.



17
18
19
20
21
22
23
24
# File 'lib/spinach/tags_matcher.rb', line 17

def match(tags)
  return true if tag_groups.empty?

  tag_groups.all? { |tag_group| 
    res = match_tag_group(Array(tag_group), tags) 
    res
  }
end

.match_feature(feature) ⇒ Object

Matches the tags of a feature (and its scenarios) against the tags present in Spinach’s runtime options.

A feature matches when, for any of its scenarios, the combination of the feature’s tags and that scenario’s tags match the configured tags.



31
32
33
# File 'lib/spinach/tags_matcher.rb', line 31

def match_feature(feature)
  feature.scenarios.any? { |scenario| match(feature.tags + scenario.tags) }
end