chef 16.3.45-universal-mingw32 → 16.4.35-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/chef-universal-mingw32.gemspec +0 -1
  3. data/lib/chef/action_collection.rb +4 -0
  4. data/lib/chef/api_client/registration.rb +2 -2
  5. data/lib/chef/application.rb +1 -1
  6. data/lib/chef/application/apply.rb +5 -5
  7. data/lib/chef/application/windows_service.rb +27 -27
  8. data/lib/chef/chef_class.rb +0 -1
  9. data/lib/chef/chef_fs/chef_fs_data_store.rb +54 -54
  10. data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +10 -10
  11. data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +8 -8
  12. data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +8 -8
  13. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  14. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +18 -18
  16. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  18. data/lib/chef/client.rb +11 -11
  19. data/lib/chef/data_collector/run_end_message.rb +11 -1
  20. data/lib/chef/dsl/platform_introspection.rb +8 -8
  21. data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
  22. data/lib/chef/environment.rb +2 -2
  23. data/lib/chef/exceptions.rb +1 -1
  24. data/lib/chef/file_content_management/tempfile.rb +9 -9
  25. data/lib/chef/http.rb +2 -1
  26. data/lib/chef/json_compat.rb +1 -1
  27. data/lib/chef/knife/bootstrap.rb +2 -2
  28. data/lib/chef/knife/cookbook_download.rb +1 -1
  29. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  30. data/lib/chef/knife/cookbook_upload.rb +23 -23
  31. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  32. data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
  33. data/lib/chef/knife/core/windows_bootstrap_context.rb +32 -24
  34. data/lib/chef/knife/delete.rb +15 -15
  35. data/lib/chef/knife/exec.rb +2 -2
  36. data/lib/chef/knife/ssh.rb +6 -6
  37. data/lib/chef/knife/xargs.rb +19 -19
  38. data/lib/chef/knife/yaml_convert.rb +1 -1
  39. data/lib/chef/mixin/checksum.rb +0 -1
  40. data/lib/chef/mixin/deep_merge.rb +35 -6
  41. data/lib/chef/mixin/openssl_helper.rb +3 -1
  42. data/lib/chef/mixin/shell_out.rb +1 -1
  43. data/lib/chef/mixin/which.rb +1 -1
  44. data/lib/chef/monkey_patches/webrick-utils.rb +10 -10
  45. data/lib/chef/node/attribute.rb +2 -4
  46. data/lib/chef/platform/service_helpers.rb +1 -1
  47. data/lib/chef/property.rb +1 -1
  48. data/lib/chef/provider/cron/unix.rb +0 -2
  49. data/lib/chef/provider/git.rb +5 -5
  50. data/lib/chef/provider/group.rb +0 -2
  51. data/lib/chef/provider/group/suse.rb +5 -5
  52. data/lib/chef/provider/ifconfig.rb +1 -4
  53. data/lib/chef/provider/mount.rb +0 -2
  54. data/lib/chef/provider/package.rb +0 -2
  55. data/lib/chef/provider/package/rubygems.rb +1 -1
  56. data/lib/chef/provider/package/snap.rb +1 -1
  57. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +9 -9
  58. data/lib/chef/provider/powershell_script.rb +21 -5
  59. data/lib/chef/provider/route.rb +1 -1
  60. data/lib/chef/provider/service/arch.rb +1 -1
  61. data/lib/chef/provider/service/debian.rb +1 -1
  62. data/lib/chef/provider/service/gentoo.rb +2 -2
  63. data/lib/chef/provider/service/macosx.rb +2 -2
  64. data/lib/chef/provider/service/openbsd.rb +1 -4
  65. data/lib/chef/provider/service/redhat.rb +2 -2
  66. data/lib/chef/provider/service/upstart.rb +1 -1
  67. data/lib/chef/provider/service/windows.rb +10 -10
  68. data/lib/chef/provider/systemd_unit.rb +0 -2
  69. data/lib/chef/provider/template/content.rb +1 -0
  70. data/lib/chef/provider/user/dscl.rb +2 -2
  71. data/lib/chef/provider/user/mac.rb +9 -9
  72. data/lib/chef/provider/windows_task.rb +0 -3
  73. data/lib/chef/provider/zypper_repository.rb +0 -1
  74. data/lib/chef/providers.rb +0 -1
  75. data/lib/chef/recipe.rb +1 -1
  76. data/lib/chef/resource.rb +6 -10
  77. data/lib/chef/resource/apt_repository.rb +1 -10
  78. data/lib/chef/resource/chef_client_systemd_timer.rb +2 -2
  79. data/lib/chef/resource/chef_vault_secret.rb +13 -13
  80. data/lib/chef/resource/execute.rb +2 -3
  81. data/lib/chef/resource/homebrew_update.rb +2 -2
  82. data/lib/chef/resource/openssl_dhparam.rb +2 -0
  83. data/lib/chef/resource/openssl_ec_private_key.rb +2 -0
  84. data/lib/chef/resource/openssl_ec_public_key.rb +2 -0
  85. data/lib/chef/resource/openssl_rsa_private_key.rb +2 -0
  86. data/lib/chef/resource/openssl_rsa_public_key.rb +2 -0
  87. data/lib/chef/resource/openssl_x509_certificate.rb +24 -21
  88. data/lib/chef/resource/openssl_x509_crl.rb +2 -0
  89. data/lib/chef/resource/openssl_x509_request.rb +23 -20
  90. data/lib/chef/resource/osx_profile.rb +227 -5
  91. data/lib/chef/resource/powershell_package_source.rb +1 -1
  92. data/lib/chef/resource/powershell_script.rb +24 -30
  93. data/lib/chef/resource/sudo.rb +1 -1
  94. data/lib/chef/resource/sysctl.rb +5 -5
  95. data/lib/chef/resource/windows_ad_join.rb +2 -0
  96. data/lib/chef/resource/windows_audit_policy.rb +3 -0
  97. data/lib/chef/resource/windows_auto_run.rb +2 -0
  98. data/lib/chef/resource/windows_certificate.rb +2 -0
  99. data/lib/chef/resource/windows_dfs_folder.rb +2 -0
  100. data/lib/chef/resource/windows_dfs_namespace.rb +2 -0
  101. data/lib/chef/resource/windows_dfs_server.rb +2 -0
  102. data/lib/chef/resource/windows_dns_record.rb +10 -7
  103. data/lib/chef/resource/windows_dns_zone.rb +12 -7
  104. data/lib/chef/resource/windows_feature.rb +2 -0
  105. data/lib/chef/resource/windows_feature_dism.rb +10 -0
  106. data/lib/chef/resource/windows_feature_powershell.rb +14 -2
  107. data/lib/chef/resource/windows_firewall_profile.rb +4 -2
  108. data/lib/chef/resource/windows_firewall_rule.rb +5 -3
  109. data/lib/chef/resource/windows_font.rb +3 -1
  110. data/lib/chef/resource/windows_pagefile.rb +4 -0
  111. data/lib/chef/resource/windows_printer.rb +17 -18
  112. data/lib/chef/resource/windows_printer_port.rb +14 -13
  113. data/lib/chef/resource/windows_security_policy.rb +2 -0
  114. data/lib/chef/resource/windows_share.rb +5 -3
  115. data/lib/chef/resource/windows_shortcut.rb +2 -0
  116. data/lib/chef/resource/windows_uac.rb +2 -0
  117. data/lib/chef/resource/windows_user_privilege.rb +2 -0
  118. data/lib/chef/resource/windows_workgroup.rb +2 -3
  119. data/lib/chef/resource_collection/stepable_iterator.rb +1 -2
  120. data/lib/chef/role.rb +2 -2
  121. data/lib/chef/run_context/cookbook_compiler.rb +20 -20
  122. data/lib/chef/run_status.rb +2 -6
  123. data/lib/chef/shell.rb +1 -1
  124. data/lib/chef/util/backup.rb +1 -1
  125. data/lib/chef/util/diff.rb +11 -11
  126. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  127. data/lib/chef/version.rb +1 -1
  128. data/lib/chef/win32/file.rb +2 -2
  129. data/lib/chef/win32/file/version_info.rb +5 -5
  130. data/spec/data/ssl/chef-rspec.cert +15 -15
  131. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  132. data/spec/functional/resource/bff_spec.rb +2 -2
  133. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  134. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  135. data/spec/functional/resource/dsc_script_spec.rb +0 -1
  136. data/spec/functional/resource/group_spec.rb +6 -6
  137. data/spec/functional/resource/insserv_spec.rb +4 -4
  138. data/spec/functional/resource/link_spec.rb +20 -20
  139. data/spec/functional/resource/powershell_script_spec.rb +4 -4
  140. data/spec/functional/resource/rpm_spec.rb +2 -2
  141. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  142. data/spec/functional/resource/windows_font_spec.rb +49 -0
  143. data/spec/functional/resource/windows_security_policy_spec.rb +0 -3
  144. data/spec/functional/run_lock_spec.rb +24 -24
  145. data/spec/functional/win32/registry_spec.rb +8 -8
  146. data/spec/functional/win32/service_manager_spec.rb +1 -1
  147. data/spec/integration/knife/common_options_spec.rb +12 -12
  148. data/spec/integration/knife/config_get_profile_spec.rb +69 -68
  149. data/spec/integration/knife/config_get_spec.rb +126 -125
  150. data/spec/integration/knife/config_list_profiles_spec.rb +181 -180
  151. data/spec/integration/knife/config_use_profile_spec.rb +110 -109
  152. data/spec/integration/knife/diff_spec.rb +3 -1
  153. data/spec/integration/knife/download_spec.rb +3 -1
  154. data/spec/integration/knife/serve_spec.rb +5 -5
  155. data/spec/integration/knife/upload_spec.rb +3 -1
  156. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  157. data/spec/spec_helper.rb +6 -6
  158. data/spec/support/platform_helpers.rb +9 -9
  159. data/spec/support/platforms/win32/spec_service.rb +1 -1
  160. data/spec/support/shared/functional/directory_resource.rb +1 -1
  161. data/spec/support/shared/functional/execute_resource.rb +1 -1
  162. data/spec/support/shared/functional/file_resource.rb +20 -20
  163. data/spec/support/shared/functional/win32_service.rb +1 -1
  164. data/spec/support/shared/functional/windows_script.rb +3 -3
  165. data/spec/support/shared/integration/integration_helper.rb +22 -52
  166. data/spec/support/shared/unit/script_resource.rb +6 -20
  167. data/spec/support/shared/unit/windows_script_resource.rb +15 -28
  168. data/spec/unit/data_collector_spec.rb +22 -0
  169. data/spec/unit/environment_spec.rb +7 -7
  170. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  171. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  172. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  173. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  174. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +21 -12
  175. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  176. data/spec/unit/mixin/template_spec.rb +30 -30
  177. data/spec/unit/mixin/windows_architecture_helper_spec.rb +4 -4
  178. data/spec/unit/node/immutable_collections_spec.rb +6 -2
  179. data/spec/unit/node_spec.rb +5 -5
  180. data/spec/unit/provider/powershell_script_spec.rb +11 -4
  181. data/spec/unit/provider/remote_directory_spec.rb +9 -9
  182. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  183. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  184. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  185. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  186. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  187. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  188. data/spec/unit/provider_resolver_spec.rb +6 -6
  189. data/spec/unit/resource/batch_spec.rb +6 -6
  190. data/spec/unit/resource/execute_spec.rb +113 -118
  191. data/spec/unit/resource/osx_profile_spec.rb +233 -0
  192. data/spec/unit/resource/powershell_script_spec.rb +11 -29
  193. data/spec/unit/resource/script_spec.rb +6 -1
  194. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  195. data/spec/unit/role_spec.rb +11 -11
  196. data/tasks/rspec.rb +1 -1
  197. metadata +7 -22
  198. data/lib/chef/provider/osx_profile.rb +0 -255
  199. data/spec/unit/provider/osx_profile_spec.rb +0 -255
@@ -318,7 +318,9 @@ describe "knife diff", :workstation do
318
318
  end
319
319
  end # without versioned cookbooks
320
320
 
321
- with_versioned_cookbooks do
321
+ context "with versioned cookbooks" do
322
+ before { Chef::Config[:versioned_cookbooks] = true }
323
+
322
324
  when_the_chef_server "has one of each thing" do
323
325
  before do
324
326
  client "x", "{}"
@@ -594,7 +594,9 @@ describe "knife download", :workstation do
594
594
  end
595
595
  end # without versioned cookbooks
596
596
 
597
- with_versioned_cookbooks do
597
+ context "with versioned cookbooks" do
598
+ before { Chef::Config[:versioned_cookbooks] = true }
599
+
598
600
  when_the_chef_server "has one of each thing" do
599
601
  before do
600
602
  client "x", {}
@@ -26,11 +26,11 @@ describe "knife serve", :workstation do
26
26
  def with_knife_serve
27
27
  exception = nil
28
28
  t = Thread.new do
29
- begin
30
- knife("serve --chef-zero-port=8890")
31
- rescue
32
- exception = $!
33
- end
29
+
30
+ knife("serve --chef-zero-port=8890")
31
+ rescue
32
+ exception = $!
33
+
34
34
  end
35
35
  begin
36
36
  Chef::Config.log_level = :debug
@@ -800,7 +800,9 @@ describe "knife upload", :workstation do
800
800
  end
801
801
  end # without versioned cookbooks
802
802
 
803
- with_versioned_cookbooks do
803
+ context "with versioned cookbooks" do
804
+ before { Chef::Config[:versioned_cookbooks] = true }
805
+
804
806
  when_the_chef_server "has one of each thing" do
805
807
 
806
808
  before do
@@ -59,7 +59,7 @@ describe "LWRPs with inline resources" do
59
59
  end
60
60
  end
61
61
 
62
- after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exists?(LwrpShadowedPropertyTest::PATH) }
62
+ after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exist?(LwrpShadowedPropertyTest::PATH) }
63
63
 
64
64
  # https://github.com/chef/chef/issues/4334
65
65
  it "does not warn spuriously" do
@@ -68,7 +68,7 @@ end
68
68
 
69
69
  # If you want to load anything into the testing environment
70
70
  # without versioning it, add it to spec/support/local_gems.rb
71
- require "spec/support/local_gems.rb" if File.exists?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
71
+ require "spec/support/local_gems.rb" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
72
72
 
73
73
  # Explicitly require spec helpers that need to load first
74
74
  require "spec/support/platform_helpers"
@@ -297,11 +297,11 @@ RSpec.configure do |config|
297
297
 
298
298
  # Protect Rspec from accidental exit(0) causing rspec to terminate without error
299
299
  config.around(:example) do |ex|
300
- begin
301
- ex.run
302
- rescue SystemExit => e
303
- raise UnexpectedSystemExit.from(e)
304
- end
300
+
301
+ ex.run
302
+ rescue SystemExit => e
303
+ raise UnexpectedSystemExit.from(e)
304
+
305
305
  end
306
306
  end
307
307
 
@@ -105,7 +105,7 @@ def mac_osx_1014?
105
105
  end
106
106
 
107
107
  def mac_osx?
108
- if File.exists? "/usr/bin/sw_vers"
108
+ if File.exist? "/usr/bin/sw_vers"
109
109
  result = ShellHelpers.shell_out("/usr/bin/sw_vers")
110
110
  result.stdout.each_line do |line|
111
111
  if /^ProductName:\sMac OS X.*$/.match?(line)
@@ -134,19 +134,19 @@ def unix?
134
134
  end
135
135
 
136
136
  def linux?
137
- !!(RUBY_PLATFORM =~ /linux/)
137
+ RUBY_PLATFORM.match?(/linux/)
138
138
  end
139
139
 
140
- def os_x?
141
- !!(RUBY_PLATFORM =~ /darwin/)
140
+ def macos?
141
+ RUBY_PLATFORM.match?(/darwin/)
142
142
  end
143
143
 
144
144
  def solaris?
145
- !!(RUBY_PLATFORM =~ /solaris/)
145
+ RUBY_PLATFORM.match?(/solaris/)
146
146
  end
147
147
 
148
148
  def freebsd?
149
- !!(RUBY_PLATFORM =~ /freebsd/)
149
+ RUBY_PLATFORM.match?(/freebsd/)
150
150
  end
151
151
 
152
152
  def intel_64bit?
@@ -182,7 +182,7 @@ def debian_family?
182
182
  end
183
183
 
184
184
  def aix?
185
- !!(RUBY_PLATFORM =~ /aix/)
185
+ RUBY_PLATFORM.match?(/aix/)
186
186
  end
187
187
 
188
188
  def wpar?
@@ -216,8 +216,8 @@ def selinux_enabled?
216
216
  end
217
217
 
218
218
  def suse?
219
- ::File.exists?("/etc/SuSE-release") ||
220
- ( ::File.exists?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
219
+ ::File.exist?("/etc/SuSE-release") ||
220
+ ( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
221
221
  end
222
222
 
223
223
  def root?
@@ -26,7 +26,7 @@ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
26
26
 
27
27
  def service_main(*startup_parameters)
28
28
  while running?
29
- unless File.exists?(@test_service_file)
29
+ unless File.exist?(@test_service_file)
30
30
  File.open(@test_service_file, "wb") do |f|
31
31
  f.write("This file is created by SpecService")
32
32
  end
@@ -173,6 +173,6 @@ shared_context Chef::Resource::Directory do
173
173
  end
174
174
 
175
175
  after(:each) do
176
- FileUtils.rm_r(path) if File.exists?(path)
176
+ FileUtils.rm_r(path) if File.exist?(path)
177
177
  end
178
178
  end
@@ -62,7 +62,7 @@ shared_context "a command that can be executed as an alternate user" do
62
62
  end
63
63
 
64
64
  after do
65
- File.delete(script_output_path) if File.exists?(script_output_path)
65
+ File.delete(script_output_path) if File.exist?(script_output_path)
66
66
  Dir.rmdir(script_output_dir) if Dir.exist?(script_output_dir)
67
67
  end
68
68
  end
@@ -476,12 +476,12 @@ shared_examples_for "a configured file resource" do
476
476
  end
477
477
 
478
478
  it "issues a warning/assumption in whyrun mode" do
479
- begin
480
- Chef::Config[:why_run] = true
481
- resource.run_action(:create) # should not raise
482
- ensure
483
- Chef::Config[:why_run] = false
484
- end
479
+
480
+ Chef::Config[:why_run] = true
481
+ resource.run_action(:create) # should not raise
482
+ ensure
483
+ Chef::Config[:why_run] = false
484
+
485
485
  end
486
486
  end
487
487
 
@@ -504,12 +504,12 @@ shared_examples_for "a configured file resource" do
504
504
  end
505
505
 
506
506
  it "issues a warning/assumption in whyrun mode" do
507
- begin
508
- Chef::Config[:why_run] = true
509
- resource.run_action(:create) # should not raise
510
- ensure
511
- Chef::Config[:why_run] = false
512
- end
507
+
508
+ Chef::Config[:why_run] = true
509
+ resource.run_action(:create) # should not raise
510
+ ensure
511
+ Chef::Config[:why_run] = false
512
+
513
513
  end
514
514
  end
515
515
 
@@ -535,12 +535,12 @@ shared_examples_for "a configured file resource" do
535
535
  end
536
536
 
537
537
  it "issues a warning/assumption in whyrun mode" do
538
- begin
539
- Chef::Config[:why_run] = true
540
- resource.run_action(:create) # should not raise
541
- ensure
542
- Chef::Config[:why_run] = false
543
- end
538
+
539
+ Chef::Config[:why_run] = true
540
+ resource.run_action(:create) # should not raise
541
+ ensure
542
+ Chef::Config[:why_run] = false
543
+
544
544
  end
545
545
  end
546
546
 
@@ -1037,8 +1037,8 @@ shared_context Chef::Resource::File do
1037
1037
  end
1038
1038
 
1039
1039
  after(:each) do
1040
- FileUtils.rm_r(path) if File.exists?(path)
1041
- FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
1040
+ FileUtils.rm_r(path) if File.exist?(path)
1041
+ FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
1042
1042
  end
1043
1043
 
1044
1044
  after do
@@ -30,7 +30,7 @@ shared_context "using Win32::Service" do
30
30
  end
31
31
 
32
32
  # Delete the test_service_file if it exists
33
- if File.exists?(test_service_file)
33
+ if File.exist?(test_service_file)
34
34
  File.delete(test_service_file)
35
35
  end
36
36
  end
@@ -39,11 +39,11 @@ shared_context Chef::Resource::WindowsScript do
39
39
  end
40
40
 
41
41
  before(:each) do
42
- File.delete(script_output_path) if File.exists?(script_output_path)
42
+ File.delete(script_output_path) if File.exist?(script_output_path)
43
43
  end
44
44
 
45
45
  after(:each) do
46
- File.delete(script_output_path) if File.exists?(script_output_path)
46
+ File.delete(script_output_path) if File.exist?(script_output_path)
47
47
  end
48
48
 
49
49
  shared_examples_for "a script resource with architecture attribute" do
@@ -138,7 +138,7 @@ shared_context Chef::Resource::WindowsScript do
138
138
 
139
139
  after do
140
140
  script_file.close! if script_file
141
- ::File.delete(script_file.to_path) if script_file && ::File.exists?(script_file.to_path)
141
+ ::File.delete(script_file.to_path) if script_file && ::File.exist?(script_file.to_path)
142
142
  end
143
143
 
144
144
  include_context "alternate user identity"
@@ -44,15 +44,30 @@ module IntegrationSupport
44
44
 
45
45
  def when_the_repository(desc, *tags, &block)
46
46
  context("when the chef repo #{desc}", *tags) do
47
- include_context "with a chef repo"
47
+ before :each do
48
+ raise "Can only create one directory per test" if @repository_dir
48
49
 
49
- module_eval(&block)
50
- end
51
- end
50
+ @repository_dir = Dir.mktmpdir("chef_repo")
51
+ Chef::Config.chef_repo_path = @repository_dir
52
+ %w{client cookbook data_bag environment node role user}.each do |object_name|
53
+ Chef::Config.delete("#{object_name}_path".to_sym)
54
+ end
55
+ end
56
+
57
+ after :each do
58
+ if @repository_dir
59
+ begin
60
+ # TODO: "force" actually means "silence all exceptions". this
61
+ # silences a weird permissions error on Windows that we should track
62
+ # down, but for now there's no reason for it to blow up our CI.
63
+ FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
64
+ ensure
65
+ @repository_dir = nil
66
+ end
67
+ end
68
+ Dir.chdir(@old_cwd) if @old_cwd
69
+ end
52
70
 
53
- def with_versioned_cookbooks(&block)
54
- context("with versioned cookbooks") do
55
- include_context "with versioned cookbooks"
56
71
  module_eval(&block)
57
72
  end
58
73
  end
@@ -105,49 +120,4 @@ module IntegrationSupport
105
120
  @old_cwd = Dir.pwd
106
121
  Dir.chdir(path_to(relative_path))
107
122
  end
108
-
109
- RSpec.shared_context "with a chef repo" do
110
- before :each do
111
- raise "Can only create one directory per test" if @repository_dir
112
-
113
- @repository_dir = Dir.mktmpdir("chef_repo")
114
- Chef::Config.chef_repo_path = @repository_dir
115
- %w{client cookbook data_bag environment node role user}.each do |object_name|
116
- Chef::Config.delete("#{object_name}_path".to_sym)
117
- end
118
- end
119
-
120
- after :each do
121
- if @repository_dir
122
- begin
123
- %w{client cookbook data_bag environment node role user}.each do |object_name|
124
- Chef::Config.delete("#{object_name}_path".to_sym)
125
- end
126
- Chef::Config.delete(:chef_repo_path)
127
- # TODO: "force" actually means "silence all exceptions". this
128
- # silences a weird permissions error on Windows that we should track
129
- # down, but for now there's no reason for it to blow up our CI.
130
- FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
131
- ensure
132
- @repository_dir = nil
133
- end
134
- end
135
- Dir.chdir(@old_cwd) if @old_cwd
136
- end
137
-
138
- end
139
-
140
- # Versioned cookbooks
141
-
142
- RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do
143
- before(:each) { Chef::Config[:versioned_cookbooks] = true }
144
- after(:each) { Chef::Config.delete(:versioned_cookbooks) }
145
- end
146
-
147
- RSpec.shared_context "without versioned cookbooks", versioned_cookbooks: false do
148
- # Just make sure this goes back to default
149
- before(:each) { Chef::Config[:versioned_cookbooks] = false }
150
- after(:each) { Chef::Config.delete(:versioned_cookbooks) }
151
- end
152
-
153
123
  end
@@ -47,21 +47,6 @@ shared_examples_for "a script resource" do
47
47
  end
48
48
 
49
49
  describe "when executing guards" do
50
- let(:resource) do
51
- resource = script_resource
52
- resource.run_context = run_context
53
- resource.code "echo hi"
54
- resource
55
- end
56
- let(:node) do
57
- node = Chef::Node.new
58
- node.automatic[:platform] = "debian"
59
- node.automatic[:platform_version] = "6.0"
60
- node
61
- end
62
- let(:events) { Chef::EventDispatch::Dispatcher.new }
63
- let(:run_context) { Chef::RunContext.new(node, {}, events) }
64
-
65
50
  it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do
66
51
  inherited_difference = Chef::Resource::Script.guard_inherited_attributes -
67
52
  %i{cwd environment group path user umask}
@@ -73,16 +58,17 @@ shared_examples_for "a script resource" do
73
58
  expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block)
74
59
  expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).not_to receive(:evaluate_action)
75
60
  expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:evaluate).and_return(true)
76
- resource.only_if "echo hi"
77
- expect(resource.should_skip?(:run)).to eq(nil)
61
+ script_resource.only_if "echo hi"
62
+ expect(script_resource.should_skip?(:run)).to eq(nil)
78
63
  end
79
64
 
80
65
  it "when a valid guard_interpreter resource is specified, a block should be used to evaluate the guard" do
66
+ expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block)
81
67
  expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
82
68
  expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
83
- resource.guard_interpreter :script
84
- resource.only_if "echo hi"
85
- expect(resource.should_skip?(:run)).to eq(nil)
69
+ script_resource.guard_interpreter :script
70
+ script_resource.only_if "echo hi"
71
+ expect(script_resource.should_skip?(:run)).to eq(nil)
86
72
  end
87
73
  end
88
74
  end
@@ -20,59 +20,46 @@ require "support/shared/unit/execute_resource"
20
20
  require "support/shared/unit/script_resource"
21
21
 
22
22
  shared_examples_for "a Windows script resource" do
23
- before(:each) do
24
- node = Chef::Node.new
25
-
26
- node.default["kernel"] = {}
27
- node.default["kernel"][:machine] = :x86_64.to_s
28
-
29
- run_context = Chef::RunContext.new(node, nil, nil)
30
-
31
- @resource = resource_instance
32
-
33
- end
34
-
35
23
  it "should be a kind of Chef::Resource::WindowsScript" do
36
- expect(@resource).to be_a_kind_of(Chef::Resource)
37
- expect(@resource).to be_a_kind_of(Chef::Resource::WindowsScript)
24
+ expect(windows_script_resource).to be_a_kind_of(Chef::Resource)
25
+ expect(windows_script_resource).to be_a_kind_of(Chef::Resource::WindowsScript)
38
26
  end
39
27
 
40
28
  context "when evaluating guards" do
41
29
  it "should have a default_guard_interpreter attribute that is the same as the resource" do
42
- expect(@resource.default_guard_interpreter).to eq(@resource.resource_name)
30
+ expect(windows_script_resource.default_guard_interpreter).to eq(windows_script_resource.resource_name)
43
31
  end
44
32
 
45
33
  it "should default to using guard_interpreter attribute that is the same as the resource" do
46
- expect(@resource.guard_interpreter).to eq(@resource.resource_name)
34
+ expect(windows_script_resource.guard_interpreter).to eq(windows_script_resource.resource_name)
47
35
  end
48
36
 
49
37
  it "should use a resource to evaluate the guard when guard_interpreter is not specified" do
50
38
  expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
51
39
  expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
52
- @resource.only_if "echo hi"
53
- expect(@resource.should_skip?(:run)).to eq(nil)
40
+ windows_script_resource.only_if "echo hi"
41
+ expect(windows_script_resource.should_skip?(:run)).to eq(nil)
54
42
  end
55
43
 
56
44
  describe "when the guard is given a ruby block" do
57
45
  it "should evaluate the guard if the guard_interpreter is set to its default value" do
58
- @resource.only_if { true }
59
- expect(@resource.should_skip?(:run)).to eq(nil)
46
+ windows_script_resource.only_if { true }
47
+ expect(windows_script_resource.should_skip?(:run)).to eq(nil)
60
48
  end
61
49
 
62
50
  it "should raise an exception if the guard_interpreter is overridden from its default value" do
63
- @resource.guard_interpreter :bash
64
- @resource.only_if { true }
65
- expect { @resource.should_skip?(:run) }.to raise_error(ArgumentError)
51
+ windows_script_resource.guard_interpreter :bash
52
+ windows_script_resource.only_if { true }
53
+ expect { windows_script_resource.should_skip?(:run) }.to raise_error(ArgumentError)
66
54
  end
67
55
  end
68
56
  end
69
57
 
70
58
  context "script with a default guard interpreter" do
71
- let(:script_resource) do
72
- resource_instance.guard_interpreter :default
73
- resource_instance
74
- end
59
+ let(:script_resource) { windows_script_resource }
60
+
61
+ before { windows_script_resource.guard_interpreter :default }
62
+
75
63
  it_should_behave_like "a script resource"
76
64
  end
77
-
78
65
  end