1
unless defined? SPEC_HELPER_IS_LOADED
2
SPEC_HELPER_IS_LOADED = 1
4
1
dir = File.expand_path(File.dirname(__FILE__))
5
2
$LOAD_PATH.unshift File.join(dir, 'lib')
39
36
config.before :each do
39
# We need to preserve the current state of all our indirection cache and
40
# terminus classes. This is pretty important, because changes to these
41
# are global and lead to order dependencies in our testing.
43
# We go direct to the implementation because there is no safe, sane public
44
# API to manage restoration of these to their default values. This
45
# should, once the value is proved, be moved to a standard API on the
48
# To make things worse, a number of the tests stub parts of the
49
# indirector. These stubs have very specific expectations that what
50
# little of the public API we could use is, well, likely to explode
51
# randomly in some tests. So, direct access. --daniel 2011-08-30
52
$saved_indirection_state = {}
53
indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
54
indirections.each do |indirector|
55
$saved_indirection_state[indirector.name] = {
56
:@terminus_class => indirector.instance_variable_get(:@terminus_class),
57
:@cache_class => indirector.instance_variable_get(:@cache_class)
42
61
# these globals are set by Application
43
62
$puppet_application_mode = nil
44
63
$puppet_application_name = nil
74
93
Puppet::Util::Log.close_all
75
94
Puppet::Util::Log.level = @log_level
96
# Restore the indirector configuration. See before hook.
97
indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
98
indirections.each do |indirector|
99
$saved_indirection_state.fetch(indirector.name, {}).each do |variable, value|
100
indirector.instance_variable_set(variable, value)
103
$saved_indirection_state = nil