Class: RSpec::Puppet::Adapters::Puppet4X
- Defined in:
- lib/rspec-puppet/adapters/puppet_4x.rb
Instance Method Summary collapse
- #catalog(node, exported) ⇒ Object
- #current_environment ⇒ Object
-
#manifest ⇒ String?
Puppet 4.0 specially handles environments that don’t have a manifest set, so we check for the no manifest value and return nil when it is set.
- #modulepath ⇒ Object
- #settings_map ⇒ Object
- #setup_puppet(example_group) ⇒ Object
Methods inherited from Base
Instance Method Details
#catalog(node, exported) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 52 def catalog(node, exported) node.environment = current_environment # Override $::environment to workaround PUP-5835, where Puppet otherwise # stores a symbol for the parameter node.parameters['environment'] = current_environment.name.to_s if node.parameters['environment'] != node.parameters['environment'].to_s super end |
#current_environment ⇒ Object
60 61 62 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 60 def current_environment Puppet.lookup(:current_environment) end |
#manifest ⇒ String?
Puppet 4.0 specially handles environments that don’t have a manifest set, so we check for the no manifest value and return nil when it is set.
72 73 74 75 76 77 78 79 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 72 def manifest m = current_environment.manifest if m == Puppet::Node::Environment::NO_MANIFEST nil else m end end |
#modulepath ⇒ Object
64 65 66 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 64 def modulepath current_environment.modulepath end |
#settings_map ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 43 def settings_map super.concat([ [:environmentpath, :environmentpath], [:hiera_config, :hiera_config], [:strict_variables, :strict_variables], [:manifest, :manifest], ]) end |
#setup_puppet(example_group) ⇒ Object
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 36 37 38 39 40 41 |
# File 'lib/rspec-puppet/adapters/puppet_4x.rb', line 6 def setup_puppet(example_group) super if rspec_modulepath = RSpec.configuration.module_path modulepath = rspec_modulepath.split(File::PATH_SEPARATOR) else modulepath = Puppet[:environmentpath].split(File::PATH_SEPARATOR).map do |path| File.join(path, 'fixtures', 'modules') end end if rspec_manifest = RSpec.configuration.manifest manifest = rspec_manifest else manifest_paths = Puppet[:environmentpath].split(File::PATH_SEPARATOR).map do |path| File.join(path, 'fixtures', 'manifests') end manifest = manifest_paths.find do |path| File.exist?(path) end manifest ||= Puppet::Node::Environment::NO_MANIFEST end env = Puppet::Node::Environment.create(@environment_name, modulepath, manifest) loader = Puppet::Environments::Static.new(env) Puppet.push_context( { :environments => loader, :current_environment => env }, "Setup rspec-puppet environments" ) end |