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



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

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

#settings_mapObject



256
257
258
259
260
261
# File 'lib/rspec-puppet/adapters.rb', line 256

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

#setup_puppet(example_group) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/rspec-puppet/adapters.rb', line 236

def setup_puppet(example_group)
  case RSpec.configuration.facter_implementation.to_sym
  when :rspec
    if supports_facter_runtime?
      Puppet.runtime[:facter] = proc { RSpec::Puppet::FacterTestImpl.new }
      set_facter_impl(Puppet.runtime[:facter])
    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



223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/rspec-puppet/adapters.rb', line 223

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