Class: RSpec::Puppet::Adapters::Base
- Inherits:
-
Object
- Object
- RSpec::Puppet::Adapters::Base
- Defined in:
- lib/rspec-puppet/adapters.rb
Instance Method Summary collapse
- #catalog(node, exported) ⇒ Object
- #current_environment ⇒ Object
-
#manifest ⇒ String?
The path to the Puppet manifest if it is present and set, nil otherwise.
- #modulepath ⇒ Object
-
#set_setting(example_group, puppet_setting, rspec_setting) ⇒ void
Set up a specific Puppet setting.
- #settings_map ⇒ Object
-
#setup_puppet(example_group) ⇒ void
Set up all Puppet settings applicable for this Puppet version.
Instance Method Details
#catalog(node, exported) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/rspec-puppet/adapters.rb', line 69 def catalog(node, exported) if exported # Use the compiler directly to skip the filtering done by the indirector Puppet::Parser::Compiler.compile(node).filter { |r| !r.exported? } else Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node) end end |
#current_environment ⇒ Object
78 79 80 |
# File 'lib/rspec-puppet/adapters.rb', line 78 def current_environment Puppet::Node::Environment.new(@environment_name) end |
#manifest ⇒ String?
Returns The path to the Puppet manifest if it is present and set, nil otherwise.
95 96 97 |
# File 'lib/rspec-puppet/adapters.rb', line 95 def manifest Puppet[:manifest] end |
#modulepath ⇒ Object
90 91 92 |
# File 'lib/rspec-puppet/adapters.rb', line 90 def modulepath Puppet[:modulepath].split(File::PATH_SEPARATOR) end |
#set_setting(example_group, puppet_setting, rspec_setting) ⇒ void
This method returns an undefined value.
Set up a specific Puppet setting. configuration setting.
Puppet setting values can be taken from the global RSpec configuration, or from the currently executing RSpec context. When a setting is specified both in the global configuration and in the example group, the setting in the example group is preferred.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspec-puppet/adapters.rb', line 54 def set_setting(example_group, puppet_setting, rspec_setting) if example_group.respond_to?(rspec_setting) value = example_group.send(rspec_setting) else value = RSpec.configuration.send(rspec_setting) end begin Puppet[puppet_setting] = value rescue ArgumentError # TODO: this silently swallows errors when applying settings that the current # Puppet version does not accept, which means that user specified settings # are ignored. This may lead to suprising behavior for users. end end |
#settings_map ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/rspec-puppet/adapters.rb', line 82 def settings_map [ [:modulepath, :module_path], [:config, :config], [:confdir, :confdir], ] end |
#setup_puppet(example_group) ⇒ void
This method returns an undefined value.
Set up all Puppet settings applicable for this Puppet version
9 10 11 12 13 14 |
# File 'lib/rspec-puppet/adapters.rb', line 9 def setup_puppet(example_group) settings_map.each do |puppet_setting, rspec_setting| set_setting(example_group, puppet_setting, rspec_setting) end @environment_name = example_group.environment end |