blob: 4d801ea33778c56b41e23710e0ae5287c7e05f35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
class VariableMatcher
class << self
attr_accessor :variables_method, :description
end
def initialize(variable)
@variable = variable.to_sym
end
def matches?(object)
@object = object
@object.send(self.class.variables_method).include? @variable
end
def failure_message
["Expected #{@object} to have #{self.class.description} '#{@variable}'",
"but it does not"]
end
def negative_failure_message
["Expected #{@object} NOT to have #{self.class.description} '#{@variable}'",
"but it does"]
end
end
|