Class: TestRunner::Cli::TagFilters

Inherits:
Object
  • Object
show all
Defined in:
lib/test-runner/cli/tag_filters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str_tags) ⇒ TagFilters

Returns a new instance of TagFilters.

Parameters:

  • str_tags (Array<String>)


4
5
6
7
8
# File 'lib/test-runner/cli/tag_filters.rb', line 4

def initialize(str_tags)
  @must = []
  @cant = []
  parse_all(str_tags)
end

Instance Attribute Details

#cantObject (readonly, protected)

Returns the value of attribute cant.



18
19
20
# File 'lib/test-runner/cli/tag_filters.rb', line 18

def cant
  @cant
end

#mustObject (readonly, protected)

Returns the value of attribute must.



18
19
20
# File 'lib/test-runner/cli/tag_filters.rb', line 18

def must
  @must
end

Instance Method Details

#parse_all(str_tags) ⇒ Object (protected)



20
21
22
23
24
25
26
27
28
# File 'lib/test-runner/cli/tag_filters.rb', line 20

def parse_all(str_tags)
  str_tags.each do |t|
    if t.start_with?('^')
      cant << t[1..]
    else
      must << t
    end
  end
end

#pass?(test_script) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/test-runner/cli/tag_filters.rb', line 11

def pass?(test_script)
  must.all? { |t| test_script.tags.include?(t) } \
    && cant.all? { |t| !test_script.tags.include?(t) }
end