blob: 792c64089ab7aabc3eeaa4d9d9a2623133a5e182 (
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 BeAncestorOfMatcher
def initialize(expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@expected.ancestors.include? @actual
end
def failure_message
["Expected #{@actual}", "to be an ancestor of #{@expected}"]
end
def negative_failure_message
["Expected #{@actual}", "not to be an ancestor of #{@expected}"]
end
end
class Object
def be_ancestor_of(expected)
BeAncestorOfMatcher.new(expected)
end
end
|