chef 14.1.12-universal-mingw32 → 14.2.0-universal-mingw32

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.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -6
  3. data/VERSION +1 -1
  4. data/chef.gemspec +2 -3
  5. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +8 -4
  6. data/lib/chef/cookbook/manifest_v0.rb +2 -2
  7. data/lib/chef/cookbook_manifest.rb +3 -2
  8. data/lib/chef/cookbook_version.rb +3 -2
  9. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -2
  10. data/lib/chef/http/auth_credentials.rb +5 -3
  11. data/lib/chef/http/authenticator.rb +6 -3
  12. data/lib/chef/knife.rb +3 -6
  13. data/lib/chef/knife/configure.rb +12 -8
  14. data/lib/chef/knife/raw.rb +6 -1
  15. data/lib/chef/mixin/shell_out.rb +16 -14
  16. data/lib/chef/provider/execute.rb +4 -3
  17. data/lib/chef/provider/git.rb +1 -1
  18. data/lib/chef/provider/package/dnf.rb +5 -5
  19. data/lib/chef/provider/package/windows.rb +7 -0
  20. data/lib/chef/provider/package/yum.rb +7 -7
  21. data/lib/chef/provider/service/freebsd.rb +3 -3
  22. data/lib/chef/provider/service/init.rb +5 -5
  23. data/lib/chef/provider/service/macosx.rb +5 -4
  24. data/lib/chef/provider/service/simple.rb +4 -4
  25. data/lib/chef/provider/service/systemd.rb +13 -13
  26. data/lib/chef/provider/service/upstart.rb +3 -3
  27. data/lib/chef/provider/service/windows.rb +2 -0
  28. data/lib/chef/provider/systemd_unit.rb +4 -4
  29. data/lib/chef/provider/user.rb +18 -1
  30. data/lib/chef/provider/user/aix.rb +40 -8
  31. data/lib/chef/provider/user/dscl.rb +7 -14
  32. data/lib/chef/provider/user/linux.rb +1 -11
  33. data/lib/chef/provider/user/solaris.rb +57 -26
  34. data/lib/chef/provider/user/useradd.rb +4 -1
  35. data/lib/chef/provider/windows_task.rb +1 -0
  36. data/lib/chef/providers.rb +1 -2
  37. data/lib/chef/resource/execute.rb +4 -1
  38. data/lib/chef/resource/gem_package.rb +1 -1
  39. data/lib/chef/resource/hostname.rb +1 -1
  40. data/lib/chef/resource/sysctl.rb +3 -1
  41. data/lib/chef/resource/windows_ad_join.rb +16 -3
  42. data/lib/chef/resource_inspector.rb +13 -0
  43. data/lib/chef/run_context/cookbook_compiler.rb +1 -1
  44. data/lib/chef/server_api.rb +2 -0
  45. data/lib/chef/version.rb +1 -1
  46. data/spec/functional/mixin/shell_out_spec.rb +27 -1
  47. data/spec/functional/resource/execute_spec.rb +2 -2
  48. data/spec/functional/resource/windows_task_spec.rb +1 -1
  49. data/spec/support/shared/functional/securable_resource.rb +1 -1
  50. data/spec/support/shared/unit/execute_resource.rb +1 -1
  51. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
  52. data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +65 -0
  53. data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
  54. data/spec/unit/cookbook_manifest_spec.rb +2 -0
  55. data/spec/unit/dsl/recipe_spec.rb +1 -5
  56. data/spec/unit/http/authenticator_spec.rb +33 -8
  57. data/spec/unit/mixin/shell_out_spec.rb +61 -1
  58. data/spec/unit/provider/apt_update_spec.rb +7 -7
  59. data/spec/unit/provider/execute_spec.rb +16 -15
  60. data/spec/unit/provider/git_spec.rb +3 -3
  61. data/spec/unit/provider/package/windows_spec.rb +12 -0
  62. data/spec/unit/provider/script_spec.rb +2 -2
  63. data/spec/unit/provider/service/arch_service_spec.rb +9 -9
  64. data/spec/unit/provider/service/freebsd_service_spec.rb +6 -6
  65. data/spec/unit/provider/service/init_service_spec.rb +11 -11
  66. data/spec/unit/provider/service/invokercd_service_spec.rb +9 -9
  67. data/spec/unit/provider/service/macosx_spec.rb +11 -11
  68. data/spec/unit/provider/service/openbsd_service_spec.rb +6 -6
  69. data/spec/unit/provider/service/simple_service_spec.rb +4 -4
  70. data/spec/unit/provider/service/systemd_service_spec.rb +16 -16
  71. data/spec/unit/provider/service/upstart_service_spec.rb +12 -12
  72. data/spec/unit/provider/service/windows_spec.rb +5 -0
  73. data/spec/unit/provider/systemd_unit_spec.rb +163 -118
  74. data/spec/unit/provider/user/dscl_spec.rb +2 -9
  75. data/spec/unit/provider/user/solaris_spec.rb +2 -2
  76. data/spec/unit/provider/zypper_repository_spec.rb +3 -3
  77. data/spec/unit/provider_spec.rb +1 -5
  78. data/spec/unit/resource/apt_package_spec.rb +14 -0
  79. data/spec/unit/resource/apt_preference_spec.rb +14 -1
  80. data/spec/unit/resource/apt_repository_spec.rb +12 -3
  81. data/spec/unit/resource/apt_update_spec.rb +9 -0
  82. data/spec/unit/resource/bash_spec.rb +8 -0
  83. data/spec/unit/resource/bff_package_spec.rb +51 -0
  84. data/spec/unit/resource/breakpoint_spec.rb +4 -4
  85. data/spec/unit/resource/build_essential_spec.rb +5 -1
  86. data/spec/unit/resource/cab_package_spec.rb +10 -0
  87. data/spec/unit/resource/chef_gem_spec.rb +14 -0
  88. data/spec/unit/resource/chef_handler_spec.rb +9 -4
  89. data/spec/unit/resource/chocolatey_package_spec.rb +15 -1
  90. data/spec/unit/resource/conditional_spec.rb +3 -3
  91. data/spec/unit/resource/cookbook_file_spec.rb +13 -2
  92. data/spec/unit/resource/cron_spec.rb +2 -7
  93. data/spec/unit/resource/csh_spec.rb +8 -0
  94. data/spec/unit/resource/directory_spec.rb +4 -9
  95. data/spec/unit/resource/dmg_package_spec.rb +8 -4
  96. data/spec/unit/resource/dnf_package_spec.rb +16 -1
  97. data/spec/unit/resource/dpkg_package_spec.rb +18 -0
  98. data/spec/unit/resource/dsc_resource_spec.rb +6 -6
  99. data/spec/unit/resource/dsc_script_spec.rb +39 -39
  100. data/spec/unit/resource/execute_spec.rb +20 -12
  101. data/spec/unit/resource/file_spec.rb +10 -10
  102. data/spec/unit/resource/freebsd_package_spec.rb +16 -0
  103. data/spec/unit/resource/gem_package_spec.rb +27 -0
  104. data/spec/unit/resource/git_spec.rb +17 -2
  105. data/spec/unit/resource/group_spec.rb +18 -17
  106. data/spec/unit/resource/homebrew_cask_spec.rb +9 -4
  107. data/spec/unit/resource/homebrew_package_spec.rb +14 -0
  108. data/spec/unit/resource/homebrew_tap_spec.rb +8 -3
  109. data/spec/unit/resource/hostname_spec.rb +10 -6
  110. data/spec/unit/resource/http_request_spec.rb +14 -0
  111. data/spec/unit/resource/ips_package_spec.rb +15 -3
  112. data/spec/unit/resource/ksh_spec.rb +8 -0
  113. data/spec/unit/resource/launchd_spec.rb +11 -5
  114. data/spec/unit/resource/link_spec.rb +6 -11
  115. data/spec/unit/resource/log_spec.rb +8 -8
  116. data/spec/unit/resource/macos_user_defaults_spec.rb +5 -1
  117. data/spec/unit/resource/macports_package_spec.rb +19 -0
  118. data/spec/unit/resource/mdadm_spec.rb +7 -3
  119. data/spec/unit/resource/mount_spec.rb +15 -18
  120. data/spec/unit/resource/msu_package_spec.rb +10 -0
  121. data/spec/unit/resource/ohai_hint_spec.rb +9 -8
  122. data/spec/unit/resource/ohai_spec.rb +11 -3
  123. data/spec/unit/resource/openbsd_package_spec.rb +14 -0
  124. data/spec/unit/resource/openssl_dhparam.rb +10 -5
  125. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +10 -5
  126. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +9 -5
  127. data/spec/unit/resource/osx_profile_spec.rb +7 -4
  128. data/spec/unit/resource/package_spec.rb +14 -0
  129. data/spec/unit/resource/pacman_package_spec.rb +17 -3
  130. data/spec/unit/resource/paludis_package_spec.rb +36 -0
  131. data/spec/unit/resource/perl_spec.rb +8 -0
  132. data/spec/unit/resource/portage_package_spec.rb +14 -0
  133. data/spec/unit/resource/powershell_package_spec.rb +14 -0
  134. data/spec/unit/resource/python_spec.rb +8 -0
  135. data/spec/unit/resource/reboot_spec.rb +5 -3
  136. data/spec/unit/resource/registry_key_spec.rb +12 -1
  137. data/spec/unit/resource/remote_directory_spec.rb +11 -1
  138. data/spec/unit/resource/remote_file_spec.rb +19 -0
  139. data/spec/unit/resource/rhsm_errata_level_spec.rb +7 -3
  140. data/spec/unit/resource/rhsm_errata_spec.rb +8 -4
  141. data/spec/unit/resource/rhsm_register_spec.rb +6 -1
  142. data/spec/unit/resource/rhsm_repo_spec.rb +9 -4
  143. data/spec/unit/resource/rhsm_subscription_spec.rb +9 -4
  144. data/spec/unit/resource/route_spec.rb +4 -9
  145. data/spec/unit/resource/rpm_package_spec.rb +14 -0
  146. data/spec/unit/resource/ruby_block_spec.rb +12 -8
  147. data/spec/unit/resource/ruby_spec.rb +8 -0
  148. data/spec/unit/resource/scm_spec.rb +16 -8
  149. data/spec/unit/resource/script_spec.rb +8 -0
  150. data/spec/unit/resource/service_spec.rb +15 -0
  151. data/spec/unit/resource/smartos_package_spec.rb +18 -4
  152. data/spec/unit/resource/solaris_package_spec.rb +14 -0
  153. data/spec/unit/resource/subversion_spec.rb +14 -8
  154. data/spec/unit/resource/sudo_spec.rb +11 -4
  155. data/spec/unit/resource/swap_file_spec.rb +4 -5
  156. data/spec/unit/resource/sysctl_spec.rb +8 -10
  157. data/spec/unit/resource/systemd_unit_spec.rb +14 -12
  158. data/spec/unit/resource/template_spec.rb +19 -0
  159. data/spec/unit/resource/{windows_ad_join.rb → windows_ad_join_spec.rb} +12 -6
  160. data/spec/unit/resource/windows_auto_run_spec.rb +9 -9
  161. data/spec/unit/resource/windows_env_spec.rb +8 -16
  162. data/spec/unit/resource/windows_feature.rb +27 -8
  163. data/spec/unit/resource/windows_feature_dism.rb +30 -9
  164. data/spec/unit/resource/windows_feature_powershell.rb +7 -7
  165. data/spec/unit/resource/windows_font_spec.rb +3 -4
  166. data/spec/unit/resource/windows_package_spec.rb +12 -2
  167. data/spec/unit/resource/windows_pagefile_spec.rb +12 -8
  168. data/spec/unit/resource/windows_path_spec.rb +4 -5
  169. data/spec/unit/resource/windows_printer_port_spec.rb +20 -3
  170. data/spec/unit/resource/windows_printer_spec.rb +12 -5
  171. data/spec/unit/resource/windows_service_spec.rb +24 -1
  172. data/spec/unit/resource/windows_shortcut_spec.rb +4 -5
  173. data/spec/unit/resource/yum_repository_spec.rb +48 -2
  174. data/spec/unit/resource/zypper_package_spec.rb +51 -0
  175. data/spec/unit/resource/zypper_repository_spec.rb +56 -11
  176. data/spec/unit/resource_spec.rb +1 -5
  177. metadata +21 -12
  178. data/spec/functional/resource/user/useradd_spec.rb +0 -709
@@ -37,4 +37,18 @@ describe Chef::Resource::SolarisPackage, "initialize" do
37
37
  it "sets the package_name to the name provided" do
38
38
  expect(resource.package_name).to eql("foo")
39
39
  end
40
+
41
+ it "sets the default action as :install" do
42
+ expect(resource.action).to eql([:install])
43
+ end
44
+
45
+ it "supports :install, :lock, :purge, :reconfig, :remove, :unlock, :upgrade actions" do
46
+ expect { resource.action :install }.not_to raise_error
47
+ expect { resource.action :lock }.not_to raise_error
48
+ expect { resource.action :purge }.not_to raise_error
49
+ expect { resource.action :reconfig }.not_to raise_error
50
+ expect { resource.action :remove }.not_to raise_error
51
+ expect { resource.action :unlock }.not_to raise_error
52
+ expect { resource.action :upgrade }.not_to raise_error
53
+ end
40
54
  end
@@ -17,10 +17,8 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- require "support/shared/unit/resource/static_provider_resolution"
21
20
 
22
21
  describe Chef::Resource::Subversion do
23
-
24
22
  static_provider_resolution(
25
23
  resource: Chef::Resource::Subversion,
26
24
  provider: Chef::Provider::Subversion,
@@ -28,19 +26,27 @@ describe Chef::Resource::Subversion do
28
26
  action: :install
29
27
  )
30
28
 
31
- let(:resource) { Chef::Resource::Subversion.new("ohai, svn project!") }
29
+ let(:resource) { Chef::Resource::Subversion.new("fakey_fakerton") }
32
30
 
33
31
  it "is a subclass of Resource::Scm" do
34
- expect(resource).to be_an_instance_of(Chef::Resource::Subversion)
35
32
  expect(resource).to be_a_kind_of(Chef::Resource::Scm)
36
33
  end
37
34
 
38
- it "set destination property to the name_property" do
39
- expect(resource.destination).to eq("ohai, svn project!")
35
+ it "the destination property is the name_property" do
36
+ expect(resource.destination).to eql("fakey_fakerton")
37
+ end
38
+
39
+ it "sets the default action as :sync" do
40
+ expect(resource.action).to eql([:sync])
40
41
  end
41
42
 
42
- it "allows the force_export action" do
43
- expect(resource.allowed_actions).to include(:force_export)
43
+ it "supports :checkout, :diff, :export, :force_export, :log, :sync actions" do
44
+ expect { resource.action :checkout }.not_to raise_error
45
+ expect { resource.action :diff }.not_to raise_error
46
+ expect { resource.action :export }.not_to raise_error
47
+ expect { resource.action :force_export }.not_to raise_error
48
+ expect { resource.action :log }.not_to raise_error
49
+ expect { resource.action :sync }.not_to raise_error
44
50
  end
45
51
 
46
52
  it "sets svn info arguments to --no-auth-cache by default" do
@@ -22,18 +22,25 @@ describe Chef::Resource::Sudo do
22
22
  let(:node) { Chef::Node.new }
23
23
  let(:events) { Chef::EventDispatch::Dispatcher.new }
24
24
  let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
- let(:resource) { Chef::Resource::Sudo.new("someone", run_context) }
25
+ let(:resource) { Chef::Resource::Sudo.new("fakey_fakerton", run_context) }
26
26
 
27
27
  it "has a resource name of :sudo" do
28
28
  expect(resource.resource_name).to eql(:sudo)
29
29
  end
30
30
 
31
- it "has a default action of create" do
31
+ it "the filename property is the name_property" do
32
+ expect(resource.filename).to eql("fakey_fakerton")
33
+ end
34
+
35
+ it "sets the default action as :create" do
32
36
  expect(resource.action).to eql([:create])
33
37
  end
34
38
 
35
- it "the filename property is the name property" do
36
- expect(resource.filename).to eql("someone")
39
+ it "supports :create, :delete, :install, :remove actions" do
40
+ expect { resource.action :create }.not_to raise_error
41
+ expect { resource.action :delete }.not_to raise_error
42
+ expect { resource.action :install }.not_to raise_error
43
+ expect { resource.action :remove }.not_to raise_error
37
44
  end
38
45
 
39
46
  it "coerces filename property values . & ~ to __" do
@@ -18,23 +18,22 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::SwapFile do
21
- let(:resource) { Chef::Resource::SwapFile.new("swapfile") }
21
+ let(:resource) { Chef::Resource::SwapFile.new("fakey_fakerton") }
22
22
 
23
23
  it "sets resource name as :swap_file" do
24
24
  expect(resource.resource_name).to eql(:swap_file)
25
25
  end
26
26
 
27
- it "sets the path as its name" do
28
- expect(resource.path).to eql("swapfile")
27
+ it "the path property is the name_property" do
28
+ expect(resource.path).to eql("fakey_fakerton")
29
29
  end
30
30
 
31
31
  it "sets the default action as :create" do
32
32
  expect(resource.action).to eql([:create])
33
33
  end
34
34
 
35
- it "supports :create and :remove actions" do
35
+ it "supports :create, :remove actions" do
36
36
  expect { resource.action :create }.not_to raise_error
37
37
  expect { resource.action :remove }.not_to raise_error
38
- expect { resource.action :delete }.to raise_error(ArgumentError)
39
38
  end
40
39
  end
@@ -18,18 +18,23 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::Sysctl do
21
- let(:resource) { Chef::Resource::Sysctl.new("something.something") }
21
+ let(:resource) { Chef::Resource::Sysctl.new("fakey_fakerton") }
22
22
 
23
23
  it "sets resource name as :sysctl" do
24
24
  expect(resource.resource_name).to eql(:sysctl)
25
25
  end
26
26
 
27
+ it "the key property is the name_property" do
28
+ expect(resource.key).to eql("fakey_fakerton")
29
+ end
30
+
27
31
  it "sets the default action as :apply" do
28
32
  expect(resource.action).to eql([:apply])
29
33
  end
30
34
 
31
- it "sets the key property as its name property" do
32
- expect(resource.key).to eql("something.something")
35
+ it "supports :apply, :remove actions" do
36
+ expect { resource.action :apply }.not_to raise_error
37
+ expect { resource.action :remove }.not_to raise_error
33
38
  end
34
39
 
35
40
  it "coerces Arrays in the value property to space delimited Strings" do
@@ -46,11 +51,4 @@ describe Chef::Resource::Sysctl do
46
51
  resource.value 1.1
47
52
  expect(resource.value).to eql("1.1")
48
53
  end
49
-
50
- it "supports :apply and :remove actions" do
51
- expect { resource.action :apply }.not_to raise_error
52
- expect { resource.action :remove }.not_to raise_error
53
- expect { resource.action :delete }.to raise_error(ArgumentError)
54
- expect { resource.action :install }.to raise_error(ArgumentError)
55
- end
56
54
  end
@@ -35,29 +35,31 @@ describe Chef::Resource::SystemdUnit do
35
35
  }
36
36
  end
37
37
 
38
- it "has a name property" do
39
- expect(resource.name).to eql("sysstat-collect.timer")
38
+ it "the unit_name property is the name_property" do
39
+ expect(resource.unit_name).to eql("sysstat-collect.timer")
40
40
  end
41
41
 
42
- it "has a default action of nothing" do
42
+ it "sets the default action as :nothing" do
43
43
  expect(resource.action).to eql([:nothing])
44
44
  end
45
45
 
46
- it "supports appropriate unit actions" do
46
+ it "supports :create, :delete, :disable, :enable, :mask, :preset, :reenable, :reload, :reload_or_restart, :reload_or_try_restart, :restart, :revert, :start, :stop, :try_restart, :unmask actions" do
47
47
  expect { resource.action :create }.not_to raise_error
48
48
  expect { resource.action :delete }.not_to raise_error
49
- expect { resource.action :preset }.not_to raise_error
50
- expect { resource.action :revert }.not_to raise_error
51
- expect { resource.action :enable }.not_to raise_error
52
49
  expect { resource.action :disable }.not_to raise_error
53
- expect { resource.action :reenable }.not_to raise_error
50
+ expect { resource.action :enable }.not_to raise_error
54
51
  expect { resource.action :mask }.not_to raise_error
55
- expect { resource.action :unmask }.not_to raise_error
52
+ expect { resource.action :preset }.not_to raise_error
53
+ expect { resource.action :reenable }.not_to raise_error
54
+ expect { resource.action :reload }.not_to raise_error
55
+ expect { resource.action :reload_or_restart }.not_to raise_error
56
+ expect { resource.action :reload_or_try_restart }.not_to raise_error
57
+ expect { resource.action :restart }.not_to raise_error
58
+ expect { resource.action :revert }.not_to raise_error
56
59
  expect { resource.action :start }.not_to raise_error
57
60
  expect { resource.action :stop }.not_to raise_error
58
- expect { resource.action :restart }.not_to raise_error
59
- expect { resource.action :reload }.not_to raise_error
60
- expect { resource.action :wrong }.to raise_error(ArgumentError)
61
+ expect { resource.action :try_restart }.not_to raise_error
62
+ expect { resource.action :unmask }.not_to raise_error
61
63
  end
62
64
 
63
65
  it "accepts boolean state properties" do
@@ -27,6 +27,25 @@ describe Chef::Resource::Template do
27
27
  end
28
28
  end
29
29
 
30
+ describe "name" do
31
+ it "the path property is the name_property" do
32
+ expect(resource.path).to eql("fakey_fakerton")
33
+ end
34
+ end
35
+
36
+ describe "Actions" do
37
+ it "sets the default action as :create" do
38
+ expect(resource.action).to eql([:create])
39
+ end
40
+
41
+ it "supports :create, :create_if_missing, :delete, :touch actions" do
42
+ expect { resource.action :create }.not_to raise_error
43
+ expect { resource.action :create_if_missing }.not_to raise_error
44
+ expect { resource.action :delete }.not_to raise_error
45
+ expect { resource.action :touch }.not_to raise_error
46
+ end
47
+ end
48
+
30
49
  describe "source" do
31
50
  it "accepts a string for the template source" do
32
51
  resource.source "something"
@@ -24,21 +24,27 @@ describe Chef::Resource::WindowsAdJoin do
24
24
  expect(resource.resource_name).to eql(:windows_ad_join)
25
25
  end
26
26
 
27
- it "sets the domain_name as its name" do
27
+ it "the domain_name property is the name_property" do
28
28
  expect(resource.domain_name).to eql("example.com")
29
29
  end
30
30
 
31
- it "only accepts FQDNs for the domain_name property" do
32
- expect { resource.domain_name "example" }.to raise_error(ArgumentError)
33
- end
34
-
35
31
  it "sets the default action as :join" do
36
32
  expect(resource.action).to eql([:join])
37
33
  end
38
34
 
39
- it "accepts :immediate, :delayed, or :never values for 'reboot' property" do
35
+ it "supports :join action" do
36
+ expect { resource.action :join }.not_to raise_error
37
+ end
38
+
39
+ it "only accepts FQDNs for the domain_name property" do
40
+ expect { resource.domain_name "example" }.to raise_error(ArgumentError)
41
+ end
42
+
43
+ it "accepts :immediate, :reboot_now, :request_reboot, :delayed, or :never values for 'reboot' property" do
40
44
  expect { resource.reboot :immediate }.not_to raise_error
41
45
  expect { resource.reboot :delayed }.not_to raise_error
46
+ expect { resource.reboot :reboot_now }.not_to raise_error
47
+ expect { resource.reboot :request_reboot }.not_to raise_error
42
48
  expect { resource.reboot :never }.not_to raise_error
43
49
  expect { resource.reboot :nopenope }.to raise_error(ArgumentError)
44
50
  end
@@ -18,31 +18,31 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::WindowsAutorun do
21
- let(:resource) { Chef::Resource::WindowsAutorun.new("some_path") }
21
+ let(:resource) { Chef::Resource::WindowsAutorun.new("fakey_fakerton") }
22
22
 
23
23
  it "sets resource name as :windows_auto_run" do
24
24
  expect(resource.resource_name).to eql(:windows_auto_run)
25
25
  end
26
26
 
27
+ it "the program_name property is the name_property" do
28
+ expect(resource.program_name).to eql("fakey_fakerton")
29
+ end
30
+
27
31
  it "sets the default action as :create" do
28
32
  expect(resource.action).to eql([:create])
29
33
  end
30
34
 
31
- it "sets the program_name property as its name" do
32
- expect(resource.program_name).to eql("some_path")
35
+ it "supports :create, :remove actions" do
36
+ expect { resource.action :create }.not_to raise_error
37
+ expect { resource.action :remove }.not_to raise_error
33
38
  end
39
+
34
40
  it "supports :machine and :user in the root property" do
35
41
  expect { resource.root :user }.not_to raise_error
36
42
  expect { resource.root :machine }.not_to raise_error
37
43
  expect { resource.root "user" }.to raise_error(ArgumentError)
38
44
  end
39
45
 
40
- it "supports :create and :remove actions" do
41
- expect { resource.action :create }.not_to raise_error
42
- expect { resource.action :remove }.not_to raise_error
43
- expect { resource.action :delete }.to raise_error(ArgumentError)
44
- end
45
-
46
46
  it "coerces forward slashes to backslashes for the path" do
47
47
  resource.path "C:/something.exe"
48
48
  expect(resource.path).to eql('C:\\something.exe')
@@ -21,33 +21,25 @@ require "spec_helper"
21
21
 
22
22
  describe Chef::Resource::WindowsEnv do
23
23
 
24
- let(:resource) { Chef::Resource::WindowsEnv.new("FOO") }
24
+ let(:resource) { Chef::Resource::WindowsEnv.new("fakey_fakerton") }
25
25
 
26
26
  it "creates a new Chef::Resource::WindowsEnv" do
27
27
  expect(resource).to be_a_kind_of(Chef::Resource)
28
28
  expect(resource).to be_a_kind_of(Chef::Resource::WindowsEnv)
29
29
  end
30
30
 
31
- it "has a name" do
32
- expect(resource.name).to eql("FOO")
31
+ it "the key_name property is the name_property" do
32
+ expect(resource.key_name).to eql("fakey_fakerton")
33
33
  end
34
34
 
35
- it "has a default action of 'create'" do
35
+ it "sets the default action as :create" do
36
36
  expect(resource.action).to eql([:create])
37
37
  end
38
38
 
39
- { :create => false, :delete => false, :modify => false, :flibber => true }.each do |action, bad_value|
40
- it "should #{bad_value ? 'not' : ''} accept #{action}" do
41
- if bad_value
42
- expect { resource.action action }.to raise_error(ArgumentError)
43
- else
44
- expect { resource.action action }.not_to raise_error
45
- end
46
- end
47
- end
48
-
49
- it "uses the object name as the key_name by default" do
50
- expect(resource.key_name).to eql("FOO")
39
+ it "supports :create, :delete, :modify actions" do
40
+ expect { resource.action :create }.not_to raise_error
41
+ expect { resource.action :delete }.not_to raise_error
42
+ expect { resource.action :modify }.not_to raise_error
51
43
  end
52
44
 
53
45
  it "accepts a string as the env value via 'value'" do
@@ -18,24 +18,43 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::WindowsFeature do
21
- let(:resource) { Chef::Resource::WindowsFeature.new("SNMP") }
21
+ let(:resource) { Chef::Resource::WindowsFeature.new("fakey_fakerton") }
22
22
 
23
23
  it "sets resource name as :windows_feature" do
24
24
  expect(resource.resource_name).to eql(:windows_feature)
25
25
  end
26
26
 
27
- it "sets the default action as :install" do
28
- expect(resource.action).to eql([:install])
27
+ it "the feature_name property is the name_property" do
28
+ expect(resource.feature_name).to eql("fakey_fakerton")
29
29
  end
30
30
 
31
- it "sets the feature_name property as its name" do
32
- expect(resource.feature_name).to eql("SNMP")
31
+ it "sets the default action as :install" do
32
+ expect(resource.action).to eql([:install])
33
33
  end
34
34
 
35
- it "supports :install, :remove, and :delete actions" do
35
+ it "supports :delete, :install, :remove actions" do
36
+ expect { resource.action :delete }.not_to raise_error
36
37
  expect { resource.action :install }.not_to raise_error
37
38
  expect { resource.action :remove }.not_to raise_error
38
- expect { resource.action :delete }.not_to raise_error
39
- expect { resource.action :update }.to raise_error(ArgumentError)
40
39
  end
40
+
41
+ it "all property defaults to false" do
42
+ expect(resource.all).to eql(false)
43
+ end
44
+
45
+ it "management_tools property defaults to false" do
46
+ expect(resource.management_tools).to eql(false)
47
+ end
48
+
49
+ it "timeout property defaults to 600" do
50
+ expect(resource.timeout).to eql(600)
51
+ end
52
+
53
+ it "install_method accepts :windows_feature_dism, :windows_feature_powershell, and :windows_feature_servermanagercmd" do
54
+ expect { resource.install_method :windows_feature_dism }.not_to raise_error
55
+ expect { resource.install_method :windows_feature_powershell }.not_to raise_error
56
+ expect { resource.install_method :windows_feature_servermanagercmd }.not_to raise_error
57
+ expect { resource.install_method "windows_feature_servermanagercmd" }.to raise_error(ArgumentError)
58
+ end
59
+
41
60
  end
@@ -18,7 +18,10 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::WindowsFeatureDism do
21
- let(:resource) { Chef::Resource::WindowsFeatureDism.new(%w{SNMP DHCP}) }
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::WindowsFeatureDism.new(%w{SNMP DHCP}, run_context) }
22
25
 
23
26
  it "sets resource name as :windows_feature_dism" do
24
27
  expect(resource.resource_name).to eql(:windows_feature_dism)
@@ -28,24 +31,42 @@ describe Chef::Resource::WindowsFeatureDism do
28
31
  expect(resource.action).to eql([:install])
29
32
  end
30
33
 
31
- it "sets the feature_name property as its name property" do
34
+ it "the feature_name property is the name_property" do
35
+ node.automatic[:platform_version] = "6.2"
32
36
  expect(resource.feature_name).to eql(%w{snmp dhcp})
33
37
  end
34
38
 
35
- it "coerces comma separated lists of features to a lowercase array" do
39
+ it "sets the default action as :install" do
40
+ expect(resource.action).to eql([:install])
41
+ end
42
+
43
+ it "supports :delete, :install, :remove actions" do
44
+ expect { resource.action :delete }.not_to raise_error
45
+ expect { resource.action :install }.not_to raise_error
46
+ expect { resource.action :remove }.not_to raise_error
47
+ end
48
+
49
+ it "coerces comma separated lists of features to a lowercase array on 2012+" do
50
+ node.automatic[:platform_version] = "6.2"
36
51
  resource.feature_name "SNMP, DHCP"
37
52
  expect(resource.feature_name).to eql(%w{snmp dhcp})
38
53
  end
39
54
 
40
- it "coerces a single feature as a String to a lowercase array" do
55
+ it "coerces a single feature as a String to a lowercase array on 2012+" do
56
+ node.automatic[:platform_version] = "6.2"
41
57
  resource.feature_name "SNMP"
42
58
  expect(resource.feature_name).to eql(["snmp"])
43
59
  end
44
60
 
45
- it "supports :install, :remove, and :delete actions" do
46
- expect { resource.action :install }.not_to raise_error
47
- expect { resource.action :remove }.not_to raise_error
48
- expect { resource.action :delete }.not_to raise_error
49
- expect { resource.action :update }.to raise_error(ArgumentError)
61
+ it "coerces comma separated lists of features to an array, but preserves case on < 2012" do
62
+ node.automatic[:platform_version] = "6.1"
63
+ resource.feature_name "SNMP, DHCP"
64
+ expect(resource.feature_name).to eql(%w{SNMP DHCP})
65
+ end
66
+
67
+ it "coerces a single feature as a String to an array, but preserves case on < 2012" do
68
+ node.automatic[:platform_version] = "6.1"
69
+ resource.feature_name "SNMP"
70
+ expect(resource.feature_name).to eql(["SNMP"])
50
71
  end
51
72
  end