blob: 2aa3ab14d11fb960478c01799ecca92fda4f489e (
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 RespondToMatcher
def initialize(expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@actual.respond_to?(@expected)
end
def failure_message
["Expected #{@actual.inspect} (#{@actual.class})", "to respond to #{@expected}"]
end
def negative_failure_message
["Expected #{@actual.inspect} (#{@actual.class})", "not to respond to #{@expected}"]
end
end
class Object
def respond_to(expected)
RespondToMatcher.new(expected)
end
end
|