chef 13.6.4 → 13.7.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/acceptance/Gemfile +2 -2
  4. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
  5. data/distro/powershell/chef/chef.psm1 +1 -5
  6. data/lib/chef/api_client.rb +5 -5
  7. data/lib/chef/api_client_v1.rb +6 -6
  8. data/lib/chef/application.rb +3 -2
  9. data/lib/chef/application/knife.rb +4 -0
  10. data/lib/chef/chef_class.rb +2 -2
  11. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  12. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
  13. data/lib/chef/client.rb +3 -3
  14. data/lib/chef/cookbook/chefignore.rb +4 -0
  15. data/lib/chef/cookbook/cookbook_collection.rb +2 -2
  16. data/lib/chef/cookbook/metadata.rb +2 -2
  17. data/lib/chef/data_bag.rb +1 -1
  18. data/lib/chef/deprecated.rb +10 -0
  19. data/lib/chef/event_dispatch/base.rb +2 -2
  20. data/lib/chef/http.rb +10 -10
  21. data/lib/chef/knife.rb +16 -15
  22. data/lib/chef/knife/configure.rb +12 -36
  23. data/lib/chef/knife/cookbook_upload.rb +4 -4
  24. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  25. data/lib/chef/knife/core/status_presenter.rb +6 -2
  26. data/lib/chef/knife/core/ui.rb +1 -1
  27. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  28. data/lib/chef/knife/data_bag_show.rb +1 -1
  29. data/lib/chef/knife/edit.rb +1 -1
  30. data/lib/chef/knife/ssh.rb +47 -35
  31. data/lib/chef/knife/user_create.rb +2 -0
  32. data/lib/chef/knife/user_delete.rb +2 -0
  33. data/lib/chef/knife/user_edit.rb +2 -0
  34. data/lib/chef/knife/user_reregister.rb +2 -0
  35. data/lib/chef/knife/user_show.rb +2 -0
  36. data/lib/chef/mixin/powershell_out.rb +1 -1
  37. data/lib/chef/node/attribute.rb +46 -70
  38. data/lib/chef/node/attribute_collections.rb +5 -5
  39. data/lib/chef/node/common_api.rb +1 -1
  40. data/lib/chef/node/immutable_collections.rb +180 -23
  41. data/lib/chef/node/mixin/state_tracking.rb +6 -6
  42. data/lib/chef/node_map.rb +63 -45
  43. data/lib/chef/property.rb +8 -8
  44. data/lib/chef/provider.rb +9 -3
  45. data/lib/chef/provider/apt_preference.rb +1 -1
  46. data/lib/chef/provider/apt_repository.rb +1 -1
  47. data/lib/chef/provider/apt_update.rb +1 -1
  48. data/lib/chef/provider/file.rb +1 -1
  49. data/lib/chef/provider/group/dscl.rb +6 -2
  50. data/lib/chef/provider/ifconfig.rb +96 -34
  51. data/lib/chef/provider/launchd.rb +0 -1
  52. data/lib/chef/provider/log.rb +3 -13
  53. data/lib/chef/provider/package/dnf.rb +1 -1
  54. data/lib/chef/provider/package/smartos.rb +2 -2
  55. data/lib/chef/provider/reboot.rb +12 -0
  56. data/lib/chef/provider/remote_directory.rb +1 -1
  57. data/lib/chef/provider/remote_file/http.rb +3 -2
  58. data/lib/chef/provider/service/solaris.rb +6 -2
  59. data/lib/chef/provider/systemd_unit.rb +34 -33
  60. data/lib/chef/provider/user/dscl.rb +1 -1
  61. data/lib/chef/provider/windows_path.rb +6 -7
  62. data/lib/chef/provider/windows_task.rb +89 -33
  63. data/lib/chef/provider/yum_repository.rb +24 -9
  64. data/lib/chef/resource/apt_package.rb +1 -0
  65. data/lib/chef/resource/apt_preference.rb +4 -0
  66. data/lib/chef/resource/apt_repository.rb +4 -0
  67. data/lib/chef/resource/apt_update.rb +3 -0
  68. data/lib/chef/resource/bash.rb +4 -0
  69. data/lib/chef/resource/batch.rb +5 -0
  70. data/lib/chef/resource/bff_package.rb +4 -0
  71. data/lib/chef/resource/breakpoint.rb +6 -0
  72. data/lib/chef/resource/cab_package.rb +6 -6
  73. data/lib/chef/resource/chef_gem.rb +13 -0
  74. data/lib/chef/resource/chocolatey_package.rb +4 -6
  75. data/lib/chef/resource/cookbook_file.rb +13 -15
  76. data/lib/chef/resource/cron.rb +2 -0
  77. data/lib/chef/resource/csh.rb +4 -0
  78. data/lib/chef/resource/directory.rb +8 -26
  79. data/lib/chef/resource/dnf_package.rb +5 -0
  80. data/lib/chef/resource/dpkg_package.rb +2 -0
  81. data/lib/chef/resource/dsc_resource.rb +5 -0
  82. data/lib/chef/resource/dsc_script.rb +6 -0
  83. data/lib/chef/resource/env.rb +3 -0
  84. data/lib/chef/resource/erl_call.rb +5 -0
  85. data/lib/chef/resource/execute.rb +5 -1
  86. data/lib/chef/resource/file.rb +2 -1
  87. data/lib/chef/resource/file/verification.rb +10 -0
  88. data/lib/chef/resource/freebsd_package.rb +10 -2
  89. data/lib/chef/resource/gem_package.rb +2 -0
  90. data/lib/chef/resource/git.rb +2 -0
  91. data/lib/chef/resource/group.rb +1 -0
  92. data/lib/chef/resource/homebrew_package.rb +3 -0
  93. data/lib/chef/resource/http_request.rb +2 -0
  94. data/lib/chef/resource/ifconfig.rb +23 -150
  95. data/lib/chef/resource/ips_package.rb +1 -0
  96. data/lib/chef/resource/ksh.rb +6 -0
  97. data/lib/chef/resource/launchd.rb +5 -4
  98. data/lib/chef/resource/link.rb +10 -0
  99. data/lib/chef/resource/log.rb +19 -46
  100. data/lib/chef/resource/macports_package.rb +1 -0
  101. data/lib/chef/resource/mdadm.rb +4 -0
  102. data/lib/chef/resource/mount.rb +1 -0
  103. data/lib/chef/resource/msu_package.rb +7 -8
  104. data/lib/chef/resource/ohai.rb +2 -0
  105. data/lib/chef/resource/openbsd_package.rb +3 -0
  106. data/lib/chef/resource/osx_profile.rb +10 -40
  107. data/lib/chef/resource/package.rb +6 -0
  108. data/lib/chef/resource/pacman_package.rb +1 -0
  109. data/lib/chef/resource/paludis_package.rb +3 -0
  110. data/lib/chef/resource/perl.rb +4 -0
  111. data/lib/chef/resource/portage_package.rb +1 -0
  112. data/lib/chef/resource/powershell_package.rb +5 -0
  113. data/lib/chef/resource/powershell_script.rb +8 -0
  114. data/lib/chef/resource/python.rb +4 -0
  115. data/lib/chef/resource/reboot.rb +14 -20
  116. data/lib/chef/resource/registry_key.rb +1 -0
  117. data/lib/chef/resource/remote_directory.rb +3 -0
  118. data/lib/chef/resource/remote_file.rb +2 -0
  119. data/lib/chef/resource/resource_notification.rb +17 -0
  120. data/lib/chef/resource/route.rb +1 -0
  121. data/lib/chef/resource/rpm_package.rb +1 -0
  122. data/lib/chef/resource/ruby.rb +4 -0
  123. data/lib/chef/resource/ruby_block.rb +3 -0
  124. data/lib/chef/resource/script.rb +4 -0
  125. data/lib/chef/resource/service.rb +1 -0
  126. data/lib/chef/resource/smartos_package.rb +1 -0
  127. data/lib/chef/resource/solaris_package.rb +1 -0
  128. data/lib/chef/resource/subversion.rb +1 -0
  129. data/lib/chef/resource/systemd_unit.rb +6 -0
  130. data/lib/chef/resource/template.rb +9 -0
  131. data/lib/chef/resource/user.rb +1 -0
  132. data/lib/chef/resource/windows_package.rb +2 -0
  133. data/lib/chef/resource/windows_path.rb +5 -10
  134. data/lib/chef/resource/windows_service.rb +3 -0
  135. data/lib/chef/resource/windows_task.rb +66 -87
  136. data/lib/chef/resource/yum_repository.rb +26 -22
  137. data/lib/chef/resource/zypper_package.rb +2 -0
  138. data/lib/chef/resource/zypper_repository.rb +6 -1
  139. data/lib/chef/run_context.rb +8 -2
  140. data/lib/chef/server_api.rb +1 -0
  141. data/lib/chef/util/selinux.rb +5 -4
  142. data/lib/chef/version.rb +1 -1
  143. data/lib/chef/version/platform.rb +18 -0
  144. data/lib/chef/version_constraint/platform.rb +2 -0
  145. data/spec/data/client.d_00/02-strings.rb +2 -0
  146. data/spec/functional/assets/chefinittest +6 -4
  147. data/spec/functional/knife/ssh_spec.rb +54 -7
  148. data/spec/functional/resource/bff_spec.rb +3 -3
  149. data/spec/functional/resource/ifconfig_spec.rb +1 -1
  150. data/spec/functional/resource/mount_spec.rb +7 -3
  151. data/spec/functional/resource/user/useradd_spec.rb +4 -4
  152. data/spec/functional/resource/windows_task_spec.rb +6 -6
  153. data/spec/functional/win32/security_spec.rb +7 -33
  154. data/spec/integration/knife/data_bag_show_spec.rb +1 -1
  155. data/spec/integration/recipes/noop_resource_spec.rb +1 -1
  156. data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
  157. data/spec/integration/recipes/resource_action_spec.rb +2 -2
  158. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
  159. data/spec/spec_helper.rb +19 -0
  160. data/spec/support/shared/functional/execute_resource.rb +1 -1
  161. data/spec/support/shared/unit/application_dot_d.rb +2 -0
  162. data/spec/support/shared/unit/execute_resource.rb +8 -1
  163. data/spec/support/shared/unit/provider/file.rb +9 -1
  164. data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
  165. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
  166. data/spec/unit/client_spec.rb +1 -1
  167. data/spec/unit/deprecated_spec.rb +4 -4
  168. data/spec/unit/http_spec.rb +9 -0
  169. data/spec/unit/knife/bootstrap_spec.rb +5 -0
  170. data/spec/unit/knife/configure_spec.rb +10 -60
  171. data/spec/unit/knife/data_bag_create_spec.rb +40 -2
  172. data/spec/unit/knife/data_bag_show_spec.rb +16 -2
  173. data/spec/unit/knife/ssh_spec.rb +85 -39
  174. data/spec/unit/knife_spec.rb +2 -0
  175. data/spec/unit/lwrp_spec.rb +5 -3
  176. data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
  177. data/spec/unit/node/attribute_spec.rb +55 -24
  178. data/spec/unit/node/immutable_collections_spec.rb +28 -14
  179. data/spec/unit/node/vivid_mash_spec.rb +27 -10
  180. data/spec/unit/node_map_spec.rb +34 -0
  181. data/spec/unit/property_spec.rb +13 -13
  182. data/spec/unit/provider/group/dscl_spec.rb +14 -5
  183. data/spec/unit/provider/ifconfig_spec.rb +10 -3
  184. data/spec/unit/provider/remote_file/http_spec.rb +23 -19
  185. data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
  186. data/spec/unit/provider/user/dscl_spec.rb +26 -0
  187. data/spec/unit/provider/windows_task_spec.rb +148 -4
  188. data/spec/unit/provider_spec.rb +1 -1
  189. data/spec/unit/resource/apt_package_spec.rb +1 -1
  190. data/spec/unit/resource/bash_spec.rb +8 -10
  191. data/spec/unit/resource/batch_spec.rb +1 -1
  192. data/spec/unit/resource/cab_package_spec.rb +19 -1
  193. data/spec/unit/resource/chef_gem_spec.rb +3 -3
  194. data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
  195. data/spec/unit/resource/conditional_spec.rb +2 -2
  196. data/spec/unit/resource/cookbook_file_spec.rb +24 -30
  197. data/spec/unit/resource/cron_spec.rb +79 -82
  198. data/spec/unit/resource/csh_spec.rb +8 -10
  199. data/spec/unit/resource/deploy_spec.rb +1 -1
  200. data/spec/unit/resource/directory_spec.rb +28 -31
  201. data/spec/unit/resource/dnf_package_spec.rb +9 -9
  202. data/spec/unit/resource/env_spec.rb +7 -7
  203. data/spec/unit/resource/erl_call_spec.rb +9 -9
  204. data/spec/unit/resource/execute_spec.rb +6 -6
  205. data/spec/unit/resource/file/verification_spec.rb +18 -4
  206. data/spec/unit/resource/file_spec.rb +53 -56
  207. data/spec/unit/resource/freebsd_package_spec.rb +7 -7
  208. data/spec/unit/resource/gem_package_spec.rb +1 -1
  209. data/spec/unit/resource/git_spec.rb +7 -9
  210. data/spec/unit/resource/group_spec.rb +60 -70
  211. data/spec/unit/resource/http_request_spec.rb +16 -19
  212. data/spec/unit/resource/ifconfig_spec.rb +3 -3
  213. data/spec/unit/resource/ips_package_spec.rb +3 -5
  214. data/spec/unit/resource/ksh_spec.rb +8 -10
  215. data/spec/unit/resource/launchd_spec.rb +17 -10
  216. data/spec/unit/resource/link_spec.rb +53 -53
  217. data/spec/unit/resource/log_spec.rb +24 -28
  218. data/spec/unit/resource/mdadm_spec.rb +42 -44
  219. data/spec/unit/resource/mount_spec.rb +97 -99
  220. data/spec/unit/resource/msu_package_spec.rb +14 -8
  221. data/spec/unit/resource/ohai_spec.rb +15 -17
  222. data/spec/unit/resource/openbsd_package_spec.rb +3 -3
  223. data/spec/unit/resource/osx_profile_spec.rb +7 -7
  224. data/spec/unit/resource/package_spec.rb +36 -40
  225. data/spec/unit/resource/perl_spec.rb +8 -11
  226. data/spec/unit/resource/portage_package_spec.rb +8 -10
  227. data/spec/unit/resource/powershell_package_spec.rb +9 -9
  228. data/spec/unit/resource/python_spec.rb +8 -11
  229. data/spec/unit/resource/reboot_spec.rb +50 -0
  230. data/spec/unit/resource/registry_key_spec.rb +84 -98
  231. data/spec/unit/resource/remote_directory_spec.rb +40 -42
  232. data/spec/unit/resource/remote_file_spec.rb +78 -80
  233. data/spec/unit/resource/route_spec.rb +42 -44
  234. data/spec/unit/resource/rpm_package_spec.rb +5 -7
  235. data/spec/unit/resource/ruby_block_spec.rb +14 -16
  236. data/spec/unit/resource/ruby_spec.rb +8 -12
  237. data/spec/unit/resource/scm_spec.rb +66 -69
  238. data/spec/unit/resource/script_spec.rb +1 -1
  239. data/spec/unit/resource/service_spec.rb +80 -83
  240. data/spec/unit/resource/smartos_package_spec.rb +5 -0
  241. data/spec/unit/resource/solaris_package_spec.rb +3 -5
  242. data/spec/unit/resource/subversion_spec.rb +18 -16
  243. data/spec/unit/resource/systemd_unit_spec.rb +50 -54
  244. data/spec/unit/resource/template_spec.rb +56 -61
  245. data/spec/unit/resource/user_spec.rb +47 -53
  246. data/spec/unit/resource/windows_package_spec.rb +1 -1
  247. data/spec/unit/resource/windows_path_spec.rb +11 -8
  248. data/spec/unit/resource/windows_task_spec.rb +129 -33
  249. data/spec/unit/resource/yum_package_spec.rb +1 -1
  250. data/spec/unit/resource/yum_repository_spec.rb +61 -8
  251. data/spec/unit/resource/zypper_repository_spec.rb +17 -18
  252. data/spec/unit/util/selinux_spec.rb +3 -6
  253. data/tasks/dependencies.rb +0 -5
  254. data/tasks/rspec.rb +1 -1
  255. metadata +6 -6
  256. data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
  257. data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
@@ -36,7 +36,7 @@ describe Chef::Resource::DnfPackage, "arch" do
36
36
  @resource = Chef::Resource::DnfPackage.new("foo")
37
37
  end
38
38
 
39
- it "should set the arch variable to whatever is passed in" do
39
+ it "sets the arch variable to whatever is passed in" do
40
40
  @resource.arch("i386")
41
41
  expect(@resource.arch).to eql(["i386"])
42
42
  end
@@ -47,40 +47,40 @@ describe Chef::Resource::DnfPackage, "flush_cache" do
47
47
  @resource = Chef::Resource::DnfPackage.new("foo")
48
48
  end
49
49
 
50
- it "should default the flush timing to false" do
50
+ it "defaults the flush timing to false" do
51
51
  flush_hash = { :before => false, :after => false }
52
52
  expect(@resource.flush_cache).to eq(flush_hash)
53
53
  end
54
54
 
55
- it "should allow you to set the flush timing with an array" do
55
+ it "allows you to set the flush timing with an array" do
56
56
  flush_array = [ :before, :after ]
57
57
  flush_hash = { :before => true, :after => true }
58
58
  @resource.flush_cache(flush_array)
59
59
  expect(@resource.flush_cache).to eq(flush_hash)
60
60
  end
61
61
 
62
- it "should allow you to set the flush timing with a hash" do
62
+ it "allows you to set the flush timing with a hash" do
63
63
  flush_hash = { :before => true, :after => true }
64
64
  @resource.flush_cache(flush_hash)
65
65
  expect(@resource.flush_cache).to eq(flush_hash)
66
66
  end
67
67
 
68
- it "should allow 'true' for flush_cache" do
68
+ it "allows 'true' for flush_cache" do
69
69
  @resource.flush_cache(true)
70
70
  expect(@resource.flush_cache).to eq({ before: true, after: true })
71
71
  end
72
72
 
73
- it "should allow 'false' for flush_cache" do
73
+ it "allows 'false' for flush_cache" do
74
74
  @resource.flush_cache(false)
75
75
  expect(@resource.flush_cache).to eq({ before: false, after: false })
76
76
  end
77
77
 
78
- it "should allow ':before' for flush_cache" do
78
+ it "allows ':before' for flush_cache" do
79
79
  @resource.flush_cache(:before)
80
80
  expect(@resource.flush_cache).to eq({ before: true, after: false })
81
81
  end
82
82
 
83
- it "should allow ':after' for flush_cache" do
83
+ it "allows ':after' for flush_cache" do
84
84
  @resource.flush_cache(:after)
85
85
  expect(@resource.flush_cache).to eq({ before: false, after: true })
86
86
  end
@@ -91,7 +91,7 @@ describe Chef::Resource::DnfPackage, "allow_downgrade" do
91
91
  @resource = Chef::Resource::DnfPackage.new("foo")
92
92
  end
93
93
 
94
- it "should allow you to specify whether allow_downgrade is true or false" do
94
+ it "allows you to specify whether allow_downgrade is true or false" do
95
95
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
96
96
  expect { @resource.allow_downgrade true }.not_to raise_error
97
97
  expect { @resource.allow_downgrade false }.not_to raise_error
@@ -25,16 +25,16 @@ describe Chef::Resource::Env do
25
25
  @resource = Chef::Resource::Env.new("FOO")
26
26
  end
27
27
 
28
- it "should create a new Chef::Resource::Env" do
28
+ it "creates a new Chef::Resource::Env" do
29
29
  expect(@resource).to be_a_kind_of(Chef::Resource)
30
30
  expect(@resource).to be_a_kind_of(Chef::Resource::Env)
31
31
  end
32
32
 
33
- it "should have a name" do
33
+ it "has a name" do
34
34
  expect(@resource.name).to eql("FOO")
35
35
  end
36
36
 
37
- it "should have a default action of 'create'" do
37
+ it "has a default action of 'create'" do
38
38
  expect(@resource.action).to eql([:create])
39
39
  end
40
40
 
@@ -48,19 +48,19 @@ describe Chef::Resource::Env do
48
48
  end
49
49
  end
50
50
 
51
- it "should use the object name as the key_name by default" do
51
+ it "uses the object name as the key_name by default" do
52
52
  expect(@resource.key_name).to eql("FOO")
53
53
  end
54
54
 
55
- it "should accept a string as the env value via 'value'" do
55
+ it "accepts a string as the env value via 'value'" do
56
56
  expect { @resource.value "bar" }.not_to raise_error
57
57
  end
58
58
 
59
- it "should not accept a Hash for the env value via 'to'" do
59
+ it "does not accept a Hash for the env value via 'to'" do
60
60
  expect { @resource.value Hash.new }.to raise_error(ArgumentError)
61
61
  end
62
62
 
63
- it "should allow you to set an env value via 'to'" do
63
+ it "allows you to set an env value via 'to'" do
64
64
  @resource.value "bar"
65
65
  expect(@resource.value).to eql("bar")
66
66
  end
@@ -25,44 +25,44 @@ describe Chef::Resource::ErlCall do
25
25
  @resource = Chef::Resource::ErlCall.new("fakey_fakerton")
26
26
  end
27
27
 
28
- it "should create a new Chef::Resource::ErlCall" do
28
+ it "creates a new Chef::Resource::ErlCall" do
29
29
  expect(@resource).to be_a_kind_of(Chef::Resource)
30
30
  expect(@resource).to be_a_kind_of(Chef::Resource::ErlCall)
31
31
  end
32
32
 
33
- it "should have a resource name of :erl_call" do
33
+ it "has a resource name of :erl_call" do
34
34
  expect(@resource.resource_name).to eql(:erl_call)
35
35
  end
36
36
 
37
- it "should have a default action of run" do
37
+ it "has a default action of run" do
38
38
  expect(@resource.action).to eql([:run])
39
39
  end
40
40
 
41
- it "should accept run as an action" do
41
+ it "accepts run as an action" do
42
42
  expect { @resource.action :run }.not_to raise_error
43
43
  end
44
44
 
45
- it "should allow you to set the code attribute" do
45
+ it "allows you to set the code attribute" do
46
46
  @resource.code "q()."
47
47
  expect(@resource.code).to eql("q().")
48
48
  end
49
49
 
50
- it "should allow you to set the cookie attribute" do
50
+ it "allows you to set the cookie attribute" do
51
51
  @resource.cookie "nomnomnom"
52
52
  expect(@resource.cookie).to eql("nomnomnom")
53
53
  end
54
54
 
55
- it "should allow you to set the distributed attribute" do
55
+ it "allows you to set the distributed attribute" do
56
56
  @resource.distributed true
57
57
  expect(@resource.distributed).to eql(true)
58
58
  end
59
59
 
60
- it "should allow you to set the name_type attribute" do
60
+ it "allows you to set the name_type attribute" do
61
61
  @resource.name_type "sname"
62
62
  expect(@resource.name_type).to eql("sname")
63
63
  end
64
64
 
65
- it "should allow you to set the node_name attribute" do
65
+ it "allows you to set the node_name attribute" do
66
66
  @resource.node_name "chef@erlang"
67
67
  expect(@resource.node_name).to eql("chef@erlang")
68
68
  end
@@ -24,7 +24,7 @@ describe Chef::Resource::Execute do
24
24
  let(:execute_resource) { Chef::Resource::Execute.new(resource_instance_name) }
25
25
  it_behaves_like "an execute resource"
26
26
 
27
- it "default guard interpreter should be :execute interpreter" do
27
+ it "default guard interpreter is :execute interpreter" do
28
28
  expect(execute_resource.guard_interpreter).to be(:execute)
29
29
  end
30
30
 
@@ -59,13 +59,13 @@ describe Chef::Resource::Execute do
59
59
 
60
60
  shared_examples_for "it received valid credentials" do
61
61
  describe "the validation method" do
62
- it "should not raise an error" do
62
+ it "does not raise an error" do
63
63
  expect { execute_resource.validate_identity_platform(username, password, domain) }.not_to raise_error
64
64
  end
65
65
  end
66
66
 
67
67
  describe "the name qualification method" do
68
- it "should correctly translate the user and domain" do
68
+ it "correctly translates the user and domain" do
69
69
  identity = nil
70
70
  expect { identity = execute_resource.qualify_user(username, password, domain) }.not_to raise_error
71
71
  expect(identity[:domain]).to eq(domain)
@@ -76,7 +76,7 @@ describe Chef::Resource::Execute do
76
76
 
77
77
  shared_examples_for "it received invalid credentials" do
78
78
  describe "the validation method" do
79
- it "should raise an error" do
79
+ it "raises an error" do
80
80
  expect { execute_resource.validate_identity_platform(username, password, domain, elevated) }.to raise_error(ArgumentError)
81
81
  end
82
82
  end
@@ -84,7 +84,7 @@ describe Chef::Resource::Execute do
84
84
 
85
85
  shared_examples_for "it received invalid username and domain" do
86
86
  describe "the validation method" do
87
- it "should raise an error" do
87
+ it "raises an error" do
88
88
  expect { execute_resource.qualify_user(username, password, domain) }.to raise_error(ArgumentError)
89
89
  end
90
90
  end
@@ -92,7 +92,7 @@ describe Chef::Resource::Execute do
92
92
 
93
93
  shared_examples_for "it received credentials that are not valid on the platform" do
94
94
  describe "the validation method" do
95
- it "should raise an error" do
95
+ it "raises an error" do
96
96
  expect { execute_resource.validate_identity_platform(username, password, domain) }.to raise_error(Chef::Exceptions::UnsupportedPlatform)
97
97
  end
98
98
  end
@@ -66,6 +66,11 @@ describe Chef::Resource::File::Verification do
66
66
  v = Chef::Resource::File::Verification.new(parent_resource, nil, {}, &f_block)
67
67
  expect(v.verify(temp_path)).to eq(false)
68
68
  end
69
+
70
+ it "responds to to_s" do
71
+ v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {}
72
+ expect(v.to_s).to eq("<Proc>")
73
+ end
69
74
  end
70
75
 
71
76
  context "with a verification command(String)" do
@@ -110,23 +115,32 @@ describe Chef::Resource::File::Verification do
110
115
  v = Chef::Resource::File::Verification.new(parent_resource, "true", {})
111
116
  expect(v.verify(temp_path)).to eq(true)
112
117
  end
118
+
119
+ it "responds to to_s" do
120
+ v = Chef::Resource::File::Verification.new(parent_resource, "some command --here", {})
121
+ expect(v.to_s).to eq("some command --here")
122
+ end
113
123
  end
114
124
 
115
125
  context "with a named verification(Symbol)" do
126
+ let(:registered_verification) { double("registered_verification") }
127
+ subject { described_class.new(parent_resource, :cats, {}) }
116
128
  before(:each) do
117
129
  class Chef::Resource::File::Verification::Turtle < Chef::Resource::File::Verification
118
130
  provides :cats
119
131
  def verify(path, opts)
120
132
  end
121
133
  end
134
+ allow(Chef::Resource::File::Verification::Turtle).to receive(:new).and_return(registered_verification)
122
135
  end
123
136
 
124
137
  it "delegates to the registered verification" do
125
- registered_verification = double()
126
- allow(Chef::Resource::File::Verification::Turtle).to receive(:new).and_return(registered_verification)
127
- v = Chef::Resource::File::Verification.new(parent_resource, :cats, {})
128
138
  expect(registered_verification).to receive(:verify).with(temp_path, {})
129
- v.verify(temp_path, {})
139
+ subject.verify(temp_path, {})
140
+ end
141
+
142
+ it "responds to to_s" do
143
+ expect(subject.to_s).to eq(":cats (Chef::Resource::File::Verification::Turtle)")
130
144
  end
131
145
  end
132
146
  end
@@ -20,88 +20,86 @@ require "spec_helper"
20
20
 
21
21
  describe Chef::Resource::File do
22
22
 
23
- before(:each) do
24
- @resource = Chef::Resource::File.new("fakey_fakerton")
25
- end
23
+ let(:resource) { Chef::Resource::File.new("fakey_fakerton") }
26
24
 
27
- it "should have a name" do
28
- expect(@resource.name).to eql("fakey_fakerton")
25
+ it "has a name" do
26
+ expect(resource.name).to eql("fakey_fakerton")
29
27
  end
30
28
 
31
- it "should have a default action of 'create'" do
32
- expect(@resource.action).to eql([:create])
29
+ it "has a default action of 'create'" do
30
+ expect(resource.action).to eql([:create])
33
31
  end
34
32
 
35
- it "should have a default content of nil" do
36
- expect(@resource.content).to be_nil
33
+ it "has a default content of nil" do
34
+ expect(resource.content).to be_nil
37
35
  end
38
36
 
39
- it "should be set to back up 5 files by default" do
40
- expect(@resource.backup).to eql(5)
37
+ it "is set to back up 5 files by default" do
38
+ expect(resource.backup).to eql(5)
41
39
  end
42
40
 
43
- it "should only accept strings for content" do
44
- expect { @resource.content 5 }.to raise_error(ArgumentError)
45
- expect { @resource.content :foo }.to raise_error(ArgumentError)
46
- expect { @resource.content "hello" => "there" }.to raise_error(ArgumentError)
47
- expect { @resource.content "hi" }.not_to raise_error
41
+ it "only accept strings for content" do
42
+ expect { resource.content 5 }.to raise_error(ArgumentError)
43
+ expect { resource.content :foo }.to raise_error(ArgumentError)
44
+ expect { resource.content "hello" => "there" }.to raise_error(ArgumentError)
45
+ expect { resource.content "hi" }.not_to raise_error
48
46
  end
49
47
 
50
- it "should only accept false or a number for backup" do
51
- expect { @resource.backup true }.to raise_error(ArgumentError)
52
- expect { @resource.backup false }.not_to raise_error
53
- expect { @resource.backup 10 }.not_to raise_error
54
- expect { @resource.backup "blues" }.to raise_error(ArgumentError)
48
+ it "only accept false or a number for backup" do
49
+ expect { resource.backup true }.to raise_error(ArgumentError)
50
+ expect { resource.backup false }.not_to raise_error
51
+ expect { resource.backup 10 }.not_to raise_error
52
+ expect { resource.backup "blues" }.to raise_error(ArgumentError)
55
53
  end
56
54
 
57
- it "should accept a sha256 for checksum" do
58
- expect { @resource.checksum "0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa" }.not_to raise_error
59
- expect { @resource.checksum "monkey!" }.to raise_error(ArgumentError)
55
+ it "accepts a sha256 for checksum" do
56
+ expect { resource.checksum "0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa" }.not_to raise_error
57
+ expect { resource.checksum "monkey!" }.to raise_error(ArgumentError)
60
58
  end
61
59
 
62
- it "should accept create, delete or touch for action" do
63
- expect { @resource.action :create }.not_to raise_error
64
- expect { @resource.action :delete }.not_to raise_error
65
- expect { @resource.action :touch }.not_to raise_error
66
- expect { @resource.action :blues }.to raise_error(ArgumentError)
60
+ it "accepts create, delete or touch for action" do
61
+ expect { resource.action :create }.not_to raise_error
62
+ expect { resource.action :delete }.not_to raise_error
63
+ expect { resource.action :touch }.not_to raise_error
64
+ expect { resource.action :blues }.to raise_error(ArgumentError)
67
65
  end
68
66
 
69
- it "should accept a block, symbol, or string for verify" do
70
- expect { @resource.verify {} }.not_to raise_error
71
- expect { @resource.verify "" }.not_to raise_error
72
- expect { @resource.verify :json }.not_to raise_error
73
- expect { @resource.verify true }.to raise_error(ArgumentError)
74
- expect { @resource.verify false }.to raise_error(ArgumentError)
67
+ it "accepts a block, symbol, or string for verify" do
68
+ expect { resource.verify {} }.not_to raise_error
69
+ expect { resource.verify "" }.not_to raise_error
70
+ expect { resource.verify :json }.not_to raise_error
71
+ expect { resource.verify true }.to raise_error(ArgumentError)
72
+ expect { resource.verify false }.to raise_error(ArgumentError)
75
73
  end
76
74
 
77
- it "should accept multiple verify statements" do
78
- @resource.verify "foo"
79
- @resource.verify "bar"
80
- @resource.verify.length == 2
75
+ it "accepts multiple verify statements" do
76
+ resource.verify "foo"
77
+ resource.verify "bar"
78
+ resource.verify.length == 2
81
79
  end
82
80
 
83
- it "should use the object name as the path by default" do
84
- expect(@resource.path).to eql("fakey_fakerton")
81
+ it "uses the object name as the path by default" do
82
+ expect(resource.path).to eql("fakey_fakerton")
85
83
  end
86
84
 
87
- it "should accept a string as the path" do
88
- expect { @resource.path "/tmp" }.not_to raise_error
89
- expect(@resource.path).to eql("/tmp")
90
- expect { @resource.path Hash.new }.to raise_error(ArgumentError)
85
+ it "accepts a string as the path" do
86
+ expect { resource.path "/tmp" }.not_to raise_error
87
+ expect(resource.path).to eql("/tmp")
88
+ expect { resource.path Hash.new }.to raise_error(ArgumentError)
91
89
  end
92
90
 
93
91
  describe "when it has a path, owner, group, mode, and checksum" do
94
92
  before do
95
- @resource.path("/tmp/foo.txt")
96
- @resource.owner("root")
97
- @resource.group("wheel")
98
- @resource.mode("0644")
99
- @resource.checksum("1" * 64)
93
+ resource.path("/tmp/foo.txt")
94
+ resource.owner("root")
95
+ resource.group("wheel")
96
+ resource.mode("0644")
97
+ resource.checksum("1" * 64)
100
98
  end
101
99
 
102
100
  context "on unix", :unix_only do
103
101
  it "describes its state" do
104
- state = @resource.state_for_resource_reporter
102
+ state = resource.state_for_resource_reporter
105
103
  expect(state[:owner]).to eq("root")
106
104
  expect(state[:group]).to eq("wheel")
107
105
  expect(state[:mode]).to eq("0644")
@@ -110,21 +108,20 @@ describe Chef::Resource::File do
110
108
  end
111
109
 
112
110
  it "returns the file path as its identity" do
113
- expect(@resource.identity).to eq("/tmp/foo.txt")
111
+ expect(resource.identity).to eq("/tmp/foo.txt")
114
112
  end
115
113
 
116
114
  end
117
115
 
118
116
  describe "when access controls are set on windows", :windows_only => true do
119
117
  before do
120
- @resource.rights :read, "Everyone"
121
- @resource.rights :full_control, "DOMAIN\User"
118
+ resource.rights :read, "Everyone"
119
+ resource.rights :full_control, "DOMAIN\User"
122
120
  end
123
121
  it "describes its state including windows ACL attributes" do
124
- state = @resource.state_for_resource_reporter
122
+ state = resource.state_for_resource_reporter
125
123
  expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" },
126
124
  { :permissions => :full_control, :principals => "DOMAIN\User" } ])
127
125
  end
128
126
  end
129
-
130
127
  end
@@ -30,22 +30,22 @@ describe Chef::Resource::FreebsdPackage do
30
30
  end
31
31
 
32
32
  describe "Initialization" do
33
- it "should return a Chef::Resource::FreebsdPackage" do
33
+ it "returns a Chef::Resource::FreebsdPackage" do
34
34
  expect(@resource).to be_a_kind_of(Chef::Resource::FreebsdPackage)
35
35
  end
36
36
 
37
- it "should set the resource_name to :freebsd_package" do
37
+ it "sets the resource_name to :freebsd_package" do
38
38
  expect(@resource.resource_name).to eql(:freebsd_package)
39
39
  end
40
40
 
41
- it "should not set the provider" do
41
+ it "does not set the provider" do
42
42
  expect(@resource.provider).to be_nil
43
43
  end
44
44
  end
45
45
 
46
46
  describe "Assigning provider after creation" do
47
47
  describe "if ports specified as source" do
48
- it "should be Freebsd::Port" do
48
+ it "is Freebsd::Port" do
49
49
  @resource.source("ports")
50
50
  @resource.after_created
51
51
  expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Port)
@@ -53,7 +53,7 @@ describe Chef::Resource::FreebsdPackage do
53
53
  end
54
54
 
55
55
  describe "if freebsd_version is greater than or equal to 1000017" do
56
- it "should be Freebsd::Pkgng" do
56
+ it "is Freebsd::Pkgng" do
57
57
  [1000017, 1000018, 1000500, 1001001, 1100000].each do |freebsd_version|
58
58
  @node.automatic_attrs[:os_version] = freebsd_version
59
59
  @resource.after_created
@@ -63,7 +63,7 @@ describe Chef::Resource::FreebsdPackage do
63
63
  end
64
64
 
65
65
  describe "if pkgng enabled" do
66
- it "should be Freebsd::Pkgng" do
66
+ it "is Freebsd::Pkgng" do
67
67
  pkg_enabled = OpenStruct.new(:stdout => "yes\n")
68
68
  allow(@resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled)
69
69
  @resource.after_created
@@ -72,7 +72,7 @@ describe Chef::Resource::FreebsdPackage do
72
72
  end
73
73
 
74
74
  describe "if freebsd_version is less than 1000017 and pkgng not enabled" do
75
- it "should be Freebsd::Pkg" do
75
+ it "is Freebsd::Pkg" do
76
76
  pkg_enabled = OpenStruct.new(:stdout => "\n")
77
77
  allow(@resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled)
78
78