Module: RSpec::Puppet::HostExampleGroup

Includes:
ManifestMatchers, Support
Defined in:
lib/rspec-puppet/example/host_example_group.rb

Instance Method Summary collapse

Instance Method Details

#catalogueObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec-puppet/example/host_example_group.rb', line 10

def catalogue
  vardir = Dir.mktmpdir
  Puppet[:vardir] = vardir
  Puppet[:hiera_config] = File.join(vardir, "hiera.yaml") if Puppet[:hiera_config] == File.expand_path("/dev/null")
  Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
  Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
  Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
  Puppet[:templatedir] = self.respond_to?(:template_dir) ? template_dir : RSpec.configuration.template_dir
  Puppet[:config] = self.respond_to?(:config) ? config : RSpec.configuration.config
  code = ""

  nodename = self.class.top_level_description.downcase

  facts_val = {
    'hostname' => nodename.split('.').first,
    'fqdn' => nodename,
    'domain' => nodename.split('.').last,
  }
  facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)

  catalogue = build_catalog(nodename, facts_val, code)
  FileUtils.rm_rf(vardir) if File.directory?(vardir)
  catalogue
end

#subjectObject



6
7
8
# File 'lib/rspec-puppet/example/host_example_group.rb', line 6

def subject
  @catalogue ||= catalogue
end