rspec-puppet 2.6.15 → 2.7.0

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: '088bd4fad95b9e94e69fe9f830ca94f3a6dbec39'
4
- data.tar.gz: 01a0b23cb2688dca2e476ee1bd649e1a5e704423
3
+ metadata.gz: fe98cc153715d0f4a7ea74302e22db11b27f256b
4
+ data.tar.gz: 0ff2d613a201b5b50779674bc126904555203c66
5
5
  SHA512:
6
- metadata.gz: 29984636946f45bca01b6d4e3226ae8e5bc1d072ffc67a93cc179fec4d55e0386cc207626978f35317adf1696a612059921038235ce40cc617e9a227314e36be
7
- data.tar.gz: '018cc4710b3a32ffd647d3434c16c693f1fe3b9e552aee9b113740d1c5755b42496375d9dad72c41332e9e0d5c21f652a332c77009d4136fe1987158c4306290'
6
+ metadata.gz: 24db31229795fcfd326243a0b2fc20a17c78b6ee772f28092f9afd917534a3dd307d688c3934ef590c857027944c6fc9432baea652c7c4ecfbd40e563eb89dd1
7
+ data.tar.gz: 50fa9b5882460e10e4148c4b78372b3f366178738fe5fa92dfee522e8b4811a5378156623e0f6d13e030c912f9a5560d6f4051e0cd7aa7a249c59600a55fe20f
@@ -2,6 +2,16 @@
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.0]
6
+
7
+ ### Changed
8
+ * Official Puppet 6 support added.
9
+ * When testing resource parameter values, the values received from Puppet are
10
+ now reencoded before testing to ensure that the line endings (if present)
11
+ match the platform being tested.
12
+ * `vendormoduledir` and `basemodulepath` settings (introduced in Puppet 6) are
13
+ now configurable in rspec-puppet.
14
+
5
15
  ## [2.6.15]
6
16
 
7
17
  ### Fixed
@@ -52,6 +52,8 @@ RSpec.configure do |c|
52
52
  c.add_setting :derive_node_facts_from_nodename, :default => true
53
53
  c.add_setting :adapter
54
54
  c.add_setting :platform, :default => Puppet::Util::Platform.actual_platform
55
+ c.add_setting :vendormoduledir, :default => Puppet::Util::Platform.actually_windows? ? 'c:/nul/' : '/dev/null'
56
+ c.add_setting :basemodulepath, :default => Puppet::Util::Platform.actually_windows? ? 'c:/nul/' : '/dev/null'
55
57
 
56
58
  c.instance_eval do
57
59
  def trusted_server_facts
@@ -192,7 +192,14 @@ module RSpec::Puppet
192
192
  end
193
193
  end
194
194
 
195
- class Adapter6X < Adapter40; end
195
+ class Adapter6X < Adapter40
196
+ def settings_map
197
+ super.concat([
198
+ [:basemodulepath, :basemodulepath],
199
+ [:vendormoduledir, :vendormoduledir],
200
+ ])
201
+ end
202
+ end
196
203
 
197
204
  class Adapter30 < Base
198
205
  def settings_map
@@ -12,10 +12,25 @@ module RSpec::Puppet::Consts
12
12
  }
13
13
  }
14
14
 
15
+ FEATURES = {
16
+ :posix => {
17
+ :posix => true,
18
+ :microsoft_windows => false,
19
+ },
20
+ :windows => {
21
+ :posix => false,
22
+ :microsoft_windows => true,
23
+ },
24
+ }
25
+
15
26
  def self.stub_consts_for(platform)
16
27
  STUBBED_CONSTS[platform].each do |const_name, const_value|
17
28
  stub_const_wrapper(const_name, const_value)
18
29
  end
30
+ Puppet::Util::Platform.pretend_to_be(platform)
31
+ FEATURES[platform].each do |feature_name, feature_value|
32
+ Puppet.features.add(feature_name) { feature_value }
33
+ end
19
34
  end
20
35
 
21
36
  def self.stub_const_wrapper(const, value)
@@ -28,4 +43,15 @@ module RSpec::Puppet::Consts
28
43
  def self.restore_consts
29
44
  stub_consts_for(RSpec.configuration.platform)
30
45
  end
46
+
47
+ def self.without_stubs
48
+ if Puppet::Util::Platform.pretending?
49
+ pretend_platform = Puppet::Util::Platform.pretend_platform
50
+ restore_consts
51
+ end
52
+
53
+ yield
54
+ ensure
55
+ stub_consts_for(pretend_platform) if pretend_platform
56
+ end
31
57
  end
@@ -138,7 +138,6 @@ module RSpec::Puppet
138
138
  end
139
139
 
140
140
  def cycles_found?
141
- Puppet::Type.suppress_provider
142
141
  cat = @catalogue.to_ral.relationship_graph
143
142
  cat.write_graph(:resources)
144
143
  if cat.respond_to? :find_cycles_in_graph
@@ -146,7 +145,6 @@ module RSpec::Puppet
146
145
  else
147
146
  find_cycles_legacy(cat)
148
147
  end
149
- Puppet::Type.unsuppress_provider
150
148
 
151
149
  !@cycles.empty?
152
150
  end
@@ -294,7 +294,6 @@ module RSpec::Puppet
294
294
  end
295
295
  end
296
296
 
297
- Puppet::Type.suppress_provider
298
297
  # Add autorequires if any
299
298
  if type == :require and resource.resource_type.respond_to? :eachautorequire
300
299
  resource.resource_type.eachautorequire do |t, b|
@@ -307,7 +306,6 @@ module RSpec::Puppet
307
306
  end
308
307
  end
309
308
  end
310
- Puppet::Type.unsuppress_provider
311
309
 
312
310
  results.flatten
313
311
  end
@@ -78,7 +78,7 @@ module RSpec::Puppet
78
78
  end
79
79
 
80
80
  def check_regexp(expected, actual)
81
- !!(actual.to_s.match expected) == @should_match
81
+ !!(munge_line_endings(actual.to_s).match expected) == @should_match
82
82
  end
83
83
 
84
84
  # Ensure that two hashes have the same number of keys, and that for each
@@ -119,7 +119,17 @@ module RSpec::Puppet
119
119
  end
120
120
 
121
121
  def check_string(expected, actual)
122
- (expected.to_s == actual.to_s) == @should_match
122
+ (expected.to_s == munge_line_endings(actual.to_s)) == @should_match
123
+ end
124
+
125
+ def munge_line_endings(value)
126
+ return value unless value.respond_to?(:encode)
127
+
128
+ if Puppet::Util::Platform.windows?
129
+ value.encode(:crlf_newline => true)
130
+ else
131
+ value.encode(:universal_newline => true)
132
+ end
123
133
  end
124
134
  end
125
135
  end
@@ -98,18 +98,6 @@ module Puppet
98
98
  old_set_default.bind(self).call(attr)
99
99
  end
100
100
  end
101
-
102
- def self.suppress_provider?
103
- @suppress_provider ||= false
104
- end
105
-
106
- def self.suppress_provider
107
- @suppress_provider = true
108
- end
109
-
110
- def self.unsuppress_provider
111
- @suppress_provider = false
112
- end
113
101
  end
114
102
 
115
103
  module Parser::Files
@@ -159,6 +147,22 @@ module Puppet
159
147
  module_function :get_env
160
148
  end
161
149
 
150
+ if respond_to?(:path_to_uri)
151
+ alias :old_path_to_uri :path_to_uri
152
+ module_function :old_path_to_uri
153
+
154
+ def path_to_uri(*args)
155
+ if RSpec::Puppet.rspec_puppet_example?
156
+ RSpec::Puppet::Consts.without_stubs do
157
+ old_path_to_uri(*args)
158
+ end
159
+ else
160
+ old_path_to_uri(*args)
161
+ end
162
+ end
163
+ module_function :path_to_uri
164
+ end
165
+
162
166
  # Allow rspec-puppet to pretend to be different platforms.
163
167
  module Platform
164
168
  alias :old_windows? :windows?
@@ -166,7 +170,7 @@ module Puppet
166
170
 
167
171
  def windows?
168
172
  if RSpec::Puppet.rspec_puppet_example?
169
- pretend_platform.nil? ? (actual_platform == :windows) : pretend_windows?
173
+ !pretending? ? (actual_platform == :windows) : pretend_windows?
170
174
  else
171
175
  old_windows?
172
176
  end
@@ -201,6 +205,27 @@ module Puppet
201
205
  @pretend_platform ||= nil
202
206
  end
203
207
  module_function :pretend_platform
208
+
209
+ def pretending?
210
+ !pretend_platform.nil?
211
+ end
212
+ module_function :pretending?
213
+ end
214
+
215
+ class Autoload
216
+ if singleton_class.respond_to?(:load_file)
217
+ singleton_class.send(:alias_method, :old_load_file, :load_file)
218
+
219
+ def self.load_file(*args)
220
+ if RSpec::Puppet.rspec_puppet_example?
221
+ RSpec::Puppet::Consts.without_stubs do
222
+ old_load_file(*args)
223
+ end
224
+ else
225
+ old_load_file(*args)
226
+ end
227
+ end
228
+ end
204
229
  end
205
230
  end
206
231
 
@@ -408,7 +408,7 @@ module RSpec::Puppet
408
408
  end
409
409
 
410
410
  def stub_facts!(facts)
411
- Puppet.settings[:autosign] = false
411
+ Puppet.settings[:autosign] = false if Puppet.settings.include? :autosign
412
412
  Facter.clear
413
413
  facts.each { |k, v| Facter.add(k, :weight => 999) { setcode { v } } }
414
414
  end
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.15
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-13 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec