chef 15.10.12-universal-mingw32 → 15.14.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/README.md +3 -3
  4. data/Rakefile +1 -1
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +3 -3
  7. data/distro/powershell/chef/chef.psm1 +3 -3
  8. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  9. data/lib/chef/api_client/registration.rb +2 -2
  10. data/lib/chef/application/apply.rb +2 -2
  11. data/lib/chef/application/exit_code.rb +2 -2
  12. data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
  13. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  20. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  21. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  22. data/lib/chef/chef_fs/path_utils.rb +3 -3
  23. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +4 -4
  25. data/lib/chef/data_bag.rb +2 -2
  26. data/lib/chef/data_collector/error_handlers.rb +1 -1
  27. data/lib/chef/deprecated.rb +13 -1
  28. data/lib/chef/dsl/declare_resource.rb +1 -1
  29. data/lib/chef/dsl/platform_introspection.rb +3 -1
  30. data/lib/chef/environment.rb +2 -2
  31. data/lib/chef/exceptions.rb +3 -0
  32. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
  33. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
  34. data/lib/chef/http.rb +2 -1
  35. data/lib/chef/knife.rb +26 -20
  36. data/lib/chef/knife/bootstrap.rb +30 -31
  37. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
  38. data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
  39. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  40. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
  41. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  42. data/lib/chef/knife/cookbook_download.rb +1 -1
  43. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  44. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  45. data/lib/chef/knife/cookbook_site_show.rb +1 -1
  46. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  47. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  48. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  49. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  50. data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
  51. data/lib/chef/knife/exec.rb +2 -2
  52. data/lib/chef/knife/ssh.rb +21 -2
  53. data/lib/chef/log.rb +1 -1
  54. data/lib/chef/mixin/create_path.rb +8 -8
  55. data/lib/chef/mixin/openssl_helper.rb +26 -3
  56. data/lib/chef/mixin/template.rb +1 -0
  57. data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
  58. data/lib/chef/node_map.rb +5 -2
  59. data/lib/chef/provider/mount/solaris.rb +0 -1
  60. data/lib/chef/provider/package/cab.rb +1 -1
  61. data/lib/chef/provider/package/chocolatey.rb +4 -3
  62. data/lib/chef/provider/package/msu.rb +1 -0
  63. data/lib/chef/provider/package/powershell.rb +5 -1
  64. data/lib/chef/provider/package/snap.rb +96 -27
  65. data/lib/chef/provider/package/zypper.rb +0 -1
  66. data/lib/chef/provider/service/arch.rb +2 -2
  67. data/lib/chef/provider/service/debian.rb +1 -1
  68. data/lib/chef/provider/service/gentoo.rb +2 -2
  69. data/lib/chef/provider/service/macosx.rb +2 -2
  70. data/lib/chef/provider/service/openbsd.rb +1 -1
  71. data/lib/chef/provider/service/redhat.rb +2 -2
  72. data/lib/chef/provider/service/simple.rb +3 -3
  73. data/lib/chef/provider/service/upstart.rb +1 -1
  74. data/lib/chef/provider/windows_task.rb +1 -1
  75. data/lib/chef/provider/yum_repository.rb +1 -1
  76. data/lib/chef/provider/zypper_repository.rb +31 -11
  77. data/lib/chef/resource.rb +2 -0
  78. data/lib/chef/resource/archive_file.rb +28 -8
  79. data/lib/chef/resource/build_essential.rb +1 -1
  80. data/lib/chef/resource/cron_access.rb +13 -5
  81. data/lib/chef/resource/cron_d.rb +1 -1
  82. data/lib/chef/resource/hostname.rb +19 -18
  83. data/lib/chef/resource/launchd.rb +4 -4
  84. data/lib/chef/resource/lwrp_base.rb +7 -0
  85. data/lib/chef/resource/macos_userdefaults.rb +3 -3
  86. data/lib/chef/resource/msu_package.rb +5 -0
  87. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  88. data/lib/chef/resource/sudo.rb +2 -2
  89. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  90. data/lib/chef/resource/windows_firewall_rule.rb +8 -4
  91. data/lib/chef/resource/windows_font.rb +2 -1
  92. data/lib/chef/resource/windows_share.rb +4 -4
  93. data/lib/chef/resource/windows_task.rb +13 -13
  94. data/lib/chef/resource_inspector.rb +4 -3
  95. data/lib/chef/role.rb +2 -2
  96. data/lib/chef/shell.rb +1 -1
  97. data/lib/chef/shell/shell_session.rb +2 -0
  98. data/lib/chef/util/diff.rb +1 -1
  99. data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
  100. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  101. data/lib/chef/version.rb +2 -2
  102. data/lib/chef/win32/api/command_line_helper.rb +89 -0
  103. data/lib/chef/win32/api/file.rb +18 -18
  104. data/lib/chef/win32/file.rb +3 -3
  105. data/lib/chef/win32/process.rb +2 -2
  106. data/spec/functional/knife/ssh_spec.rb +4 -4
  107. data/spec/functional/resource/aix_service_spec.rb +0 -1
  108. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  109. data/spec/functional/resource/apt_package_spec.rb +0 -1
  110. data/spec/functional/resource/bff_spec.rb +2 -2
  111. data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
  112. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  113. data/spec/functional/resource/cron_spec.rb +0 -1
  114. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  115. data/spec/functional/resource/insserv_spec.rb +4 -5
  116. data/spec/functional/resource/link_spec.rb +17 -17
  117. data/spec/functional/resource/msu_package_spec.rb +5 -2
  118. data/spec/functional/resource/rpm_spec.rb +2 -2
  119. data/spec/functional/resource/user/dscl_spec.rb +2 -2
  120. data/spec/functional/resource/user/mac_user_spec.rb +2 -2
  121. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  122. data/spec/functional/resource/windows_font_spec.rb +49 -0
  123. data/spec/functional/resource/windows_task_spec.rb +8 -8
  124. data/spec/functional/run_lock_spec.rb +2 -1
  125. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  126. data/spec/functional/version_spec.rb +1 -1
  127. data/spec/functional/win32/service_manager_spec.rb +1 -1
  128. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  129. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  130. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  131. data/spec/integration/recipes/notifies_spec.rb +1 -1
  132. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  133. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  134. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  135. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  136. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  137. data/spec/scripts/ssl-serve.rb +1 -1
  138. data/spec/spec_helper.rb +26 -19
  139. data/spec/support/chef_helpers.rb +1 -1
  140. data/spec/support/platform_helpers.rb +12 -42
  141. data/spec/support/platforms/win32/spec_service.rb +1 -1
  142. data/spec/support/shared/functional/directory_resource.rb +1 -1
  143. data/spec/support/shared/functional/execute_resource.rb +1 -1
  144. data/spec/support/shared/functional/file_resource.rb +3 -3
  145. data/spec/support/shared/functional/win32_service.rb +1 -1
  146. data/spec/support/shared/functional/windows_script.rb +3 -3
  147. data/spec/support/shared/integration/knife_support.rb +2 -5
  148. data/spec/unit/application_spec.rb +7 -0
  149. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  150. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  151. data/spec/unit/data_bag_spec.rb +1 -1
  152. data/spec/unit/data_collector_spec.rb +1 -1
  153. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  154. data/spec/unit/environment_spec.rb +7 -7
  155. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  156. data/spec/unit/file_access_control_spec.rb +1 -1
  157. data/spec/unit/json_compat_spec.rb +1 -1
  158. data/spec/unit/knife/bootstrap_spec.rb +26 -29
  159. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  160. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  161. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  162. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  163. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
  164. data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
  165. data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
  166. data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
  167. data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
  168. data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
  169. data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
  170. data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
  171. data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
  172. data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
  173. data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
  174. data/spec/unit/knife/ssh_spec.rb +2 -2
  175. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  176. data/spec/unit/lwrp_spec.rb +4 -4
  177. data/spec/unit/mixin/securable_spec.rb +0 -1
  178. data/spec/unit/mixin/user_context_spec.rb +1 -9
  179. data/spec/unit/property_spec.rb +6 -6
  180. data/spec/unit/provider/apt_repository_spec.rb +2 -2
  181. data/spec/unit/provider/git_spec.rb +3 -3
  182. data/spec/unit/provider/osx_profile_spec.rb +2 -2
  183. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  184. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  185. data/spec/unit/provider/package/msu_spec.rb +3 -3
  186. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  187. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  188. data/spec/unit/provider/package/snap_spec.rb +1 -1
  189. data/spec/unit/provider/package/windows_spec.rb +30 -53
  190. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  191. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  192. data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
  193. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  194. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  195. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  196. data/spec/unit/provider/service/windows_spec.rb +2 -6
  197. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  198. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  199. data/spec/unit/provider_resolver_spec.rb +9 -9
  200. data/spec/unit/provider_spec.rb +1 -0
  201. data/spec/unit/resource/archive_file_spec.rb +11 -2
  202. data/spec/unit/resource/msu_package_spec.rb +4 -0
  203. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  204. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  205. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  206. data/spec/unit/resource/windows_package_spec.rb +1 -0
  207. data/spec/unit/resource/windows_task_spec.rb +1 -1
  208. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  209. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  210. data/spec/unit/resource_reporter_spec.rb +1 -1
  211. data/spec/unit/resource_spec.rb +1 -1
  212. data/spec/unit/role_spec.rb +11 -11
  213. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  214. data/spec/unit/run_context_spec.rb +1 -1
  215. data/spec/unit/run_lock_spec.rb +1 -1
  216. data/spec/unit/scan_access_control_spec.rb +1 -1
  217. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  218. data/spec/unit/win32/security_spec.rb +4 -3
  219. data/tasks/rspec.rb +5 -13
  220. metadata +32 -18
@@ -593,14 +593,14 @@ describe Chef::ProviderResolver do
593
593
  "debian" => {
594
594
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ],
595
595
  package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ],
596
- # service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ],
596
+ # service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ],
597
597
 
598
598
  "debian" => {
599
599
  "7.0" => {
600
600
  },
601
601
  "6.0" => {
602
602
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
603
- # service: [ Chef::Resource::InsservService, Chef::Provider::Service::Insserv ],
603
+ # service: [ Chef::Resource::InsservService, Chef::Provider::Service::Insserv ],
604
604
  },
605
605
  "5.0" => {
606
606
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
@@ -619,7 +619,7 @@ describe Chef::ProviderResolver do
619
619
  "linuxmint" => {
620
620
  "3.1.4" => {
621
621
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
622
- # service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ],
622
+ # service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ],
623
623
  },
624
624
  },
625
625
  "raspbian" => {
@@ -667,7 +667,7 @@ describe Chef::ProviderResolver do
667
667
  # TODO should be Chef::Resource::PortagePackage
668
668
  package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ],
669
669
  portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ],
670
- # service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ],
670
+ # service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ],
671
671
 
672
672
  "gentoo" => {
673
673
  "3.1.4" => {
@@ -676,14 +676,14 @@ describe Chef::ProviderResolver do
676
676
  },
677
677
 
678
678
  "rhel" => {
679
- # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ],
679
+ # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ],
680
680
  package: [ Chef::Resource::DnfPackage, Chef::Provider::Package::Dnf ],
681
681
  ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ],
682
682
 
683
683
  %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => {
684
684
  "3.1.4" => {
685
685
  package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
686
- # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
686
+ # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
687
687
  },
688
688
  },
689
689
  %w{redhat centos scientific oracle} => {
@@ -692,14 +692,14 @@ describe Chef::ProviderResolver do
692
692
  },
693
693
  "6.0" => {
694
694
  package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
695
- # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
695
+ # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
696
696
  },
697
697
  },
698
698
  "fedora" => {
699
699
  "15.0" => {
700
700
  },
701
701
  "14.0" => {
702
- # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
702
+ # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
703
703
  },
704
704
  },
705
705
  },
@@ -761,7 +761,7 @@ describe Chef::ProviderResolver do
761
761
  package: [ Chef::Resource::Package, Chef::Provider::Package::Bff ],
762
762
  rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ],
763
763
  user: [ Chef::Resource::User::AixUser, Chef::Provider::User::Aix ],
764
- # service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ],
764
+ # service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ],
765
765
 
766
766
  "aix" => {
767
767
  "aix" => {
@@ -20,6 +20,7 @@ require "spec_helper"
20
20
 
21
21
  class NoWhyrunDemonstrator < Chef::Provider
22
22
  attr_reader :system_state_altered
23
+
23
24
  def whyrun_supported?
24
25
  false
25
26
  end
@@ -18,8 +18,11 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::ArchiveFile do
21
-
22
- let(:resource) { Chef::Resource::ArchiveFile.new("foo") }
21
+ let(:node) { Chef::Node.new }
22
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
23
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
24
+ let(:resource) { Chef::Resource::ArchiveFile.new("foo", run_context) }
25
+ let(:provider) { resource.provider_for_action(:extract) }
23
26
 
24
27
  it "has a resource name of :archive_file" do
25
28
  expect(resource.resource_name).to eql(:archive_file)
@@ -41,6 +44,12 @@ describe Chef::Resource::ArchiveFile do
41
44
  expect(resource.mode).to eql("755")
42
45
  end
43
46
 
47
+ it "mode property throws a deprecation warning if Integers are passed" do
48
+ expect(Chef::Log).to receive(:deprecation)
49
+ resource.mode 755
50
+ provider.define_resource_requirements
51
+ end
52
+
44
53
  it "options property defaults to [:time]" do
45
54
  expect(resource.options).to eql([:time])
46
55
  end
@@ -60,4 +60,8 @@ describe Chef::Resource::MsuPackage do
60
60
  resource.source("package.msu")
61
61
  expect(resource.source).not_to eq("package.msu")
62
62
  end
63
+
64
+ it "sets timeout property to 3600 by default" do
65
+ expect(resource.timeout).to eql(3600)
66
+ end
63
67
  end
@@ -29,15 +29,15 @@ describe Chef::Resource::WindowsDnsRecord do
29
29
  end
30
30
 
31
31
  it "the record_type property accepts 'CNAME'" do
32
- expect { resource.record_type "CNAME" }.not_to raise_error(ArgumentError)
32
+ expect { resource.record_type "CNAME" }.not_to raise_error
33
33
  end
34
34
 
35
35
  it "the record_type property accepts 'ARecord'" do
36
- expect { resource.record_type "ARecord" }.not_to raise_error(ArgumentError)
36
+ expect { resource.record_type "ARecord" }.not_to raise_error
37
37
  end
38
38
 
39
39
  it "the record_type property accepts 'PTR'" do
40
- expect { resource.record_type "PTR" }.not_to raise_error(ArgumentError)
40
+ expect { resource.record_type "PTR" }.not_to raise_error
41
41
  end
42
42
 
43
43
  it "the resource raises an ArgumentError if invalid record_type is set" do
@@ -29,11 +29,11 @@ describe Chef::Resource::WindowsDnsZone do
29
29
  end
30
30
 
31
31
  it "the server_type property accepts 'Standalone'" do
32
- expect { resource.server_type "Standalone" }.not_to raise_error(ArgumentError)
32
+ expect { resource.server_type "Standalone" }.not_to raise_error
33
33
  end
34
34
 
35
35
  it "the server_type property accepts 'Domain'" do
36
- expect { resource.server_type "Domain" }.not_to raise_error(ArgumentError)
36
+ expect { resource.server_type "Domain" }.not_to raise_error
37
37
  end
38
38
 
39
39
  it "the resource raises an ArgumentError if invalid server_type is set" do
@@ -22,6 +22,7 @@ describe Chef::Resource::WindowsFeaturePowershell do
22
22
  let(:events) { Chef::EventDispatch::Dispatcher.new }
23
23
  let(:run_context) { Chef::RunContext.new(node, {}, events) }
24
24
  let(:resource) { Chef::Resource::WindowsFeaturePowershell.new(%w{SNMP DHCP}, run_context) }
25
+ let(:provider) { resource.provider_for_action(:install) }
25
26
 
26
27
  it "sets resource name as :windows_feature_powershell" do
27
28
  expect(resource.resource_name).to eql(:windows_feature_powershell)
@@ -36,10 +37,6 @@ describe Chef::Resource::WindowsFeaturePowershell do
36
37
  expect(resource.feature_name).to eql(%w{snmp dhcp})
37
38
  end
38
39
 
39
- it "sets the default action as :install" do
40
- expect(resource.action).to eql([:install])
41
- end
42
-
43
40
  it "supports :delete, :install, :remove actions" do
44
41
  expect { resource.action :delete }.not_to raise_error
45
42
  expect { resource.action :install }.not_to raise_error
@@ -69,4 +66,33 @@ describe Chef::Resource::WindowsFeaturePowershell do
69
66
  resource.feature_name "SNMP"
70
67
  expect(resource.feature_name).to eql(["SNMP"])
71
68
  end
69
+
70
+ it "install a single feature" do
71
+ resource.feature_name "snmp"
72
+ expect { resource.action :install }.not_to raise_error
73
+ end
74
+
75
+ it "install multi feature" do
76
+ resource.feature_name "SNMP, DHCP"
77
+ expect { resource.action :install }.not_to raise_error
78
+ end
79
+
80
+ it "does not attempt to install features that have been removed" do
81
+ node.default["powershell_features_cache"] ||= {}
82
+ node.default["powershell_features_cache"]["disabled"] = ["dhcp"]
83
+ node.default["powershell_features_cache"]["removed"] = ["snmp"]
84
+ resource.feature_name "dhcp, snmp"
85
+
86
+ expect(provider.features_to_install).to eq(["dhcp"])
87
+ end
88
+
89
+ it "attempts to install features that have been removed when source is set" do
90
+ node.default["powershell_features_cache"] ||= {}
91
+ node.default["powershell_features_cache"]["disabled"] = ["dhcp"]
92
+ node.default["powershell_features_cache"]["removed"] = ["snmp"]
93
+ resource.feature_name "dhcp, snmp"
94
+ resource.source 'D:\\sources\\sxs'
95
+
96
+ expect(provider.features_to_install).to eq(%w{dhcp snmp})
97
+ end
72
98
  end
@@ -58,6 +58,7 @@ describe Chef::Resource::WindowsPackage, "initialize" do
58
58
  expect { resource.installer_type :msi }.not_to raise_error
59
59
  expect { resource.installer_type :nsis }.not_to raise_error
60
60
  expect { resource.installer_type :wise }.not_to raise_error
61
+ expect { resource.installer_type :something_else_entirely }.to raise_error(Chef::Exceptions::ValidationFailed)
61
62
  expect { resource.installer_type "msi" }.to raise_error(Chef::Exceptions::ValidationFailed)
62
63
  end
63
64
 
@@ -144,7 +144,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
144
144
  resource.frequency :once
145
145
  resource.random_delay "20"
146
146
  resource.start_time "15:00"
147
- expect { resource.after_created }.to_not raise_error(ArgumentError, "`random_delay` property is supported only for frequency :once, :minute, :hourly, :daily, :weekly and :monthly")
147
+ expect { resource.after_created }.to_not raise_error
148
148
  end
149
149
 
150
150
  it "raises error for invalid random_delay" do
@@ -26,7 +26,7 @@ describe Chef::Resource::WindowsUac do
26
26
 
27
27
  %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.each do |val|
28
28
  it "the consent_behavior_admins property accepts :#{val}" do
29
- expect { resource.consent_behavior_admins val }.not_to raise_error(ArgumentError)
29
+ expect { resource.consent_behavior_admins val }.not_to raise_error
30
30
  end
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ describe Chef::Resource::WindowsUac do
36
36
 
37
37
  %i{auto_deny secure_prompt_for_creds prompt_for_creds}.each do |val|
38
38
  it "the consent_behavior_users property accepts :#{val}" do
39
- expect { resource.consent_behavior_users val }.not_to raise_error(ArgumentError)
39
+ expect { resource.consent_behavior_users val }.not_to raise_error
40
40
  end
41
41
  end
42
42
 
@@ -73,52 +73,52 @@ describe Chef::Resource::YumRepository do
73
73
  end
74
74
 
75
75
  it "the timeout property expects numeric Strings" do
76
- expect { resource.timeout "123" }.not_to raise_error(ArgumentError)
76
+ expect { resource.timeout "123" }.not_to raise_error
77
77
  expect { resource.timeout "123foo" }.to raise_error(ArgumentError)
78
78
  end
79
79
 
80
80
  it "the priority property expects numeric Strings from '1' to '99'" do
81
- expect { resource.priority "99" }.not_to raise_error(ArgumentError)
82
- expect { resource.priority "1" }.not_to raise_error(ArgumentError)
81
+ expect { resource.priority "99" }.not_to raise_error
82
+ expect { resource.priority "1" }.not_to raise_error
83
83
  expect { resource.priority "100" }.to raise_error(ArgumentError)
84
84
  expect { resource.priority "0" }.to raise_error(ArgumentError)
85
85
  end
86
86
 
87
87
  it "the failovermethod property accepts 'priority' or 'roundrobin'" do
88
- expect { resource.failovermethod "priority" }.not_to raise_error(ArgumentError)
89
- expect { resource.failovermethod "roundrobin" }.not_to raise_error(ArgumentError)
88
+ expect { resource.failovermethod "priority" }.not_to raise_error
89
+ expect { resource.failovermethod "roundrobin" }.not_to raise_error
90
90
  expect { resource.failovermethod "bob" }.to raise_error(ArgumentError)
91
91
  end
92
92
 
93
93
  it "the http_caching property accepts 'packages', 'all', or 'none'" do
94
- expect { resource.http_caching "packages" }.not_to raise_error(ArgumentError)
95
- expect { resource.http_caching "all" }.not_to raise_error(ArgumentError)
96
- expect { resource.http_caching "none" }.not_to raise_error(ArgumentError)
94
+ expect { resource.http_caching "packages" }.not_to raise_error
95
+ expect { resource.http_caching "all" }.not_to raise_error
96
+ expect { resource.http_caching "none" }.not_to raise_error
97
97
  expect { resource.http_caching "bob" }.to raise_error(ArgumentError)
98
98
  end
99
99
 
100
100
  it "the metadata_expire property accepts a time value or 'never'" do
101
- expect { resource.metadata_expire "100" }.not_to raise_error(ArgumentError)
102
- expect { resource.metadata_expire "100d" }.not_to raise_error(ArgumentError)
103
- expect { resource.metadata_expire "100h" }.not_to raise_error(ArgumentError)
104
- expect { resource.metadata_expire "100m" }.not_to raise_error(ArgumentError)
105
- expect { resource.metadata_expire "never" }.not_to raise_error(ArgumentError)
101
+ expect { resource.metadata_expire "100" }.not_to raise_error
102
+ expect { resource.metadata_expire "100d" }.not_to raise_error
103
+ expect { resource.metadata_expire "100h" }.not_to raise_error
104
+ expect { resource.metadata_expire "100m" }.not_to raise_error
105
+ expect { resource.metadata_expire "never" }.not_to raise_error
106
106
  expect { resource.metadata_expire "100s" }.to raise_error(ArgumentError)
107
107
  end
108
108
 
109
109
  it "the mirror_expire property accepts a time value" do
110
- expect { resource.mirror_expire "100" }.not_to raise_error(ArgumentError)
111
- expect { resource.mirror_expire "100d" }.not_to raise_error(ArgumentError)
112
- expect { resource.mirror_expire "100h" }.not_to raise_error(ArgumentError)
113
- expect { resource.mirror_expire "100m" }.not_to raise_error(ArgumentError)
110
+ expect { resource.mirror_expire "100" }.not_to raise_error
111
+ expect { resource.mirror_expire "100d" }.not_to raise_error
112
+ expect { resource.mirror_expire "100h" }.not_to raise_error
113
+ expect { resource.mirror_expire "100m" }.not_to raise_error
114
114
  expect { resource.mirror_expire "never" }.to raise_error(ArgumentError)
115
115
  end
116
116
 
117
117
  it "the mirrorlist_expire property accepts a time value" do
118
- expect { resource.mirrorlist_expire "100" }.not_to raise_error(ArgumentError)
119
- expect { resource.mirrorlist_expire "100d" }.not_to raise_error(ArgumentError)
120
- expect { resource.mirrorlist_expire "100h" }.not_to raise_error(ArgumentError)
121
- expect { resource.mirrorlist_expire "100m" }.not_to raise_error(ArgumentError)
118
+ expect { resource.mirrorlist_expire "100" }.not_to raise_error
119
+ expect { resource.mirrorlist_expire "100d" }.not_to raise_error
120
+ expect { resource.mirrorlist_expire "100h" }.not_to raise_error
121
+ expect { resource.mirrorlist_expire "100m" }.not_to raise_error
122
122
  expect { resource.mirrorlist_expire "never" }.to raise_error(ArgumentError)
123
123
  end
124
124
 
@@ -19,7 +19,7 @@
19
19
  # limitations under the License.
20
20
  #
21
21
 
22
- require File.expand_path("../../spec_helper", __FILE__)
22
+ require_relative "../spec_helper"
23
23
  require "chef/resource_reporter"
24
24
  require "socket"
25
25
 
@@ -378,7 +378,7 @@ describe Chef::Resource do
378
378
  it "does not propagate validation errors" do
379
379
  resource_class = Class.new(Chef::Resource) { property :foo, String, required: true }
380
380
  resource = resource_class.new("required_property_tests")
381
- expect { resource.to_text }.to_not raise_error Chef::Exceptions::ValidationFailed
381
+ expect { resource.to_text }.to_not raise_error
382
382
  end
383
383
  end
384
384
  end
@@ -259,7 +259,7 @@ describe Chef::Role do
259
259
  it "should return a Chef::Role object from JSON" do
260
260
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json"])
261
261
  file_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
262
- expect(File).to receive(:exists?).with(file_path).exactly(1).times.and_return(true)
262
+ expect(File).to receive(:exist?).with(file_path).exactly(1).times.and_return(true)
263
263
  expect(IO).to receive(:read).with(file_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
264
264
  expect(@role).to be_a_kind_of(Chef::Role)
265
265
  @role.class.from_disk("lolcat")
@@ -268,7 +268,7 @@ describe Chef::Role do
268
268
  it "should return a Chef::Role object from a Ruby DSL" do
269
269
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
270
270
  rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
271
- expect(File).to receive(:exists?).with(rb_path).exactly(1).times.and_return(true)
271
+ expect(File).to receive(:exist?).with(rb_path).exactly(1).times.and_return(true)
272
272
  expect(File).to receive(:readable?).with(rb_path).exactly(1).times.and_return(true)
273
273
  expect(File).to receive(:file?).with(rb_path).exactly(1).times.and_return(true)
274
274
  expect(IO).to receive(:read).with(rb_path).and_return(ROLE_DSL)
@@ -280,8 +280,8 @@ describe Chef::Role do
280
280
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
281
281
  js_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
282
282
  rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
283
- expect(File).to receive(:exists?).with(js_path).exactly(1).times.and_return(true)
284
- expect(File).not_to receive(:exists?).with(rb_path)
283
+ expect(File).to receive(:exist?).with(js_path).exactly(1).times.and_return(true)
284
+ expect(File).not_to receive(:exist?).with(rb_path)
285
285
  expect(IO).to receive(:read).with(js_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
286
286
  expect(@role).to be_a_kind_of(Chef::Role)
287
287
  @role.class.from_disk("lolcat")
@@ -289,19 +289,19 @@ describe Chef::Role do
289
289
 
290
290
  it "should raise an exception if the file does not exist" do
291
291
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/meme.rb"])
292
- expect(File).not_to receive(:exists?)
292
+ expect(File).not_to receive(:exist?)
293
293
  expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::RoleNotFound)
294
294
  end
295
295
 
296
296
  it "should raise an exception if two files exist with the same name" do
297
297
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/lolcat.rb"])
298
- expect(File).not_to receive(:exists?)
298
+ expect(File).not_to receive(:exist?)
299
299
  expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::DuplicateRole)
300
300
  end
301
301
 
302
302
  it "should not raise an exception if two files exist with a similar name" do
303
303
  expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/super_lolcat.rb"])
304
- expect(File).to receive(:exists?).with("#{Chef::Config[:role_path]}/memes/lolcat.rb").and_return(true)
304
+ expect(File).to receive(:exist?).with("#{Chef::Config[:role_path]}/memes/lolcat.rb").and_return(true)
305
305
  allow_any_instance_of(Chef::Role).to receive(:from_file).with("#{Chef::Config[:role_path]}/memes/lolcat.rb")
306
306
  expect { @role.class.from_disk("lolcat") }.not_to raise_error
307
307
  end
@@ -315,7 +315,7 @@ describe Chef::Role do
315
315
 
316
316
  it "should return a Chef::Role object from JSON" do
317
317
  expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.json"])
318
- expect(File).to receive(:exists?).with("/path1/lolcat.json").exactly(1).times.and_return(true)
318
+ expect(File).to receive(:exist?).with("/path1/lolcat.json").exactly(1).times.and_return(true)
319
319
  expect(IO).to receive(:read).with("/path1/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
320
320
  expect(@role).to be_a_kind_of(Chef::Role)
321
321
  @role.class.from_disk("lolcat")
@@ -324,7 +324,7 @@ describe Chef::Role do
324
324
  it "should return a Chef::Role object from JSON when role is in the second path" do
325
325
  expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([])
326
326
  expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return(["/path/path2/lolcat.json"])
327
- expect(File).to receive(:exists?).with("/path/path2/lolcat.json").exactly(1).times.and_return(true)
327
+ expect(File).to receive(:exist?).with("/path/path2/lolcat.json").exactly(1).times.and_return(true)
328
328
  expect(IO).to receive(:read).with("/path/path2/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
329
329
  expect(@role).to be_a_kind_of(Chef::Role)
330
330
  @role.class.from_disk("lolcat")
@@ -332,7 +332,7 @@ describe Chef::Role do
332
332
 
333
333
  it "should return a Chef::Role object from a Ruby DSL" do
334
334
  expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.rb"])
335
- expect(File).to receive(:exists?).with("/path1/lolcat.rb").exactly(1).times.and_return(true)
335
+ expect(File).to receive(:exist?).with("/path1/lolcat.rb").exactly(1).times.and_return(true)
336
336
  expect(File).to receive(:readable?).with("/path1/lolcat.rb").and_return(true)
337
337
  expect(File).to receive(:file?).with("/path1/lolcat.rb").and_return(true)
338
338
  expect(IO).to receive(:read).with("/path1/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)
@@ -343,7 +343,7 @@ describe Chef::Role do
343
343
  it "should return a Chef::Role object from a Ruby DSL when role is in the second path" do
344
344
  expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([])
345
345
  expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return(["/path/path2/lolcat.rb"])
346
- expect(File).to receive(:exists?).with("/path/path2/lolcat.rb").exactly(1).times.and_return(true)
346
+ expect(File).to receive(:exist?).with("/path/path2/lolcat.rb").exactly(1).times.and_return(true)
347
347
  expect(File).to receive(:readable?).with("/path/path2/lolcat.rb").and_return(true)
348
348
  expect(File).to receive(:file?).with("/path/path2/lolcat.rb").and_return(true)
349
349
  expect(IO).to receive(:read).with("/path/path2/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)
@@ -175,7 +175,7 @@ describe Chef::RunContext::CookbookCompiler do
175
175
  describe "event dispatch" do
176
176
  let(:recipe) { "dependency1::default" }
177
177
  let(:recipe_path) do
178
- File.expand_path("../../../data/run_context/cookbooks/dependency1/recipes/default.rb", __FILE__)
178
+ File.expand_path("../../data/run_context/cookbooks/dependency1/recipes/default.rb", __dir__)
179
179
  end
180
180
  before do
181
181
  node.run_list(recipe)
@@ -138,7 +138,7 @@ describe Chef::RunContext do
138
138
  expect(node).to receive(:loaded_recipe).with(:ancient, "aliens")
139
139
  expect do
140
140
  run_context.include_recipe("ancient::aliens")
141
- # In CHEF-5120, this becomes a Chef::Exceptions::MissingCookbookDependency error:
141
+ # In CHEF-5120, this becomes a Chef::Exceptions::MissingCookbookDependency error:
142
142
  end.to raise_error(Chef::Exceptions::CookbookNotFound)
143
143
  end
144
144
 
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require_relative "../spec_helper"
19
19
  require "chef/client"
20
20
 
21
21
  describe Chef::RunLock do