rspec-puppet 2.7.4 → 2.7.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rspec-puppet might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95bf3d879ba756cda5b177f912cfe475bbbc4bc447f5406f9f1316fbfe993ba4
4
- data.tar.gz: 2f28954f31be33d33106a654b223674813dbe077e9389da1a2c3e1220f4f9aa6
3
+ metadata.gz: ca4beef2e1c4c55e6e0e79b0fd9d03fb05a1462166632aa64c6df9b37ca93e51
4
+ data.tar.gz: 7b4c5948d175bbfad4f46fcf89ac1ec8427dbc1457cf3f767dc656427a30b6ce
5
5
  SHA512:
6
- metadata.gz: de1fe9a59b9f74dc5da66bf23121cdcc7b0330837fc6ba3305e5e40d4170b5a45447d454ee7c20aa747a40bb59a8536430f966b55ee963c5bb274ca595746ef4
7
- data.tar.gz: e1f45453a1d1263244c14d12550bd7ace1c291983c93aa4516bd7cb6f3f4b75dbac047c3ebad7bb41937082a2f225292cb3161c6bf2618ce22b30af15d36c8a5
6
+ metadata.gz: 3a24ffc5d27c563a0bfe01be6f6881119955ad7a46afe330ffa9a787102186b41ba1af6d26df8984202746aefa5fca432860074e874073aba9a2fe69e87099d7
7
+ data.tar.gz: 19e34976f263b427406002ffa5ba26711814d49558c1bc2f396fd03415ce0ec7fe018052d4e90db5e295127561d1e8a1c30371fc32d856a14a0d34c81a29b1a4
@@ -2,6 +2,36 @@
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.7.9]
6
+ ### Fixed
7
+ * Fix issues with removal of `default_env` method in Puppet 6.17.0.
8
+
9
+ ## [2.7.8]
10
+
11
+ ### Fixed
12
+ * Fix cross-platform testing for Puppet >= 6.9.0 when there is no `ipaddress6`
13
+ fact defined.
14
+
15
+ ## [2.7.7]
16
+
17
+ ### Fixed
18
+ * Fix the support for rspec-expectations >= 3.8.5.
19
+
20
+ ### Changed
21
+ * Remove the rspec-expectations dependency limit introduced in 2.7.6.
22
+
23
+ ## [2.7.6]
24
+
25
+ ### Changed
26
+ * Limit rspec-expectations dependency to < 3.8.5 due to an incompatible
27
+ change.
28
+
29
+ ## [2.7.5]
30
+
31
+ ### Fixed
32
+ * Minor refactor to prevent the fix introduced in 2.7.4 from raising
33
+ a deprecation warning on latest RSpec.
34
+
5
35
  ## [2.7.4]
6
36
 
7
37
  ### Fixed
@@ -11,12 +11,17 @@ module RSpec::Puppet
11
11
  end
12
12
 
13
13
  def get(*args, &blk)
14
- # decouple the hash key from whatever the blk might do to it
15
14
  key = Marshal.load(Marshal.dump(args))
16
- if !@cache.has_key? key
17
- @cache[key] = (blk || @default_proc).call(*args)
18
- @lra << key
15
+ if @cache.has_key?(key)
16
+ # Cache hit
17
+ # move that entry last to make it "most recenty used"
18
+ @lra.insert(-1, @lra.delete_at(@lra.index(args)))
19
+ else
20
+ # Cache miss
21
+ # Ensure room by evicting least recently used if no space left
19
22
  expire!
23
+ @cache[args] = (blk || @default_proc).call(*args)
24
+ @lra << args
20
25
  end
21
26
 
22
27
  @cache[key]
@@ -25,8 +30,8 @@ module RSpec::Puppet
25
30
  private
26
31
 
27
32
  def expire!
28
- expired = @lra.slice!(0, @lra.size - MAX_ENTRIES)
29
- expired.each { |key| @cache.delete(key) } if expired
33
+ # delete one entry (the oldest) when there is no room in cache
34
+ @cache.delete(@lra.shift) if @cache.size == MAX_ENTRIES
30
35
  end
31
36
  end
32
37
  end
@@ -159,7 +159,13 @@ module RSpec::Puppet
159
159
  end
160
160
  coverage_test.run(RSpec.configuration.reporter)
161
161
 
162
- if coverage_results.execution_result[:status] == :failed
162
+ status = if coverage_results.execution_result.respond_to?(:status)
163
+ coverage_results.execution_result.status
164
+ else
165
+ coverage_results.execution_result[:status]
166
+ end
167
+
168
+ if status == :failed
163
169
  RSpec.world.non_example_failure = true
164
170
  RSpec.world.wants_to_quit = true
165
171
  end
@@ -6,3 +6,4 @@ require 'rspec-puppet/matchers/count_generic'
6
6
  require 'rspec-puppet/matchers/dynamic_matchers'
7
7
  require 'rspec-puppet/matchers/type_matchers'
8
8
  require 'rspec-puppet/matchers/allow_value'
9
+ require 'rspec-puppet/matchers/raise_error'
@@ -34,6 +34,14 @@ module RSpec::Puppet
34
34
  def failure_message_when_negated
35
35
  "expected that the type alias would not " + description + " but it does"
36
36
  end
37
+
38
+ def supports_block_expectations
39
+ true
40
+ end
41
+
42
+ def supports_value_expectations
43
+ true
44
+ end
37
45
  end
38
46
 
39
47
  def allow_value(*values)
@@ -78,6 +78,14 @@ module RSpec::Puppet
78
78
  end
79
79
  end
80
80
 
81
+ def supports_block_expectations
82
+ true
83
+ end
84
+
85
+ def supports_value_expectations
86
+ true
87
+ end
88
+
81
89
  private
82
90
  def missing_dependencies?
83
91
  retval = false
@@ -61,6 +61,14 @@ module RSpec::Puppet
61
61
  "expected that the catalogue would not " + description + " but it does"
62
62
  end
63
63
 
64
+ def supports_block_expectations
65
+ true
66
+ end
67
+
68
+ def supports_value_expectations
69
+ true
70
+ end
71
+
64
72
  private
65
73
 
66
74
  def referenced_type(type)
@@ -89,6 +89,11 @@ module RSpec::Puppet
89
89
  else
90
90
  RSpec::Puppet::Coverage.cover!(resource)
91
91
  rsrc_hsh = resource.to_hash
92
+ if resource.respond_to?(:sensitive_parameters)
93
+ resource.sensitive_parameters.each do |s_param|
94
+ rsrc_hsh[s_param] = ::Puppet::Pops::Types::PSensitiveType::Sensitive.new(rsrc_hsh[s_param])
95
+ end
96
+ end
92
97
 
93
98
  if resource.builtin_type?
94
99
  namevar = resource.resource_type.key_attributes.first.to_s
@@ -177,6 +182,14 @@ module RSpec::Puppet
177
182
  true
178
183
  end
179
184
 
185
+ def supports_block_expectations
186
+ true
187
+ end
188
+
189
+ def supports_value_expectations
190
+ true
191
+ end
192
+
180
193
  def expected
181
194
  @errors.map {|e| e.expected if e.respond_to?(:expected)}.compact.join("\n\n")
182
195
  end
@@ -22,6 +22,13 @@ module RSpec::Puppet
22
22
  end
23
23
  end
24
24
 
25
+ def supports_block_expectations
26
+ true
27
+ end
28
+
29
+ def supports_value_expectations
30
+ true
31
+ end
25
32
  end
26
33
 
27
34
  end
@@ -21,10 +21,7 @@ module RSpec::Puppet
21
21
  #
22
22
  # @return [true, false]
23
23
  def matches?(resource)
24
-
25
- @resource = resource
26
-
27
- actual = @resource[@parameter]
24
+ actual = resource[@parameter]
28
25
  expected = @value
29
26
 
30
27
  # Puppet flattens an array with a single value into just the value and
@@ -65,6 +62,8 @@ module RSpec::Puppet
65
62
  check_hash(expected, actual)
66
63
  when Array
67
64
  check_array(expected, actual)
65
+ when RSpec::Puppet::Sensitive
66
+ expected == actual
68
67
  else
69
68
  check_string(expected, actual)
70
69
  end
@@ -0,0 +1,23 @@
1
+ module RSpec::Puppet
2
+ module GenericMatchers
3
+ # Due to significant code base depending on the
4
+ #
5
+ # is_expected.to raise_error Puppet::Error
6
+ #
7
+ # syntax, and removal of this syntax from RSpec, extend RSpec's built-in
8
+ # `raise_error` matcher to accept a value target, e.g. a subject defined
9
+ # as a lambda, e.g.:
10
+ #
11
+ # subject(:catalogue) { lambda { load_catalogue } }
12
+ #
13
+ class RaiseError < RSpec::Matchers::BuiltIn::RaiseError
14
+ def supports_value_expectations?
15
+ true
16
+ end
17
+ end
18
+
19
+ def raise_error(*args, &block)
20
+ RaiseError.new(*args, &block)
21
+ end
22
+ end
23
+ end
@@ -104,6 +104,14 @@ module RSpec::Puppet
104
104
  end
105
105
  end
106
106
 
107
+ def supports_block_expectations
108
+ true
109
+ end
110
+
111
+ def supports_value_expectations
112
+ true
113
+ end
114
+
107
115
  private
108
116
  def func_name
109
117
  @func_obj.func_name
@@ -132,6 +132,16 @@ module Puppet
132
132
  end
133
133
 
134
134
  module Util
135
+ # Fix for removal of default_env function
136
+ # Bug: https://github.com/rodjek/rspec-puppet/issues/796
137
+ # Upstream: https://github.com/puppetlabs/puppet/commit/94df3c1a3992d89b2d7d5db8a70373c135bdd86b
138
+ if !respond_to?(:default_env)
139
+ def default_env()
140
+ DEFAULT_ENV
141
+ end
142
+ module_function :default_env
143
+ end
144
+
135
145
  if respond_to?(:get_env)
136
146
  alias :old_get_env :get_env
137
147
  module_function :old_get_env
@@ -292,6 +302,24 @@ class Pathname
292
302
  end
293
303
  end
294
304
 
305
+ # Puppet loads init.pp, then foo.pp, to find class "mod::foo". If
306
+ # class "mod" has been mocked using pre_condition when testing
307
+ # "mod::foo", this causes duplicate declaration for "mod".
308
+ # This monkey patch only loads "init.pp" if "foo.pp" does not exist.
309
+ class Puppet::Module
310
+ if [:match_manifests, 'match_manifests'].any? { |r| instance_methods.include?(r) }
311
+ old_match_manifests = instance_method(:match_manifests)
312
+
313
+ define_method(:match_manifests) do |rest|
314
+ result = old_match_manifests.bind(self).call(rest)
315
+ if result.length > 1 && File.basename(result[0]) == 'init.pp'
316
+ result.shift
317
+ end
318
+ result
319
+ end
320
+ end
321
+ end
322
+
295
323
  # Prevent the File type from munging paths (which uses File.expand_path to
296
324
  # normalise paths, which does very bad things to *nix paths on Windows.
297
325
  file_path_munge = Puppet::Type.type(:file).paramclass(:path).instance_method(:unsafe_munge)
@@ -0,0 +1,47 @@
1
+ module RSpec::Puppet
2
+ if defined?(::Puppet::Pops::Types::PSensitiveType::Sensitive)
3
+ # A wrapper representing Sensitive data type, eg. in class params.
4
+ class Sensitive < ::Puppet::Pops::Types::PSensitiveType::Sensitive
5
+ # Create a new Sensitive object
6
+ # @param [Object] value to wrap
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ # @return the wrapped value
12
+ def unwrap
13
+ @value
14
+ end
15
+
16
+ # @return true
17
+ def sensitive?
18
+ true
19
+ end
20
+
21
+ # @return inspect of the wrapped value, inside Sensitive()
22
+ def inspect
23
+ "Sensitive(#{@value.inspect})"
24
+ end
25
+
26
+ # Check for equality with another value.
27
+ # If compared to Puppet Sensitive type, it compares the wrapped values.
28
+
29
+ # @param other [#unwrap, Object] value to compare to
30
+ def == other
31
+ if other.respond_to? :unwrap
32
+ return unwrap == other.unwrap
33
+ else
34
+ super
35
+ end
36
+ end
37
+ end
38
+ else
39
+ #:nocov:
40
+ class Sensitive
41
+ def initialize(value)
42
+ raise 'The use of the Sensitive data type is not supported by this Puppet version'
43
+ end
44
+ end
45
+ #:nocov:
46
+ end
47
+ end
@@ -1,9 +1,12 @@
1
1
  require 'rspec-puppet/cache'
2
2
  require 'rspec-puppet/adapters'
3
3
  require 'rspec-puppet/raw_string'
4
+ require 'rspec-puppet/sensitive'
4
5
 
5
6
  module RSpec::Puppet
6
7
  module Support
8
+ include GenericMatchers
9
+
7
10
  @@cache = RSpec::Puppet::Cache.new
8
11
 
9
12
  def subject
@@ -224,10 +227,11 @@ module RSpec::Puppet
224
227
  }
225
228
 
226
229
  node_facts = {
227
- 'hostname' => node.split('.').first,
228
- 'fqdn' => node,
229
- 'domain' => node.split('.', 2).last,
230
- 'clientcert' => node,
230
+ 'hostname' => node.split('.').first,
231
+ 'fqdn' => node,
232
+ 'domain' => node.split('.', 2).last,
233
+ 'clientcert' => node,
234
+ 'ipaddress6' => 'FE80:0000:0000:0000:AAAA:AAAA:AAAA',
231
235
  }
232
236
 
233
237
  networking_facts = {
@@ -437,8 +441,7 @@ module RSpec::Puppet
437
441
  end
438
442
 
439
443
  def escape_special_chars(string)
440
- string.gsub!(/\$/, "\\$")
441
- string
444
+ string.gsub(/\$/, "\\$")
442
445
  end
443
446
 
444
447
  def rspec_compatibility
@@ -459,6 +462,14 @@ module RSpec::Puppet
459
462
  return RSpec::Puppet::RawString.new("#{type}['#{title}']")
460
463
  end
461
464
 
465
+ # Helper to return value wrapped in Sensitive type.
466
+ #
467
+ # @param [Object] value to wrap
468
+ # @return [RSpec::Puppet::Sensitive] a new Sensitive wrapper with the new value
469
+ def sensitive(value)
470
+ return RSpec::Puppet::Sensitive.new(value)
471
+ end
472
+
462
473
  # @!attribute [r] adapter
463
474
  # @api private
464
475
  # @return [Class < RSpec::Puppet::Adapters::Base]
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.7.4
4
+ version: 2.7.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: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2020-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -57,6 +57,7 @@ files:
57
57
  - lib/rspec-puppet/matchers/dynamic_matchers.rb
58
58
  - lib/rspec-puppet/matchers/include_class.rb
59
59
  - lib/rspec-puppet/matchers/parameter_matcher.rb
60
+ - lib/rspec-puppet/matchers/raise_error.rb
60
61
  - lib/rspec-puppet/matchers/run.rb
61
62
  - lib/rspec-puppet/matchers/type_matchers.rb
62
63
  - lib/rspec-puppet/monkey_patches.rb
@@ -65,6 +66,7 @@ files:
65
66
  - lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb
66
67
  - lib/rspec-puppet/rake_task.rb
67
68
  - lib/rspec-puppet/raw_string.rb
69
+ - lib/rspec-puppet/sensitive.rb
68
70
  - lib/rspec-puppet/setup.rb
69
71
  - lib/rspec-puppet/spec_helper.rb
70
72
  - lib/rspec-puppet/support.rb
@@ -88,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  - !ruby/object:Gem::Version
89
91
  version: '0'
90
92
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.7.6.2
93
+ rubygems_version: 3.0.3
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: RSpec tests for your Puppet manifests