rspec-puppet 2.6.0 → 2.7.0

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.
@@ -0,0 +1,271 @@
1
+ module RSpec
2
+ module Puppet
3
+ module Windows
4
+ module TaskSchedulerConstants
5
+ SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', "SYSTEM", 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', "USERS"].freeze
6
+
7
+ # Triggers
8
+
9
+ # Trigger is set to run the task a single time
10
+ TASK_TIME_TRIGGER_ONCE = 1
11
+
12
+ # Trigger is set to run the task on a daily interval
13
+ TASK_TIME_TRIGGER_DAILY = 2
14
+
15
+ # Trigger is set to run the task on specific days of a specific week & month
16
+ TASK_TIME_TRIGGER_WEEKLY = 3
17
+
18
+ # Trigger is set to run the task on specific day(s) of the month
19
+ TASK_TIME_TRIGGER_MONTHLYDATE = 4
20
+
21
+ # Trigger is set to run the task on specific day(s) of the month
22
+ TASK_TIME_TRIGGER_MONTHLYDOW = 5
23
+
24
+ # Trigger is set to run the task if the system remains idle for the amount
25
+ # of time specified by the idle wait time of the task
26
+ TASK_EVENT_TRIGGER_ON_IDLE = 6
27
+
28
+ TASK_TRIGGER_REGISTRATION = 7
29
+
30
+ # Trigger is set to run the task at system startup
31
+ TASK_EVENT_TRIGGER_AT_SYSTEMSTART = 8
32
+
33
+ # Trigger is set to run the task when a user logs on
34
+ TASK_EVENT_TRIGGER_AT_LOGON = 9
35
+
36
+ TASK_TRIGGER_SESSION_STATE_CHANGE = 11
37
+
38
+ # Daily Tasks
39
+
40
+ # The task will run on Sunday
41
+ TASK_SUNDAY = 0x1
42
+
43
+ # The task will run on Monday
44
+ TASK_MONDAY = 0x2
45
+
46
+ # The task will run on Tuesday
47
+ TASK_TUESDAY = 0x4
48
+
49
+ # The task will run on Wednesday
50
+ TASK_WEDNESDAY = 0x8
51
+
52
+ # The task will run on Thursday
53
+ TASK_THURSDAY = 0x10
54
+
55
+ # The task will run on Friday
56
+ TASK_FRIDAY = 0x20
57
+
58
+ # The task will run on Saturday
59
+ TASK_SATURDAY = 0x40
60
+
61
+ # Weekly tasks
62
+
63
+ # The task will run between the 1st and 7th day of the month
64
+ TASK_FIRST_WEEK = 0x01
65
+
66
+ # The task will run between the 8th and 14th day of the month
67
+ TASK_SECOND_WEEK = 0x02
68
+
69
+ # The task will run between the 15th and 21st day of the month
70
+ TASK_THIRD_WEEK = 0x04
71
+
72
+ # The task will run between the 22nd and 28th day of the month
73
+ TASK_FOURTH_WEEK = 0x08
74
+
75
+ # The task will run the last seven days of the month
76
+ TASK_LAST_WEEK = 0x10
77
+
78
+ # Monthly tasks
79
+
80
+ # The task will run in January
81
+ TASK_JANUARY = 0x1
82
+
83
+ # The task will run in February
84
+ TASK_FEBRUARY = 0x2
85
+
86
+ # The task will run in March
87
+ TASK_MARCH = 0x4
88
+
89
+ # The task will run in April
90
+ TASK_APRIL = 0x8
91
+
92
+ # The task will run in May
93
+ TASK_MAY = 0x10
94
+
95
+ # The task will run in June
96
+ TASK_JUNE = 0x20
97
+
98
+ # The task will run in July
99
+ TASK_JULY = 0x40
100
+
101
+ # The task will run in August
102
+ TASK_AUGUST = 0x80
103
+
104
+ # The task will run in September
105
+ TASK_SEPTEMBER = 0x100
106
+
107
+ # The task will run in October
108
+ TASK_OCTOBER = 0x200
109
+
110
+ # The task will run in November
111
+ TASK_NOVEMBER = 0x400
112
+
113
+ # The task will run in December
114
+ TASK_DECEMBER = 0x800
115
+
116
+ # Flags
117
+
118
+ # Used when converting AT service jobs into work items
119
+ TASK_FLAG_INTERACTIVE = 0x1
120
+
121
+ # The work item will be deleted when there are no more scheduled run times
122
+ TASK_FLAG_DELETE_WHEN_DONE = 0x2
123
+
124
+ # The work item is disabled. Useful for temporarily disabling a task
125
+ TASK_FLAG_DISABLED = 0x4
126
+
127
+ # The work item begins only if the computer is not in use at the scheduled
128
+ # start time
129
+ TASK_FLAG_START_ONLY_IF_IDLE = 0x10
130
+
131
+ # The work item terminates if the computer makes an idle to non-idle
132
+ # transition while the work item is running
133
+ TASK_FLAG_KILL_ON_IDLE_END = 0x20
134
+
135
+ # The work item does not start if the computer is running on battery power
136
+ TASK_FLAG_DONT_START_IF_ON_BATTERIES = 0x40
137
+
138
+ # The work item ends, and the associated application quits, if the computer
139
+ # switches to battery power
140
+ TASK_FLAG_KILL_IF_GOING_ON_BATTERIES = 0x80
141
+
142
+ # The work item starts only if the computer is in a docking station
143
+ TASK_FLAG_RUN_ONLY_IF_DOCKED = 0x100
144
+
145
+ # The work item created will be hidden
146
+ TASK_FLAG_HIDDEN = 0x200
147
+
148
+ # The work item runs only if there is a valid internet connection
149
+ TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = 0x400
150
+
151
+ # The work item starts again if the computer makes a non-idle to idle
152
+ # transition
153
+ TASK_FLAG_RESTART_ON_IDLE_RESUME = 0x800
154
+
155
+ # The work item causes the system to be resumed, or awakened, if the
156
+ # system is running on batter power
157
+ TASK_FLAG_SYSTEM_REQUIRED = 0x1000
158
+
159
+ # The work item runs only if a specified account is logged on interactively
160
+ TASK_FLAG_RUN_ONLY_IF_LOGGED_ON = 0x2000
161
+
162
+ # Triggers
163
+
164
+ # The task will stop at some point in time
165
+ TASK_TRIGGER_FLAG_HAS_END_DATE = 0x1
166
+
167
+ # The task can be stopped at the end of the repetition period
168
+ TASK_TRIGGER_FLAG_KILL_AT_DURATION_END = 0x2
169
+
170
+ # The task trigger is disabled
171
+ TASK_TRIGGER_FLAG_DISABLED = 0x4
172
+
173
+ # Run Level Types
174
+ # Tasks will be run with the least privileges
175
+ TASK_RUNLEVEL_LUA = 0
176
+ # Tasks will be run with the highest privileges
177
+ TASK_RUNLEVEL_HIGHEST = 1
178
+
179
+ # Logon Types
180
+ # Used for non-NT credentials
181
+ TASK_LOGON_NONE = 0
182
+ # Use a password for logging on the user
183
+ TASK_LOGON_PASSWORD = 1
184
+ # The service will log the user on using Service For User
185
+ TASK_LOGON_S4U = 2
186
+ # Task will be run only in an existing interactive session
187
+ TASK_LOGON_INTERACTIVE_TOKEN = 3
188
+ # Group activation. The groupId field specifies the group
189
+ TASK_LOGON_GROUP = 4
190
+ # When Local System, Local Service, or Network Service account is
191
+ # being used as a security context to run the task
192
+ TASK_LOGON_SERVICE_ACCOUNT = 5
193
+ # Not in use; currently identical to TASK_LOGON_PASSWORD
194
+ TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD = 6
195
+
196
+
197
+ TASK_MAX_RUN_TIMES = 1440
198
+ TASKS_TO_RETRIEVE = 5
199
+
200
+ # Task creation
201
+
202
+ TASK_VALIDATE_ONLY = 0x1
203
+ TASK_CREATE = 0x2
204
+ TASK_UPDATE = 0x4
205
+ TASK_CREATE_OR_UPDATE = 0x6
206
+ TASK_DISABLE = 0x8
207
+ TASK_DONT_ADD_PRINCIPAL_ACE = 0x10
208
+ TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20
209
+
210
+ # Priority classes
211
+
212
+ REALTIME_PRIORITY_CLASS = 0
213
+ HIGH_PRIORITY_CLASS = 1
214
+ ABOVE_NORMAL_PRIORITY_CLASS = 2 # Or 3
215
+ NORMAL_PRIORITY_CLASS = 4 # Or 5, 6
216
+ BELOW_NORMAL_PRIORITY_CLASS = 7 # Or 8
217
+ IDLE_PRIORITY_CLASS = 9 # Or 10
218
+
219
+ CLSCTX_INPROC_SERVER = 0x1
220
+ CLSID_CTask = [0x148BD520,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
221
+ CLSID_CTaskScheduler = [0x148BD52A,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
222
+ IID_ITaskScheduler = [0x148BD527,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
223
+ IID_ITask = [0x148BD524,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
224
+ IID_IPersistFile = [0x0000010b,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46].pack('LSSC8')
225
+
226
+ # Days of month
227
+
228
+ TASK_FIRST = 0x01
229
+ TASK_SECOND = 0x02
230
+ TASK_THIRD = 0x04
231
+ TASK_FOURTH = 0x08
232
+ TASK_FIFTH = 0x10
233
+ TASK_SIXTH = 0x20
234
+ TASK_SEVENTH = 0x40
235
+ TASK_EIGHTH = 0x80
236
+ TASK_NINETH = 0x100
237
+ TASK_TENTH = 0x200
238
+ TASK_ELEVENTH = 0x400
239
+ TASK_TWELFTH = 0x800
240
+ TASK_THIRTEENTH = 0x1000
241
+ TASK_FOURTEENTH = 0x2000
242
+ TASK_FIFTEENTH = 0x4000
243
+ TASK_SIXTEENTH = 0x8000
244
+ TASK_SEVENTEENTH = 0x10000
245
+ TASK_EIGHTEENTH = 0x20000
246
+ TASK_NINETEENTH = 0x40000
247
+ TASK_TWENTIETH = 0x80000
248
+ TASK_TWENTY_FIRST = 0x100000
249
+ TASK_TWENTY_SECOND = 0x200000
250
+ TASK_TWENTY_THIRD = 0x400000
251
+ TASK_TWENTY_FOURTH = 0x800000
252
+ TASK_TWENTY_FIFTH = 0x1000000
253
+ TASK_TWENTY_SIXTH = 0x2000000
254
+ TASK_TWENTY_SEVENTH = 0x4000000
255
+ TASK_TWENTY_EIGHTH = 0x8000000
256
+ TASK_TWENTY_NINTH = 0x10000000
257
+ TASK_THIRTYETH = 0x20000000
258
+ TASK_THIRTY_FIRST = 0x40000000
259
+ TASK_LAST = 0x80000000
260
+ end
261
+ end
262
+ end
263
+ end
264
+
265
+ begin
266
+ require 'win32/windows/constants'
267
+ rescue LoadError
268
+ module Windows
269
+ TaskSchedulerConstants = RSpec::Puppet::Windows::TaskSchedulerConstants
270
+ end
271
+ end
@@ -1,5 +1,61 @@
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
+
10
+ class RSpec::Puppet::EventListener
11
+ def self.example_started(example)
12
+ if rspec3?
13
+ @rspec_puppet_example = example.example.example_group.ancestors.include?(RSpec::Puppet::Support)
14
+ @current_example = example.example
15
+ if !@current_example.respond_to?(:environment) && @current_example.respond_to?(:example_group_instance)
16
+ @current_example = @current_example.example_group_instance
17
+ end
18
+ else
19
+ @rspec_puppet_example = example.example_group.ancestors.include?(RSpec::Puppet::Support)
20
+ @current_example = example
21
+ end
22
+ end
23
+
24
+ def self.example_passed(example)
25
+ @rspec_puppet_example = false
26
+ end
27
+
28
+ def self.example_pending(example)
29
+ @rspec_puppet_example = false
30
+ end
31
+
32
+ def self.example_failed(example)
33
+ @rspec_puppet_example = false
34
+ end
35
+
36
+ def self.rspec_puppet_example?
37
+ @rspec_puppet_example || false
38
+ end
39
+
40
+ def self.rspec3?
41
+ if @rspec3.nil?
42
+ @rspec3 = defined?(RSpec::Core::Notifications)
43
+ end
44
+
45
+ @rspec3
46
+ end
47
+
48
+ def self.current_example
49
+ @current_example
50
+ end
51
+ end
52
+
53
+ RSpec.configuration.reporter.register_listener(RSpec::Puppet::EventListener, :example_started, :example_pending, :example_passed, :example_failed)
54
+
55
+ require 'rspec-puppet/monkey_patches/win32/taskscheduler'
56
+ require 'rspec-puppet/monkey_patches/win32/registry'
57
+ require 'rspec-puppet/monkey_patches/windows/taskschedulerconstants'
58
+
3
59
  module Puppet
4
60
  # Allow rspec-puppet to prevent Puppet::Type from automatically picking
5
61
  # a provider for a resource. We need to do this because in order to fully
@@ -11,78 +67,113 @@ module Puppet
11
67
  old_set_default = instance_method(:set_default)
12
68
 
13
69
  define_method(:set_default) do |attr|
14
- old_posix = nil
15
- old_microsoft_windows = nil
70
+ if RSpec::Puppet.rspec_puppet_example?
71
+ old_posix = nil
72
+ old_microsoft_windows = nil
16
73
 
17
- if attr == :provider
18
- old_posix = Puppet.features.posix?
19
- old_microsoft_windows = Puppet.features.microsoft_windows?
74
+ if attr == :provider
75
+ old_posix = Puppet.features.posix?
76
+ old_microsoft_windows = Puppet.features.microsoft_windows?
20
77
 
21
- if Puppet::Util::Platform.pretend_windows?
22
- Puppet.features.add(:posix) { false }
23
- Puppet.features.add(:microsoft_windows) { true }
24
- else
25
- Puppet.features.add(:posix) { true }
26
- Puppet.features.add(:microsoft_windows) { false }
78
+ if Puppet::Util::Platform.pretend_windows?
79
+ Puppet.features.add(:posix) { false }
80
+ Puppet.features.add(:microsoft_windows) { true }
81
+ else
82
+ Puppet.features.add(:posix) { true }
83
+ Puppet.features.add(:microsoft_windows) { false }
84
+ end
27
85
  end
28
- end
29
-
30
- retval = old_set_default.bind(self).call(attr)
31
-
32
- unless old_posix.nil?
33
- Puppet.features.add(:posix) { old_posix }
34
- end
35
- unless old_microsoft_windows.nil?
36
- Puppet.features.add(:microsoft_windows) { old_microsoft_windows }
37
- end
38
86
 
39
- retval
40
- end
41
-
42
- def self.suppress_provider?
43
- @suppress_provider ||= false
44
- end
87
+ retval = old_set_default.bind(self).call(attr)
45
88
 
46
- def self.suppress_provider
47
- @suppress_provider = true
48
- end
89
+ unless old_posix.nil?
90
+ Puppet.features.add(:posix) { old_posix }
91
+ end
92
+ unless old_microsoft_windows.nil?
93
+ Puppet.features.add(:microsoft_windows) { old_microsoft_windows }
94
+ end
49
95
 
50
- def self.unsuppress_provider
51
- @suppress_provider = false
96
+ retval
97
+ else
98
+ old_set_default.bind(self).call(attr)
99
+ end
52
100
  end
53
101
  end
54
102
 
55
- # If Puppet::Node::Environment has a validate_dirs instance method (i.e.
56
- # Puppet < 3.x), wrap the method to check if rspec-puppet is pretending to be
57
- # running under windows. The original method uses Puppet::Util.absolute_path?
58
- # (which in turn calls Puppet::Util::Platform.windows?) to validate the path
59
- # to the manifests on disk during compilation, so we have to temporarily
60
- # disable the pretending when running it.
61
- class Node::Environment
62
- if instance_methods.include?("validate_dirs")
63
- old_validate_dirs = instance_method(:validate_dirs)
103
+ module Parser::Files
104
+ alias :old_find_manifests_in_modules :find_manifests_in_modules
105
+ module_function :old_find_manifests_in_modules
64
106
 
65
- define_method(:validate_dirs) do |dirs|
107
+ def find_manifests_in_modules(pattern, environment)
108
+ if RSpec::Puppet.rspec_puppet_example?
66
109
  pretending = Puppet::Util::Platform.pretend_platform
67
110
 
68
- if pretending
111
+ unless pretending.nil?
69
112
  Puppet::Util::Platform.pretend_to_be nil
113
+ RSpec::Puppet::Consts.stub_consts_for(RSpec.configuration.platform)
70
114
  end
71
115
 
72
- output = old_validate_dirs.bind(self).call(dirs)
116
+ if pretending && pretending != Puppet::Util::Platform.actual_platform
117
+ environment.send(:value_cache).clear if environment.respond_to?(:value_cache, true)
118
+ end
119
+ output = old_find_manifests_in_modules(pattern, environment)
73
120
 
74
- Puppet::Util::Platform.pretend_to_be pretending
121
+ unless pretending.nil?
122
+ Puppet::Util::Platform.pretend_to_be pretending
123
+ RSpec::Puppet::Consts.stub_consts_for pretending
124
+ end
75
125
 
76
126
  output
127
+ else
128
+ old_find_manifests_in_modules(pattern, environment)
77
129
  end
78
130
  end
131
+ module_function :find_manifests_in_modules
79
132
  end
80
133
 
81
134
  module Util
135
+ if respond_to?(:get_env)
136
+ alias :old_get_env :get_env
137
+ module_function :old_get_env
138
+
139
+ def get_env(name, mode = default_env)
140
+ if RSpec::Puppet.rspec_puppet_example?
141
+ # use the actual platform, not the pretended
142
+ old_get_env(name, Platform.actual_platform)
143
+ else
144
+ old_get_env(name, mode)
145
+ end
146
+ end
147
+ module_function :get_env
148
+ end
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
+
82
166
  # Allow rspec-puppet to pretend to be different platforms.
83
167
  module Platform
168
+ alias :old_windows? :windows?
169
+ module_function :old_windows?
170
+
84
171
  def windows?
85
- pretend_platform.nil? ? (actual_platform == :windows) : pretend_windows?
172
+ if RSpec::Puppet.rspec_puppet_example?
173
+ !pretending? ? (actual_platform == :windows) : pretend_windows?
174
+ else
175
+ old_windows?
176
+ end
86
177
  end
87
178
  module_function :windows?
88
179
 
@@ -91,6 +182,11 @@ module Puppet
91
182
  end
92
183
  module_function :actual_platform
93
184
 
185
+ def actually_windows?
186
+ actual_platform == :windows
187
+ end
188
+ module_function :actually_windows?
189
+
94
190
  def pretend_windows?
95
191
  pretend_platform == :windows
96
192
  end
@@ -109,6 +205,57 @@ module Puppet
109
205
  @pretend_platform ||= nil
110
206
  end
111
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
229
+ end
230
+ end
231
+
232
+ begin
233
+ require 'puppet/confine/exists'
234
+
235
+ class Confine::Exists < Puppet::Confine
236
+ old_pass = instance_method(:pass?)
237
+
238
+ define_method(:pass?) do |value|
239
+ if RSpec::Puppet.rspec_puppet_example?
240
+ true
241
+ else
242
+ old_pass.bind(self).call(value)
243
+ end
244
+ end
245
+ end
246
+ rescue LoadError
247
+ require 'puppet/provider/confine/exists'
248
+
249
+ class Provider::Confine::Exists < Puppet::Provider::Confine
250
+ old_pass = instance_method(:pass?)
251
+
252
+ define_method(:pass?) do |value|
253
+ if RSpec::Puppet.rspec_puppet_example?
254
+ true
255
+ else
256
+ old_pass.bind(self).call(value)
257
+ end
258
+ end
112
259
  end
113
260
  end
114
261
  end
@@ -127,12 +274,16 @@ class Pathname
127
274
  old_chop_basename = instance_method(:chop_basename)
128
275
 
129
276
  define_method(:chop_basename) do |path|
130
- if RSpec.configuration.enable_pathname_stubbing
131
- base = rspec_puppet_basename(path)
132
- if /\A#{SEPARATOR_PAT}?\z/o =~ base
133
- return nil
277
+ if RSpec::Puppet.rspec_puppet_example?
278
+ if RSpec.configuration.enable_pathname_stubbing
279
+ base = rspec_puppet_basename(path)
280
+ if /\A#{SEPARATOR_PAT}?\z/o =~ base
281
+ return nil
282
+ else
283
+ return path[0, path.rindex(base)], base
284
+ end
134
285
  else
135
- return path[0, path.rindex(base)], base
286
+ old_chop_basename.bind(self).call(path)
136
287
  end
137
288
  else
138
289
  old_chop_basename.bind(self).call(path)
@@ -143,12 +294,51 @@ end
143
294
 
144
295
  # Prevent the File type from munging paths (which uses File.expand_path to
145
296
  # normalise paths, which does very bad things to *nix paths on Windows.
146
- Puppet::Type.type(:file).paramclass(:path).munge { |value| value }
297
+ file_path_munge = Puppet::Type.type(:file).paramclass(:path).instance_method(:unsafe_munge)
298
+ Puppet::Type.type(:file).paramclass(:path).munge do |value|
299
+ if RSpec::Puppet.rspec_puppet_example?
300
+ value
301
+ else
302
+ file_path_munge.bind(self).call(value)
303
+ end
304
+ end
147
305
 
148
306
  # Prevent the Exec type from validating the user. This parameter isn't
149
307
  # supported under Windows at all and only under *nix when the current user is
150
308
  # root.
151
- Puppet::Type.type(:exec).paramclass(:user).validate { |value| true }
309
+ exec_user_validate = Puppet::Type.type(:exec).paramclass(:user).instance_method(:unsafe_validate)
310
+ Puppet::Type.type(:exec).paramclass(:user).validate do |value|
311
+ if RSpec::Puppet.rspec_puppet_example?
312
+ true
313
+ else
314
+ exec_user_validate.bind(self).call(value)
315
+ end
316
+ end
317
+
318
+ # Stub out Puppet::Util::Windows::Security.supports_acl? if it has been
319
+ # defined. This check only makes sense when applying the catalogue to a host
320
+ # and so can be safely stubbed out for unit testing.
321
+ Puppet::Type.type(:file).provide(:windows).class_eval do
322
+ old_supports_acl = instance_method(:supports_acl?) if respond_to?(:supports_acl?)
323
+
324
+ def supports_acl?(path)
325
+ if RSpec::Puppet.rspec_puppet_example?
326
+ true
327
+ else
328
+ old_supports_acl.bind(self).call(value)
329
+ end
330
+ end
331
+
332
+ old_manages_symlinks = instance_method(:manages_symlinks?) if respond_to?(:manages_symlinks?)
333
+
334
+ def manages_symlinks?
335
+ if RSpec::Puppet.rspec_puppet_example?
336
+ true
337
+ else
338
+ old_manages_symlinks.bind(self).call(value)
339
+ end
340
+ end
341
+ end
152
342
 
153
343
  # Prevent Puppet from requiring 'puppet/util/windows' if we're pretending to be
154
344
  # windows, otherwise it will require other libraries that probably won't be
@@ -156,7 +346,7 @@ Puppet::Type.type(:exec).paramclass(:user).validate { |value| true }
156
346
  module Kernel
157
347
  alias :old_require :require
158
348
  def require(path)
159
- return if path == 'puppet/util/windows' && Puppet::Util::Platform.pretend_windows?
349
+ return if (['puppet/util/windows', 'win32/registry'].include?(path)) && RSpec::Puppet.rspec_puppet_example? && Puppet::Util::Platform.pretend_windows?
160
350
  old_require(path)
161
351
  end
162
352
  end