blob: fdf3736ac2979a538799c68db1472a87b14bc610 (
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
25
26
|
class BeAnInstanceOfMatcher
def initialize(expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@actual.instance_of?(@expected)
end
def failure_message
["Expected #{@actual.inspect} (#{@actual.class})",
"to be an instance of #{@expected}"]
end
def negative_failure_message
["Expected #{@actual.inspect} (#{@actual.class})",
"not to be an instance of #{@expected}"]
end
end
module MSpecMatchers
private def be_an_instance_of(expected)
BeAnInstanceOfMatcher.new(expected)
end
end
|