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
@@ -24,7 +24,7 @@ describe Chef::Resource::Script do
24
24
  let(:script_resource) { Chef::Resource::Script.new(resource_instance_name) }
25
25
  let(:resource_name) { :script }
26
26
 
27
- it "should accept a string for the interpreter" do
27
+ it "accepts a string for the interpreter" do
28
28
  script_resource.interpreter "naaaaNaNaNaaNaaNaaNaa"
29
29
  expect(script_resource.interpreter).to eql("naaaaNaNaNaaNaaNaaNaa")
30
30
  end
@@ -20,180 +20,177 @@
20
20
  require "spec_helper"
21
21
 
22
22
  describe Chef::Resource::Service do
23
+ let(:resource) { Chef::Resource::Service.new("chef") }
23
24
 
24
- before(:each) do
25
- @resource = Chef::Resource::Service.new("chef")
25
+ it "creates a new Chef::Resource::Service" do
26
+ expect(resource).to be_a_kind_of(Chef::Resource)
27
+ expect(resource).to be_a_kind_of(Chef::Resource::Service)
26
28
  end
27
29
 
28
- it "should create a new Chef::Resource::Service" do
29
- expect(@resource).to be_a_kind_of(Chef::Resource)
30
- expect(@resource).to be_a_kind_of(Chef::Resource::Service)
30
+ it "does not set a provider unless node[:init_package] is defined as systemd" do
31
+ expect(resource.provider).to eq(nil)
31
32
  end
32
33
 
33
- it "should not set a provider unless node[:init_package] is defined as systemd" do
34
- expect(@resource.provider).to eq(nil)
34
+ it "sets the service_name to the first argument to new" do
35
+ expect(resource.service_name).to eql("chef")
35
36
  end
36
37
 
37
- it "should set the service_name to the first argument to new" do
38
- expect(@resource.service_name).to eql("chef")
38
+ it "sets the pattern to be the service name by default" do
39
+ expect(resource.pattern).to eql("chef")
39
40
  end
40
41
 
41
- it "should set the pattern to be the service name by default" do
42
- expect(@resource.pattern).to eql("chef")
42
+ it "accepts a string for the service name" do
43
+ resource.service_name "something"
44
+ expect(resource.service_name).to eql("something")
43
45
  end
44
46
 
45
- it "should accept a string for the service name" do
46
- @resource.service_name "something"
47
- expect(@resource.service_name).to eql("something")
47
+ it "accepts a string for the service pattern" do
48
+ resource.pattern ".*"
49
+ expect(resource.pattern).to eql(".*")
48
50
  end
49
51
 
50
- it "should accept a string for the service pattern" do
51
- @resource.pattern ".*"
52
- expect(@resource.pattern).to eql(".*")
53
- end
54
-
55
- it "should not accept a regexp for the service pattern" do
52
+ it "does not accept a regexp for the service pattern" do
56
53
  expect do
57
- @resource.pattern /.*/
54
+ resource.pattern /.*/
58
55
  end.to raise_error(ArgumentError)
59
56
  end
60
57
 
61
- it "should accept a string for the service start command" do
62
- @resource.start_command "/etc/init.d/chef start"
63
- expect(@resource.start_command).to eql("/etc/init.d/chef start")
58
+ it "accepts a string for the service start command" do
59
+ resource.start_command "/etc/init.d/chef start"
60
+ expect(resource.start_command).to eql("/etc/init.d/chef start")
64
61
  end
65
62
 
66
- it "should not accept a regexp for the service start command" do
63
+ it "does not accept a regexp for the service start command" do
67
64
  expect do
68
- @resource.start_command /.*/
65
+ resource.start_command /.*/
69
66
  end.to raise_error(ArgumentError)
70
67
  end
71
68
 
72
- it "should accept a string for the service stop command" do
73
- @resource.stop_command "/etc/init.d/chef stop"
74
- expect(@resource.stop_command).to eql("/etc/init.d/chef stop")
69
+ it "accepts a string for the service stop command" do
70
+ resource.stop_command "/etc/init.d/chef stop"
71
+ expect(resource.stop_command).to eql("/etc/init.d/chef stop")
75
72
  end
76
73
 
77
- it "should not accept a regexp for the service stop command" do
74
+ it "does not accept a regexp for the service stop command" do
78
75
  expect do
79
- @resource.stop_command /.*/
76
+ resource.stop_command /.*/
80
77
  end.to raise_error(ArgumentError)
81
78
  end
82
79
 
83
- it "should accept a string for the service status command" do
84
- @resource.status_command "/etc/init.d/chef status"
85
- expect(@resource.status_command).to eql("/etc/init.d/chef status")
80
+ it "accepts a string for the service status command" do
81
+ resource.status_command "/etc/init.d/chef status"
82
+ expect(resource.status_command).to eql("/etc/init.d/chef status")
86
83
  end
87
84
 
88
- it "should not accept a regexp for the service status command" do
85
+ it "does not accept a regexp for the service status command" do
89
86
  expect do
90
- @resource.status_command /.*/
87
+ resource.status_command /.*/
91
88
  end.to raise_error(ArgumentError)
92
89
  end
93
90
 
94
- it "should accept a string for the service restart command" do
95
- @resource.restart_command "/etc/init.d/chef restart"
96
- expect(@resource.restart_command).to eql("/etc/init.d/chef restart")
91
+ it "accepts a string for the service restart command" do
92
+ resource.restart_command "/etc/init.d/chef restart"
93
+ expect(resource.restart_command).to eql("/etc/init.d/chef restart")
97
94
  end
98
95
 
99
- it "should not accept a regexp for the service restart command" do
96
+ it "does not accept a regexp for the service restart command" do
100
97
  expect do
101
- @resource.restart_command /.*/
98
+ resource.restart_command /.*/
102
99
  end.to raise_error(ArgumentError)
103
100
  end
104
101
 
105
- it "should accept a string for the service reload command" do
106
- @resource.reload_command "/etc/init.d/chef reload"
107
- expect(@resource.reload_command).to eql("/etc/init.d/chef reload")
102
+ it "accepts a string for the service reload command" do
103
+ resource.reload_command "/etc/init.d/chef reload"
104
+ expect(resource.reload_command).to eql("/etc/init.d/chef reload")
108
105
  end
109
106
 
110
- it "should not accept a regexp for the service reload command" do
107
+ it "does not accept a regexp for the service reload command" do
111
108
  expect do
112
- @resource.reload_command /.*/
109
+ resource.reload_command /.*/
113
110
  end.to raise_error(ArgumentError)
114
111
  end
115
112
 
116
- it "should accept a string for the service init command" do
117
- @resource.init_command "/etc/init.d/chef"
118
- expect(@resource.init_command).to eql("/etc/init.d/chef")
113
+ it "accepts a string for the service init command" do
114
+ resource.init_command "/etc/init.d/chef"
115
+ expect(resource.init_command).to eql("/etc/init.d/chef")
119
116
  end
120
117
 
121
- it "should not accept a regexp for the service init command" do
118
+ it "does not accept a regexp for the service init command" do
122
119
  expect do
123
- @resource.init_command /.*/
120
+ resource.init_command /.*/
124
121
  end.to raise_error(ArgumentError)
125
122
  end
126
123
 
127
- it "should accept an array for options" do
128
- @resource.options ["-r", "-s"]
129
- expect(@resource.options).to eql(["-r", "-s"])
124
+ it "accepts an array for options" do
125
+ resource.options ["-r", "-s"]
126
+ expect(resource.options).to eql(["-r", "-s"])
130
127
  end
131
128
 
132
- it "should accept a string for options" do
133
- @resource.options "-r"
134
- expect(@resource.options).to eql(["-r"])
129
+ it "accepts a string for options" do
130
+ resource.options "-r"
131
+ expect(resource.options).to eql(["-r"])
135
132
  end
136
133
 
137
- it "should accept a string with multiple flags for options" do
138
- @resource.options "-r -s"
139
- expect(@resource.options).to eql(["-r", "-s"])
134
+ it "accepts a string with multiple flags for options" do
135
+ resource.options "-r -s"
136
+ expect(resource.options).to eql(["-r", "-s"])
140
137
  end
141
138
 
142
- it "should not accept a boolean for options" do
139
+ it "does not accept a boolean for options" do
143
140
  expect do
144
- @resource.options true
141
+ resource.options true
145
142
  end.to raise_error(ArgumentError)
146
143
  end
147
144
 
148
145
  %w{enabled running}.each do |attrib|
149
- it "should accept true for #{attrib}" do
150
- @resource.send(attrib, true)
151
- expect(@resource.send(attrib)).to eql(true)
146
+ it "accepts true for #{attrib}" do
147
+ resource.send(attrib, true)
148
+ expect(resource.send(attrib)).to eql(true)
152
149
  end
153
150
 
154
- it "should accept false for #{attrib}" do
155
- @resource.send(attrib, false)
156
- expect(@resource.send(attrib)).to eql(false)
151
+ it "accepts false for #{attrib}" do
152
+ resource.send(attrib, false)
153
+ expect(resource.send(attrib)).to eql(false)
157
154
  end
158
155
 
159
- it "should not accept a string for #{attrib}" do
160
- expect { @resource.send(attrib, "poop") }.to raise_error(ArgumentError)
156
+ it "does not accept a string for #{attrib}" do
157
+ expect { resource.send(attrib, "poop") }.to raise_error(ArgumentError)
161
158
  end
162
159
 
163
- it "should default all the feature support to nil" do
160
+ it "defaults all the feature support to nil" do
164
161
  support_hash = { :status => nil, :restart => nil, :reload => nil }
165
- expect(@resource.supports).to eq(support_hash)
162
+ expect(resource.supports).to eq(support_hash)
166
163
  end
167
164
 
168
- it "should allow you to set what features this resource supports as a array" do
165
+ it "allows you to set what features this resource supports as a array" do
169
166
  support_array = [ :status, :restart ]
170
167
  support_hash = { :status => true, :restart => true }
171
- @resource.supports(support_array)
172
- expect(@resource.supports).to eq(support_hash)
168
+ resource.supports(support_array)
169
+ expect(resource.supports).to eq(support_hash)
173
170
  end
174
171
 
175
- it "should allow you to set what features this resource supports as a hash" do
172
+ it "allows you to set what features this resource supports as a hash" do
176
173
  support_hash = { :status => true, :restart => true }
177
- @resource.supports(support_hash)
178
- expect(@resource.supports).to eq(support_hash)
174
+ resource.supports(support_hash)
175
+ expect(resource.supports).to eq(support_hash)
179
176
  end
180
177
  end
181
178
 
182
179
  describe "when it has pattern and supports" do
183
180
  before do
184
- @resource.service_name("superfriend")
185
- @resource.enabled(true)
186
- @resource.running(false)
181
+ resource.service_name("superfriend")
182
+ resource.enabled(true)
183
+ resource.running(false)
187
184
  end
188
185
 
189
186
  it "describes its state" do
190
- state = @resource.state_for_resource_reporter
187
+ state = resource.state_for_resource_reporter
191
188
  expect(state[:enabled]).to eql(true)
192
189
  expect(state[:running]).to eql(false)
193
190
  end
194
191
 
195
192
  it "returns the service name as its identity" do
196
- expect(@resource.identity).to eq("superfriend")
193
+ expect(resource.identity).to eq("superfriend")
197
194
  end
198
195
  end
199
196
  end
@@ -30,4 +30,9 @@ describe Chef::Resource::SmartosPackage, "initialize" do
30
30
  platform_family: "smartos"
31
31
  )
32
32
 
33
+ let(:resource) { Chef::Resource::SmartosPackage.new("foo") }
34
+
35
+ it "sets the package_name to the name provided" do
36
+ expect(resource.package_name).to eql("foo")
37
+ end
33
38
  end
@@ -32,11 +32,9 @@ describe Chef::Resource::SolarisPackage, "initialize" do
32
32
  )
33
33
  end
34
34
 
35
- before(:each) do
36
- @resource = Chef::Resource::SolarisPackage.new("foo")
37
- end
35
+ let(:resource) { Chef::Resource::SolarisPackage.new("foo") }
38
36
 
39
- it "should set the package_name to the name provided" do
40
- expect(@resource.package_name).to eql("foo")
37
+ it "sets the package_name to the name provided" do
38
+ expect(resource.package_name).to eql("foo")
41
39
  end
42
40
  end
@@ -28,44 +28,46 @@ describe Chef::Resource::Subversion do
28
28
  action: :install
29
29
  )
30
30
 
31
- before do
32
- @svn = Chef::Resource::Subversion.new("ohai, svn project!")
33
- end
31
+ let(:resource) { Chef::Resource::Subversion.new("ohai, svn project!") }
34
32
 
35
33
  it "is a subclass of Resource::Scm" do
36
- expect(@svn).to be_an_instance_of(Chef::Resource::Subversion)
37
- expect(@svn).to be_a_kind_of(Chef::Resource::Scm)
34
+ expect(resource).to be_an_instance_of(Chef::Resource::Subversion)
35
+ expect(resource).to be_a_kind_of(Chef::Resource::Scm)
36
+ end
37
+
38
+ it "set destination property to the name_property" do
39
+ expect(resource.destination).to eq("ohai, svn project!")
38
40
  end
39
41
 
40
42
  it "allows the force_export action" do
41
- expect(@svn.allowed_actions).to include(:force_export)
43
+ expect(resource.allowed_actions).to include(:force_export)
42
44
  end
43
45
 
44
46
  it "sets svn info arguments to --no-auth-cache by default" do
45
- expect(@svn.svn_info_args).to eq("--no-auth-cache")
47
+ expect(resource.svn_info_args).to eq("--no-auth-cache")
46
48
  end
47
49
 
48
50
  it "resets svn info arguments to nil when given false in the setter" do
49
- @svn.svn_info_args(false)
50
- expect(@svn.svn_info_args).to be_nil
51
+ resource.svn_info_args(false)
52
+ expect(resource.svn_info_args).to be_nil
51
53
  end
52
54
 
53
55
  it "sets svn arguments to --no-auth-cache by default" do
54
- expect(@svn.svn_arguments).to eq("--no-auth-cache")
56
+ expect(resource.svn_arguments).to eq("--no-auth-cache")
55
57
  end
56
58
 
57
59
  it "sets svn binary to nil by default" do
58
- expect(@svn.svn_binary).to be_nil
60
+ expect(resource.svn_binary).to be_nil
59
61
  end
60
62
 
61
63
  it "resets svn arguments to nil when given false in the setter" do
62
- @svn.svn_arguments(false)
63
- expect(@svn.svn_arguments).to be_nil
64
+ resource.svn_arguments(false)
65
+ expect(resource.svn_arguments).to be_nil
64
66
  end
65
67
 
66
68
  it "hides password from custom exception message" do
67
- @svn.svn_password "l33th4x0rpa$$w0rd"
68
- e = @svn.customize_exception(Chef::Exceptions::Exec.new "Exception with password #{@svn.svn_password}")
69
- expect(e.message.include?(@svn.svn_password)).to be_falsey
69
+ resource.svn_password "l33th4x0rpa$$w0rd"
70
+ e = resource.customize_exception(Chef::Exceptions::Exec.new "Exception with password #{resource.svn_password}")
71
+ expect(e.message.include?(resource.svn_password)).to be_falsey
70
72
  end
71
73
  end
@@ -19,12 +19,8 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Chef::Resource::SystemdUnit do
22
- before(:each) do
23
- @resource = Chef::Resource::SystemdUnit.new("sysstat-collect.timer")
24
- end
25
-
22
+ let(:resource) { Chef::Resource::SystemdUnit.new("sysstat-collect.timer") }
26
23
  let(:unit_content_string) { "[Unit]\nDescription = Run system activity accounting tool every 10 minutes\n\n[Timer]\nOnCalendar = *:00/10\n\n[Install]\nWantedBy = sysstat.service\n" }
27
-
28
24
  let(:unit_content_hash) do
29
25
  {
30
26
  "Unit" => {
@@ -40,76 +36,76 @@ describe Chef::Resource::SystemdUnit do
40
36
  end
41
37
 
42
38
  it "creates a new Chef::Resource::SystemdUnit" do
43
- expect(@resource).to be_a_kind_of(Chef::Resource)
44
- expect(@resource).to be_a_kind_of(Chef::Resource::SystemdUnit)
39
+ expect(resource).to be_a_kind_of(Chef::Resource)
40
+ expect(resource).to be_a_kind_of(Chef::Resource::SystemdUnit)
45
41
  end
46
42
 
47
- it "should have a name" do
48
- expect(@resource.name).to eql("sysstat-collect.timer")
43
+ it "has a name" do
44
+ expect(resource.name).to eql("sysstat-collect.timer")
49
45
  end
50
46
 
51
47
  it "has a default action of nothing" do
52
- expect(@resource.action).to eql([:nothing])
48
+ expect(resource.action).to eql([:nothing])
53
49
  end
54
50
 
55
51
  it "supports appropriate unit actions" do
56
- expect { @resource.action :create }.not_to raise_error
57
- expect { @resource.action :delete }.not_to raise_error
58
- expect { @resource.action :enable }.not_to raise_error
59
- expect { @resource.action :disable }.not_to raise_error
60
- expect { @resource.action :mask }.not_to raise_error
61
- expect { @resource.action :unmask }.not_to raise_error
62
- expect { @resource.action :start }.not_to raise_error
63
- expect { @resource.action :stop }.not_to raise_error
64
- expect { @resource.action :restart }.not_to raise_error
65
- expect { @resource.action :reload }.not_to raise_error
66
- expect { @resource.action :wrong }.to raise_error(ArgumentError)
52
+ expect { resource.action :create }.not_to raise_error
53
+ expect { resource.action :delete }.not_to raise_error
54
+ expect { resource.action :enable }.not_to raise_error
55
+ expect { resource.action :disable }.not_to raise_error
56
+ expect { resource.action :mask }.not_to raise_error
57
+ expect { resource.action :unmask }.not_to raise_error
58
+ expect { resource.action :start }.not_to raise_error
59
+ expect { resource.action :stop }.not_to raise_error
60
+ expect { resource.action :restart }.not_to raise_error
61
+ expect { resource.action :reload }.not_to raise_error
62
+ expect { resource.action :wrong }.to raise_error(ArgumentError)
67
63
  end
68
64
 
69
65
  it "accepts boolean state properties" do
70
- expect { @resource.active false }.not_to raise_error
71
- expect { @resource.active true }.not_to raise_error
72
- expect { @resource.active "yes" }.to raise_error(ArgumentError)
66
+ expect { resource.active false }.not_to raise_error
67
+ expect { resource.active true }.not_to raise_error
68
+ expect { resource.active "yes" }.to raise_error(ArgumentError)
73
69
 
74
- expect { @resource.enabled true }.not_to raise_error
75
- expect { @resource.enabled false }.not_to raise_error
76
- expect { @resource.enabled "no" }.to raise_error(ArgumentError)
70
+ expect { resource.enabled true }.not_to raise_error
71
+ expect { resource.enabled false }.not_to raise_error
72
+ expect { resource.enabled "no" }.to raise_error(ArgumentError)
77
73
 
78
- expect { @resource.masked true }.not_to raise_error
79
- expect { @resource.masked false }.not_to raise_error
80
- expect { @resource.masked :nope }.to raise_error(ArgumentError)
74
+ expect { resource.masked true }.not_to raise_error
75
+ expect { resource.masked false }.not_to raise_error
76
+ expect { resource.masked :nope }.to raise_error(ArgumentError)
81
77
 
82
- expect { @resource.static true }.not_to raise_error
83
- expect { @resource.static false }.not_to raise_error
84
- expect { @resource.static "yep" }.to raise_error(ArgumentError)
78
+ expect { resource.static true }.not_to raise_error
79
+ expect { resource.static false }.not_to raise_error
80
+ expect { resource.static "yep" }.to raise_error(ArgumentError)
85
81
  end
86
82
 
87
83
  it "accepts the content property" do
88
- expect { @resource.content nil }.not_to raise_error
89
- expect { @resource.content "test" }.not_to raise_error
90
- expect { @resource.content({}) }.not_to raise_error
91
- expect { @resource.content 5 }.to raise_error(ArgumentError)
84
+ expect { resource.content nil }.not_to raise_error
85
+ expect { resource.content "test" }.not_to raise_error
86
+ expect { resource.content({}) }.not_to raise_error
87
+ expect { resource.content 5 }.to raise_error(ArgumentError)
92
88
  end
93
89
 
94
90
  it "accepts the user property" do
95
- expect { @resource.user nil }.not_to raise_error
96
- expect { @resource.user "deploy" }.not_to raise_error
97
- expect { @resource.user 5 }.to raise_error(ArgumentError)
91
+ expect { resource.user nil }.not_to raise_error
92
+ expect { resource.user "deploy" }.not_to raise_error
93
+ expect { resource.user 5 }.to raise_error(ArgumentError)
98
94
  end
99
95
 
100
96
  it "accepts the triggers_reload property" do
101
- expect { @resource.triggers_reload true }.not_to raise_error
102
- expect { @resource.triggers_reload false }.not_to raise_error
103
- expect { @resource.triggers_reload "no" }.to raise_error(ArgumentError)
97
+ expect { resource.triggers_reload true }.not_to raise_error
98
+ expect { resource.triggers_reload false }.not_to raise_error
99
+ expect { resource.triggers_reload "no" }.to raise_error(ArgumentError)
104
100
  end
105
101
 
106
102
  it "reports its state" do
107
- @resource.active true
108
- @resource.enabled true
109
- @resource.masked false
110
- @resource.static false
111
- @resource.content "test"
112
- state = @resource.state_for_resource_reporter
103
+ resource.active true
104
+ resource.enabled true
105
+ resource.masked false
106
+ resource.static false
107
+ resource.content "test"
108
+ state = resource.state_for_resource_reporter
113
109
  expect(state[:active]).to eq(true)
114
110
  expect(state[:enabled]).to eq(true)
115
111
  expect(state[:masked]).to eq(false)
@@ -118,16 +114,16 @@ describe Chef::Resource::SystemdUnit do
118
114
  end
119
115
 
120
116
  it "returns the unit name as its identity" do
121
- expect(@resource.identity).to eq("sysstat-collect.timer")
117
+ expect(resource.identity).to eq("sysstat-collect.timer")
122
118
  end
123
119
 
124
120
  it "serializes to ini with a string-formatted content property" do
125
- @resource.content(unit_content_string)
126
- expect(@resource.to_ini).to eq unit_content_string
121
+ resource.content(unit_content_string)
122
+ expect(resource.to_ini).to eq unit_content_string
127
123
  end
128
124
 
129
125
  it "serializes to ini with a hash-formatted content property" do
130
- @resource.content(unit_content_hash)
131
- expect(@resource.to_ini).to eq unit_content_string
126
+ resource.content(unit_content_hash)
127
+ expect(resource.to_ini).to eq unit_content_string
132
128
  end
133
129
  end