blob: 57a35e6eb3b0e42812ed3d873f9b6534909b59df (
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
30
|
module Matchers
class AutoRequireMatcher
def initialize(*expected)
@expected = expected
end
def matches?(resource)
resource_type = resource.class
configuration = resource_type.instance_variable_get(:@autorequires) || {}
@autorequires = configuration.inject([]) do |memo, (param, block)|
memo + resource.instance_eval(&block)
end
@autorequires.include?(@expected)
end
def failure_message_for_should
"expected resource autorequires (#{@autorequires.inspect}) to include #{@expected.inspect}"
end
def failure_message_for_should_not
"expected resource autorequires (#{@autorequires.inspect}) to not include #{@expected.inspect}"
end
end
# call-seq:
# autorequire :logical_volume, 'mylv'
def autorequire(type, name)
AutoRequireMatcher.new(type, name)
end
end
|