blob: ce097ccf0f64f54ee8a432cb318f2c39fb6f8725 (
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
27
28
29
|
class IncludeAnyOfMatcher
def initialize(*expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@expected.each do |e|
if @actual.include?(e)
return true
end
end
return false
end
def failure_message
["Expected #{@actual.inspect}", "to include any of #{@expected.inspect}"]
end
def negative_failure_message
["Expected #{@actual.inspect}", "not to include any of #{@expected.inspect}"]
end
end
module MSpecMatchers
private def include_any_of(*expected)
IncludeAnyOfMatcher.new(*expected)
end
end
|