Class: RSpec::Puppet::Adapters::Adapter40
- Defined in:
- lib/rspec-puppet/adapters.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
-
#set_facter_impl(impl) ⇒ Object
private
Set the FacterImpl constant to the given Facter implementation.
- #settings_map ⇒ Object
- #setup_puppet(example_group) ⇒ Object
Methods inherited from Base
Instance Method Details
#catalog(node, exported) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/rspec-puppet/adapters.rb', line 171 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
179 180 181 |
# File 'lib/rspec-puppet/adapters.rb', line 179 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.
191 192 193 194 195 196 197 198 |
# File 'lib/rspec-puppet/adapters.rb', line 191 def manifest m = current_environment.manifest if m == Puppet::Node::Environment::NO_MANIFEST nil else m end end |
#modulepath ⇒ Object
183 184 185 |
# File 'lib/rspec-puppet/adapters.rb', line 183 def modulepath current_environment.modulepath end |
#set_facter_impl(impl) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the FacterImpl constant to the given Facter implementation. The method noops if the constant is already set
120 121 122 |
# File 'lib/rspec-puppet/adapters.rb', line 120 def set_facter_impl(impl) Object.send(:const_set, :FacterImpl, impl) unless defined? FacterImpl end |
#settings_map ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/rspec-puppet/adapters.rb', line 162 def settings_map super.concat([ [:environmentpath, :environmentpath], [:hiera_config, :hiera_config], [:strict_variables, :strict_variables], [:manifest, :manifest], ]) end |
#setup_puppet(example_group) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/rspec-puppet/adapters.rb', line 124 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, :loaders => (Puppet::Pops::Loaders.new(env) if Gem::Version.new(Puppet.version) >= Gem::Version.new('6.0.0')), }, "Setup rspec-puppet environments" ) end |