Class: Test::Unit::AttributeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/attribute-matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(test) ⇒ AttributeMatcher

Returns a new instance of AttributeMatcher.



4
5
6
# File 'lib/test/unit/attribute-matcher.rb', line 4

def initialize(test)
  @test = test
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/test/unit/attribute-matcher.rb', line 17

def method_missing(name, *args)
  if args.empty?
    @test[name]
  else
    super
  end
end

Instance Method Details

#match?(expression) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/test/unit/attribute-matcher.rb', line 8

def match?(expression)
  matched = instance_eval(expression)
  if matched.nil?
    false
  else
    matched
  end
end