Class: Megatest::Selector::NameMatchFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/megatest/selector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ NameMatchFilter

Returns a new instance of NameMatchFilter.



210
211
212
# File 'lib/megatest/selector.rb', line 210

def initialize(pattern)
  @pattern = Regexp.new(pattern)
end

Class Method Details

.parse(arg) ⇒ Object



203
204
205
206
207
# File 'lib/megatest/selector.rb', line 203

def parse(arg)
  if match = arg.match(%r{\A/(.+)\z})
    new(match[1])
  end
end

Instance Method Details

#select(test_cases) ⇒ Object



214
215
216
217
218
# File 'lib/megatest/selector.rb', line 214

def select(test_cases)
  test_cases.select do |t|
    @pattern.match?(t.name) || @pattern.match?(t.id)
  end
end