Class: RSpec::Puppet::Adapters::Base
- Inherits:
-
Object
- Object
- RSpec::Puppet::Adapters::Base
show all
- Defined in:
- lib/rspec-puppet/adapters.rb
Instance Method Summary
collapse
Instance Method Details
#catalog(node, exported) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/rspec-puppet/adapters.rb', line 79
def catalog(node, exported)
if exported
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
88
89
90
|
# File 'lib/rspec-puppet/adapters.rb', line 88
def current_environment
Puppet::Node::Environment.new(@environment_name)
end
|
#get_setting(example_group, rspec_setting) ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/rspec-puppet/adapters.rb', line 71
def get_setting(example_group, rspec_setting)
if example_group.respond_to?(rspec_setting)
example_group.send(rspec_setting)
else
RSpec.configuration.send(rspec_setting)
end
end
|
#manifest ⇒ String?
Returns The path to the Puppet manifest if it is present and set, nil otherwise.
105
106
107
|
# File 'lib/rspec-puppet/adapters.rb', line 105
def manifest
Puppet[:manifest]
end
|
#modulepath ⇒ Object
100
101
102
|
# File 'lib/rspec-puppet/adapters.rb', line 100
def modulepath
Puppet[:modulepath].split(File::PATH_SEPARATOR)
end
|
#settings_map ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/rspec-puppet/adapters.rb', line 92
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 as application defaults.
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.
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/rspec-puppet/adapters.rb', line 41
def setup_puppet(example_group)
settings = settings_map.map do |puppet_setting, rspec_setting|
[puppet_setting, get_setting(example_group, rspec_setting)]
end.flatten
default_hash = {:confdir => '/dev/null', :vardir => '/dev/null' }
if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true)
default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests))
end
settings_hash = default_hash.merge(Hash[*settings])
settings_hash.inject(settings_hash) { |h, (k, v)| h[k] = (v == '/dev/null') ? 'c:/nul/' : v; h } if Gem.win_platform?
if Puppet.settings.respond_to?(:initialize_app_defaults)
Puppet.settings.initialize_app_defaults(settings_hash)
Puppet.settings[:environmentpath] = settings_hash[:environmentpath] if settings_hash.key?(:environmentpath)
else
settings_hash.each do |setting, value|
Puppet.settings[setting] = value
end
end
@environment_name = example_group.environment
end
|