Class: Puppet::PuppetSpecInitializer
- Inherits:
-
Object
- Object
- Puppet::PuppetSpecInitializer
- Defined in:
- lib/puppetlabs_spec_helper/puppet_spec_helper.rb
Class Method Summary collapse
-
.initialize_via_fallback_compatibility(config) ⇒ Object
This method is for initializing puppet state for testing for older versions of puppet that do not support the new TestHelper API.
Class Method Details
.initialize_via_fallback_compatibility(config) ⇒ Object
This method is for initializing puppet state for testing for older versions of puppet that do not support the new TestHelper API. As you can see, this involves explicitly modifying global variables, directly manipulating Puppet’s Settings singleton object, and other fun implementation details that code external to puppet should really never know about.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/puppetlabs_spec_helper/puppet_spec_helper.rb', line 51 def self.initialize_via_fallback_compatibility(config) $stderr.puts("Warning: you appear to be using an older version of puppet; spec_helper will use fallback compatibility mode.") config.before :all do # nothing to do for now end config.after :all do # nothing to do for now end config.before :each do # these globals are set by Application $puppet_application_mode = nil $puppet_application_name = nil # REVISIT: I think this conceals other bad tests, but I don't have time to # fully diagnose those right now. When you read this, please come tell me # I suck for letting this float. --daniel 2011-04-21 Signal.stubs(:trap) # Set the confdir and vardir to gibberish so that tests # have to be correctly mocked. Puppet[:confdir] = "/dev/null" Puppet[:vardir] = "/dev/null" # Avoid opening ports to the outside world Puppet.settings[:bindaddress] = "127.0.0.1" end config.after :each do Puppet.settings.clear Puppet::Node::Environment.clear Puppet::Util::Storage.clear Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? "ExecutionStub" PuppetlabsSpec::Files.cleanup end end |