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



277
278
279
280
281
# File 'lib/rspec-puppet/adapters.rb', line 277

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

#settings_mapObject



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

def settings_map
  super.push(
    i[basemodulepath basemodulepath],
    i[vendormoduledir vendormoduledir]
  )
end

#setup_puppet(example_group) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/rspec-puppet/adapters.rb', line 248

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



235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/rspec-puppet/adapters.rb', line 235

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

  @supports_facter_runtime
end