Class: RSpec::Puppet::Adapters::Adapter6X

Inherits:
Adapter40 show all
Defined in:
lib/rspec-puppet/adapters.rb

Instance Method Summary collapse

Methods inherited from Adapter40

#current_environment, #manifest, #modulepath, #set_facter_impl

Methods inherited from Base

#current_environment, #get_setting, #manifest, #modulepath

Instance Method Details

#catalog(node, _exported) ⇒ Object



269
270
271
272
273
# File 'lib/rspec-puppet/adapters.rb', line 269

def catalog(node, _exported)
  super.tap do |c|
    Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(node.facts, c)
  end
end

#settings_mapObject



262
263
264
265
266
267
# File 'lib/rspec-puppet/adapters.rb', line 262

def settings_map
  super.concat([
    [:basemodulepath, :basemodulepath],
    [:vendormoduledir, :vendormoduledir],
  ])
end

#setup_puppet(example_group) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/rspec-puppet/adapters.rb', line 240

def setup_puppet(example_group)
  case RSpec.configuration.facter_implementation.to_sym
  when :rspec
    if supports_facter_runtime?
      # Lazily instantiate FacterTestImpl here to optimize memory
      # allocation, as the proc will only be called if FacterImpl is unset
      set_facter_impl(proc { RSpec::Puppet::FacterTestImpl.new })
      Puppet.runtime[:facter] = FacterImpl
    else
      warn "Facter runtime implementations are not supported in Puppet #{Puppet.version}, continuing with facter_implementation 'facter'"
      RSpec.configuration.facter_implementation = :facter
      set_facter_impl(Facter)
    end
  when :facter
    set_facter_impl(Facter)
  else
    raise "Unsupported facter_implementation '#{RSpec.configuration.facter_implementation}'"
  end

  super
end

#supports_facter_runtime?Boolean

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.

Check to see if Facter runtime implementations are supported in the current Puppet version

Returns:

  • (Boolean)

    true if runtime implementations are supported



227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/rspec-puppet/adapters.rb', line 227

def supports_facter_runtime?
  unless defined?(@supports_facter_runtime)
    begin
      Puppet.runtime[:facter]
      @supports_facter_runtime = true
    rescue
      @supports_facter_runtime = false
    end
  end

  @supports_facter_runtime
end