rspec-puppet 2.6.5 → 2.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rspec-puppet/adapters/base.rb +108 -0
- data/lib/rspec-puppet/adapters/puppet_27.rb +15 -0
- data/lib/rspec-puppet/adapters/puppet_30.rb +16 -0
- data/lib/rspec-puppet/adapters/puppet_32.rb +13 -0
- data/lib/rspec-puppet/adapters/puppet_33.rb +14 -0
- data/lib/rspec-puppet/adapters/puppet_34.rb +13 -0
- data/lib/rspec-puppet/adapters/puppet_35.rb +13 -0
- data/lib/rspec-puppet/adapters/puppet_4x.rb +82 -0
- data/lib/rspec-puppet/monkey_patches.rb +15 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9090f6434c25d6afd4341586dab7f2c04a281cce
|
4
|
+
data.tar.gz: 29c6eedd09c990f1cf2b7bc9c398b224e2931f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d9f9db94e36ac66d643943e50fbd5fda038c7be688a764e7090109cf5ad7759c54f31471e24f323dac15c6f7141b65e7b0a522d20daa05b54934ead96f712e1
|
7
|
+
data.tar.gz: 5763b8a546bb6af4ef4198ff7d136c63328483b95b6ecf9f3a35e1f64261a707ee7e0f6009c3f35e23b6a5b5fc4b637c93fbc800c52b5930c5d6b8a6ce72ffae
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
All notable changes to this project will be documented in this file. This
|
3
3
|
project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [2.6.6]
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
* Fixed an issue caused by `Puppet::Util.get_env` when pretending to be a
|
10
|
+
Windows host.
|
11
|
+
|
5
12
|
## [2.6.5]
|
6
13
|
|
7
14
|
### Changed
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module RSpec::Puppet
|
2
|
+
module Adapters
|
3
|
+
class Base
|
4
|
+
# Set up all Puppet settings applicable for this Puppet version as
|
5
|
+
# application defaults.
|
6
|
+
#
|
7
|
+
# Puppet setting values can be taken from the global RSpec configuration, or from the currently
|
8
|
+
# executing RSpec context. When a setting is specified both in the global configuration and in
|
9
|
+
# the example group, the setting in the example group is preferred.
|
10
|
+
#
|
11
|
+
# @example Configuring a Puppet setting from a global RSpec configuration value
|
12
|
+
# RSpec.configure do |config|
|
13
|
+
# config.parser = "future"
|
14
|
+
# end
|
15
|
+
# # => Puppet[:parser] will be future
|
16
|
+
#
|
17
|
+
# @example Configuring a Puppet setting from within an RSpec example group
|
18
|
+
# RSpec.describe 'my_module::my_class', :type => :class do
|
19
|
+
# let(:module_path) { "/Users/luke/modules" }
|
20
|
+
# #=> Puppet[:modulepath] will be "/Users/luke/modules"
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# @example Configuring a Puppet setting with both a global RSpec configuration and local context
|
24
|
+
# RSpec.configure do |config|
|
25
|
+
# config.confdir = "/etc/puppet"
|
26
|
+
# end
|
27
|
+
# RSpec.describe 'my_module', :type => :class do
|
28
|
+
# # Puppet[:confdir] will be "/etc/puppet"
|
29
|
+
# end
|
30
|
+
# RSpec.describe 'my_module::my_class', :type => :class do
|
31
|
+
# let(:confdir) { "/etc/puppetlabs/puppet" }
|
32
|
+
# # => Puppet[:confdir] will be "/etc/puppetlabs/puppet" in this example group
|
33
|
+
# end
|
34
|
+
# RSpec.describe 'my_module::my_define', :type => :define do
|
35
|
+
# # Puppet[:confdir] will be "/etc/puppet" again
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# @param example_group [RSpec::Core::ExampleGroup] The RSpec context to use for local settings
|
39
|
+
# @return [void]
|
40
|
+
def setup_puppet(example_group)
|
41
|
+
settings = settings_map.map do |puppet_setting, rspec_setting|
|
42
|
+
[puppet_setting, get_setting(example_group, rspec_setting)]
|
43
|
+
end.flatten
|
44
|
+
default_hash = {:confdir => '/dev/null', :vardir => '/dev/null' }
|
45
|
+
if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true)
|
46
|
+
default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests))
|
47
|
+
end
|
48
|
+
settings_hash = default_hash.merge(Hash[*settings])
|
49
|
+
|
50
|
+
if Puppet.settings.respond_to?(:initialize_app_defaults)
|
51
|
+
Puppet.settings.initialize_app_defaults(settings_hash)
|
52
|
+
|
53
|
+
# Forcefully apply the environmentpath setting instead of relying on
|
54
|
+
# the application defaults as Puppet::Test::TestHelper automatically
|
55
|
+
# sets this value as well, overriding our application default
|
56
|
+
Puppet.settings[:environmentpath] = settings_hash[:environmentpath] if settings_hash.key?(:environmentpath)
|
57
|
+
else
|
58
|
+
# Set settings the old way for Puppet 2.x, because that's how
|
59
|
+
# they're defaulted in that version of Puppet::Test::TestHelper and
|
60
|
+
# we won't be able to override them otherwise.
|
61
|
+
settings_hash.each do |setting, value|
|
62
|
+
Puppet.settings[setting] = value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
@environment_name = example_group.environment
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_setting(example_group, rspec_setting)
|
70
|
+
if example_group.respond_to?(rspec_setting)
|
71
|
+
example_group.send(rspec_setting)
|
72
|
+
else
|
73
|
+
RSpec.configuration.send(rspec_setting)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def catalog(node, exported)
|
78
|
+
if exported
|
79
|
+
# Use the compiler directly to skip the filtering done by the indirector
|
80
|
+
Puppet::Parser::Compiler.compile(node).filter { |r| !r.exported? }
|
81
|
+
else
|
82
|
+
Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def current_environment
|
87
|
+
Puppet::Node::Environment.new(@environment_name)
|
88
|
+
end
|
89
|
+
|
90
|
+
def settings_map
|
91
|
+
[
|
92
|
+
[:modulepath, :module_path],
|
93
|
+
[:config, :config],
|
94
|
+
[:confdir, :confdir],
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
def modulepath
|
99
|
+
Puppet[:modulepath].split(File::PATH_SEPARATOR)
|
100
|
+
end
|
101
|
+
|
102
|
+
# @return [String, nil] The path to the Puppet manifest if it is present and set, nil otherwise.
|
103
|
+
def manifest
|
104
|
+
Puppet[:manifest]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rspec-puppet/adapters/base'
|
2
|
+
|
3
|
+
module RSpec::Puppet
|
4
|
+
module Adapters
|
5
|
+
class Puppet27 < Base
|
6
|
+
def settings_map
|
7
|
+
super.concat([
|
8
|
+
[:manifestdir, :manifest_dir],
|
9
|
+
[:manifest, :manifest],
|
10
|
+
[:templatedir, :template_dir],
|
11
|
+
])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rspec-puppet/adapters/base'
|
2
|
+
|
3
|
+
module RSpec::Puppet
|
4
|
+
module Adapters
|
5
|
+
class Puppet30 < Base
|
6
|
+
def settings_map
|
7
|
+
super.concat([
|
8
|
+
[:manifestdir, :manifest_dir],
|
9
|
+
[:manifest, :manifest],
|
10
|
+
[:templatedir, :template_dir],
|
11
|
+
[:hiera_config, :hiera_config],
|
12
|
+
])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rspec-puppet/adapters/base'
|
2
|
+
|
3
|
+
module RSpec::Puppet
|
4
|
+
module Adapters
|
5
|
+
class Puppet4X < Base
|
6
|
+
def setup_puppet(example_group)
|
7
|
+
super
|
8
|
+
|
9
|
+
if rspec_modulepath = RSpec.configuration.module_path
|
10
|
+
modulepath = rspec_modulepath.split(File::PATH_SEPARATOR)
|
11
|
+
else
|
12
|
+
modulepath = Puppet[:environmentpath].split(File::PATH_SEPARATOR).map do |path|
|
13
|
+
File.join(path, 'fixtures', 'modules')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
if rspec_manifest = RSpec.configuration.manifest
|
18
|
+
manifest = rspec_manifest
|
19
|
+
else
|
20
|
+
manifest_paths = Puppet[:environmentpath].split(File::PATH_SEPARATOR).map do |path|
|
21
|
+
File.join(path, 'fixtures', 'manifests')
|
22
|
+
end
|
23
|
+
|
24
|
+
manifest = manifest_paths.find do |path|
|
25
|
+
File.exist?(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
manifest ||= Puppet::Node::Environment::NO_MANIFEST
|
29
|
+
end
|
30
|
+
|
31
|
+
env = Puppet::Node::Environment.create(@environment_name, modulepath, manifest)
|
32
|
+
loader = Puppet::Environments::Static.new(env)
|
33
|
+
|
34
|
+
Puppet.push_context(
|
35
|
+
{
|
36
|
+
:environments => loader,
|
37
|
+
:current_environment => env
|
38
|
+
},
|
39
|
+
"Setup rspec-puppet environments"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def settings_map
|
44
|
+
super.concat([
|
45
|
+
[:environmentpath, :environmentpath],
|
46
|
+
[:hiera_config, :hiera_config],
|
47
|
+
[:strict_variables, :strict_variables],
|
48
|
+
[:manifest, :manifest],
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
def catalog(node, exported)
|
53
|
+
node.environment = current_environment
|
54
|
+
# Override $::environment to workaround PUP-5835, where Puppet otherwise
|
55
|
+
# stores a symbol for the parameter
|
56
|
+
node.parameters['environment'] = current_environment.name.to_s if node.parameters['environment'] != node.parameters['environment'].to_s
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_environment
|
61
|
+
Puppet.lookup(:current_environment)
|
62
|
+
end
|
63
|
+
|
64
|
+
def modulepath
|
65
|
+
current_environment.modulepath
|
66
|
+
end
|
67
|
+
|
68
|
+
# Puppet 4.0 specially handles environments that don't have a manifest set, so we check for the no manifest value
|
69
|
+
# and return nil when it is set.
|
70
|
+
#
|
71
|
+
# @return [String, nil] The path to the Puppet manifest if it is present and set, nil otherwise.
|
72
|
+
def manifest
|
73
|
+
m = current_environment.manifest
|
74
|
+
if m == Puppet::Node::Environment::NO_MANIFEST
|
75
|
+
nil
|
76
|
+
else
|
77
|
+
m
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -110,6 +110,21 @@ module Puppet
|
|
110
110
|
end
|
111
111
|
|
112
112
|
module Util
|
113
|
+
if respond_to?(:get_env)
|
114
|
+
alias :old_get_env :get_env
|
115
|
+
module_function :old_get_env
|
116
|
+
|
117
|
+
def get_env(name, mode = default_env)
|
118
|
+
if RSpec::Puppet.rspec_puppet_example?
|
119
|
+
# use the actual platform, not the pretended
|
120
|
+
old_get_env(name, Platform.actual_platform)
|
121
|
+
else
|
122
|
+
old_get_env(name, mode)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
module_function :get_env
|
126
|
+
end
|
127
|
+
|
113
128
|
# Allow rspec-puppet to pretend to be different platforms.
|
114
129
|
module Platform
|
115
130
|
alias :old_windows? :windows?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -36,6 +36,14 @@ files:
|
|
36
36
|
- bin/rspec-puppet-init
|
37
37
|
- lib/rspec-puppet.rb
|
38
38
|
- lib/rspec-puppet/adapters.rb
|
39
|
+
- lib/rspec-puppet/adapters/base.rb
|
40
|
+
- lib/rspec-puppet/adapters/puppet_27.rb
|
41
|
+
- lib/rspec-puppet/adapters/puppet_30.rb
|
42
|
+
- lib/rspec-puppet/adapters/puppet_32.rb
|
43
|
+
- lib/rspec-puppet/adapters/puppet_33.rb
|
44
|
+
- lib/rspec-puppet/adapters/puppet_34.rb
|
45
|
+
- lib/rspec-puppet/adapters/puppet_35.rb
|
46
|
+
- lib/rspec-puppet/adapters/puppet_4x.rb
|
39
47
|
- lib/rspec-puppet/cache.rb
|
40
48
|
- lib/rspec-puppet/consts.rb
|
41
49
|
- lib/rspec-puppet/coverage.rb
|