rspec-puppet 2.6.8 → 2.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 685eff630cb1067919ce2264cfb87657480b75ff
4
- data.tar.gz: 9139248ce97fee84aab8e4e963f8196ee5486e64
3
+ metadata.gz: 9e358d6951d64d0bd46d40657619cebac5c90af8
4
+ data.tar.gz: e2af0a6d7a995fe41b0d155f2dc1c20055911da8
5
5
  SHA512:
6
- metadata.gz: cb91f5eea8e985d26590d6da1f74ec363d58ba762bf6e4b13542f71ee87de7977cf4887776aceaf17a2d80ded6c6ffd6e74812094f7a8689916ab25c4c1f0117
7
- data.tar.gz: a112713996ca8b0bf03df1d85e57bf24f6f4e3c3a4c58e22bbad18e600a2aaa4f2cd6d5d216ca5d992263ea6883193fa8d394d951e220287d77cf459de3ec06d
6
+ metadata.gz: f0994991a27eddd126547940ae9a8b667dd7f08a7084b90f35c7a005cdb4b58974b580110908a7afa2a4034429964ee79181531b50cfa6028a016dcf9e8e27f2
7
+ data.tar.gz: 35ca0b9c0b1c1c60a2b736b05652c216322ee5ae1f47d2cb2c85080c93e9ba90e19f88d4f458424df8a9af37625050b16b3f13a02f7a4ecf9b31f1f586916e8c
@@ -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.9]
6
+
7
+ ### Fixed
8
+
9
+ * Initialise Hiera 3 before loading any monkey patches to ensure that the
10
+ correct code is loaded for the actual platform running the tests.
11
+
5
12
  ## [2.6.8]
6
13
 
7
14
  ### Fixed
@@ -1,5 +1,12 @@
1
1
  require 'pathname'
2
2
 
3
+ # Load this library before enabling the monkey-patches to avoid HI-581
4
+ begin
5
+ require 'hiera/util/win32'
6
+ rescue LoadError
7
+ # ignore this on installs without hiera, e.g. puppet 3 gems
8
+ end
9
+
3
10
  class RSpec::Puppet::EventListener
4
11
  def self.example_started(example)
5
12
  if rspec3?
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.8
4
+ version: 2.6.9
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-16 00:00:00.000000000 Z
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -36,14 +36,6 @@ 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
47
39
  - lib/rspec-puppet/cache.rb
48
40
  - lib/rspec-puppet/consts.rb
49
41
  - lib/rspec-puppet/coverage.rb
@@ -1,108 +0,0 @@
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
@@ -1,15 +0,0 @@
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
@@ -1,16 +0,0 @@
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
@@ -1,13 +0,0 @@
1
- require 'rspec-puppet/adapters/puppet_30'
2
-
3
- module RSpec::Puppet
4
- module Adapters
5
- class Puppet32 < Puppet30
6
- def settings_map
7
- super.concat([
8
- [:parser, :parser],
9
- ])
10
- end
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- require 'rspec-puppet/adapters/puppet_32'
2
-
3
- module RSpec::Puppet
4
- module Adapters
5
- class Puppet33 < Puppet32
6
- def settings_map
7
- super.concat([
8
- [:ordering, :ordering],
9
- [:stringify_facts, :stringify_facts],
10
- ])
11
- end
12
- end
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- require 'rspec-puppet/adapters/puppet_33'
2
-
3
- module RSpec::Puppet
4
- module Adapters
5
- class Puppet34 < Puppet33
6
- def settings_map
7
- super.concat([
8
- [:trusted_node_data, :trusted_node_data],
9
- ])
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'rspec-puppet/adapters/puppet_34'
2
-
3
- module RSpec::Puppet
4
- module Adapters
5
- class Puppet35 < Puppet34
6
- def settings_map
7
- super.concat([
8
- [:strict_variables, :strict_variables],
9
- ])
10
- end
11
- end
12
- end
13
- end
@@ -1,82 +0,0 @@
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