blob: 977dba47a081626604c422e04395741aee4be0c0 (
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
31
32
33
34
35
|
# Manage whether a test is runnable.
module PuppetTest
module RunnableTest
# Confine this test based on specified criteria. The keys of the
# hash should be the message to use if the test is not suitable,
# and the values should be either 'true' or 'false'; true values
# mean the test is suitable.
def confine(hash)
@confines ||= {}
hash.each do |message, result|
@confines[message] = result
end
end
attr_reader :messages
# Evaluate all of our tests to see if any of them are false
# and thus whether this test is considered not runnable.
def runnable?
@messages ||= []
if superclass.respond_to?(:runnable?) and ! superclass.runnable?
return false
end
return false unless @messages.empty?
return true unless defined? @confines
@confines.find_all do |message, result|
! result
end.each do |message, result|
@messages << message
end
return @messages.empty?
end
end
end
|