chef 12.18.31 → 12.19.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -4
  3. data/README.md +12 -13
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile +4 -4
  6. data/acceptance/Gemfile.lock +70 -69
  7. data/chef-universal-mingw32.gemspec +2 -3
  8. data/chef.gemspec +6 -6
  9. data/lib/chef/api_client.rb +8 -10
  10. data/lib/chef/api_client_v1.rb +9 -11
  11. data/lib/chef/application/apply.rb +8 -10
  12. data/lib/chef/application/client.rb +1 -1
  13. data/lib/chef/application/exit_code.rb +3 -5
  14. data/lib/chef/application/knife.rb +2 -2
  15. data/lib/chef/application/windows_service.rb +29 -30
  16. data/lib/chef/application/windows_service_manager.rb +1 -1
  17. data/lib/chef/audit/audit_event_proxy.rb +2 -2
  18. data/lib/chef/audit/control_group_data.rb +1 -1
  19. data/lib/chef/chef_class.rb +1 -0
  20. data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
  21. data/lib/chef/chef_fs/command_line.rb +15 -16
  22. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
  23. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
  24. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  25. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  26. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
  27. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
  28. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
  29. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
  30. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
  31. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
  32. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  33. data/lib/chef/chef_fs/file_system.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
  35. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
  36. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
  37. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
  38. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
  39. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
  40. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
  41. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
  42. data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
  43. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
  44. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
  45. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
  46. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
  47. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
  48. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
  49. data/lib/chef/chef_fs/parallelizer.rb +9 -11
  50. data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
  51. data/lib/chef/cookbook/metadata.rb +26 -26
  52. data/lib/chef/cookbook/syntax_check.rb +1 -1
  53. data/lib/chef/cookbook_version.rb +3 -3
  54. data/lib/chef/data_bag.rb +1 -1
  55. data/lib/chef/data_bag_item.rb +3 -3
  56. data/lib/chef/data_collector.rb +3 -4
  57. data/lib/chef/decorator.rb +1 -1
  58. data/lib/chef/deprecated.rb +30 -0
  59. data/lib/chef/dsl/audit.rb +2 -2
  60. data/lib/chef/dsl/declare_resource.rb +1 -1
  61. data/lib/chef/dsl/platform_introspection.rb +29 -31
  62. data/lib/chef/dsl/reboot_pending.rb +1 -1
  63. data/lib/chef/dsl/resources.rb +6 -8
  64. data/lib/chef/encrypted_data_bag_item.rb +2 -2
  65. data/lib/chef/environment.rb +9 -11
  66. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  67. data/lib/chef/exceptions.rb +4 -1
  68. data/lib/chef/file_access_control/unix.rb +14 -14
  69. data/lib/chef/file_access_control/windows.rb +1 -1
  70. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
  71. data/lib/chef/formatters/error_mapper.rb +6 -6
  72. data/lib/chef/http/api_versions.rb +50 -0
  73. data/lib/chef/http/validate_content_length.rb +2 -2
  74. data/lib/chef/json_compat.rb +6 -10
  75. data/lib/chef/key.rb +5 -5
  76. data/lib/chef/knife.rb +4 -4
  77. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  78. data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
  79. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  80. data/lib/chef/knife/core/status_presenter.rb +1 -1
  81. data/lib/chef/knife/core/ui.rb +19 -25
  82. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  83. data/lib/chef/knife/deps.rb +32 -34
  84. data/lib/chef/knife/help.rb +1 -1
  85. data/lib/chef/knife/list.rb +1 -1
  86. data/lib/chef/knife/search.rb +2 -2
  87. data/lib/chef/knife/ssh.rb +37 -27
  88. data/lib/chef/knife/ssl_check.rb +1 -1
  89. data/lib/chef/knife/user_delete.rb +1 -1
  90. data/lib/chef/mash.rb +1 -1
  91. data/lib/chef/mixin/command.rb +2 -2
  92. data/lib/chef/mixin/create_path.rb +3 -5
  93. data/lib/chef/mixin/from_file.rb +2 -2
  94. data/lib/chef/mixin/get_source_from_package.rb +2 -2
  95. data/lib/chef/mixin/notifying_block.rb +7 -9
  96. data/lib/chef/mixin/params_validate.rb +3 -3
  97. data/lib/chef/mixin/securable.rb +1 -1
  98. data/lib/chef/mixin/shell_out.rb +23 -3
  99. data/lib/chef/mixin/unformatter.rb +2 -2
  100. data/lib/chef/mixin/uris.rb +4 -6
  101. data/lib/chef/mixin/versioned_api.rb +69 -0
  102. data/lib/chef/mixin/which.rb +25 -8
  103. data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
  104. data/lib/chef/mixin/xml_escape.rb +3 -5
  105. data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
  106. data/lib/chef/node.rb +8 -8
  107. data/lib/chef/node/attribute.rb +4 -4
  108. data/lib/chef/node/common_api.rb +5 -7
  109. data/lib/chef/org.rb +10 -12
  110. data/lib/chef/platform/provider_mapping.rb +7 -7
  111. data/lib/chef/platform/query_helpers.rb +1 -1
  112. data/lib/chef/policy_builder/policyfile.rb +1 -0
  113. data/lib/chef/property.rb +31 -0
  114. data/lib/chef/provider/batch.rb +1 -1
  115. data/lib/chef/provider/breakpoint.rb +1 -1
  116. data/lib/chef/provider/cookbook_file.rb +3 -3
  117. data/lib/chef/provider/cron.rb +38 -38
  118. data/lib/chef/provider/deploy.rb +81 -81
  119. data/lib/chef/provider/deploy/revision.rb +3 -5
  120. data/lib/chef/provider/directory.rb +32 -32
  121. data/lib/chef/provider/dsc_resource.rb +22 -6
  122. data/lib/chef/provider/env.rb +28 -28
  123. data/lib/chef/provider/env/windows.rb +1 -1
  124. data/lib/chef/provider/erl_call.rb +13 -13
  125. data/lib/chef/provider/execute.rb +5 -2
  126. data/lib/chef/provider/file.rb +49 -51
  127. data/lib/chef/provider/git.rb +55 -55
  128. data/lib/chef/provider/http_request.rb +36 -36
  129. data/lib/chef/provider/launchd.rb +2 -2
  130. data/lib/chef/provider/link.rb +50 -50
  131. data/lib/chef/provider/log.rb +2 -2
  132. data/lib/chef/provider/mdadm.rb +25 -25
  133. data/lib/chef/provider/mount/aix.rb +2 -2
  134. data/lib/chef/provider/mount/mount.rb +2 -2
  135. data/lib/chef/provider/ohai.rb +1 -1
  136. data/lib/chef/provider/osx_profile.rb +23 -23
  137. data/lib/chef/provider/package.rb +74 -56
  138. data/lib/chef/provider/package/aix.rb +55 -52
  139. data/lib/chef/provider/package/apt.rb +15 -13
  140. data/lib/chef/provider/package/cab.rb +49 -20
  141. data/lib/chef/provider/package/chocolatey.rb +9 -10
  142. data/lib/chef/provider/package/dnf.rb +20 -18
  143. data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
  144. data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
  145. data/lib/chef/provider/package/dnf/version.rb +1 -1
  146. data/lib/chef/provider/package/dpkg.rb +8 -9
  147. data/lib/chef/provider/package/easy_install.rb +22 -22
  148. data/lib/chef/provider/package/freebsd/base.rb +10 -10
  149. data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
  150. data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
  151. data/lib/chef/provider/package/freebsd/port.rb +7 -7
  152. data/lib/chef/provider/package/homebrew.rb +11 -10
  153. data/lib/chef/provider/package/ips.rb +18 -23
  154. data/lib/chef/provider/package/macports.rb +23 -23
  155. data/lib/chef/provider/package/msu.rb +11 -11
  156. data/lib/chef/provider/package/openbsd.rb +25 -22
  157. data/lib/chef/provider/package/pacman.rb +16 -16
  158. data/lib/chef/provider/package/paludis.rb +26 -27
  159. data/lib/chef/provider/package/portage.rb +22 -22
  160. data/lib/chef/provider/package/powershell.rb +17 -17
  161. data/lib/chef/provider/package/rpm.rb +25 -25
  162. data/lib/chef/provider/package/rubygems.rb +60 -60
  163. data/lib/chef/provider/package/smartos.rb +16 -16
  164. data/lib/chef/provider/package/solaris.rb +44 -44
  165. data/lib/chef/provider/package/windows.rb +3 -3
  166. data/lib/chef/provider/package/windows/exe.rb +6 -6
  167. data/lib/chef/provider/package/windows/msi.rb +6 -6
  168. data/lib/chef/provider/package/yum.rb +318 -268
  169. data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
  170. data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
  171. data/lib/chef/provider/package/zypper.rb +11 -11
  172. data/lib/chef/provider/powershell_script.rb +15 -7
  173. data/lib/chef/provider/reboot.rb +10 -10
  174. data/lib/chef/provider/registry_key.rb +39 -39
  175. data/lib/chef/provider/remote_directory.rb +3 -3
  176. data/lib/chef/provider/remote_file.rb +3 -3
  177. data/lib/chef/provider/route.rb +1 -1
  178. data/lib/chef/provider/ruby_block.rb +3 -3
  179. data/lib/chef/provider/script.rb +42 -6
  180. data/lib/chef/provider/service.rb +49 -49
  181. data/lib/chef/provider/service/solaris.rb +1 -1
  182. data/lib/chef/provider/service/systemd.rb +1 -1
  183. data/lib/chef/provider/subversion.rb +39 -39
  184. data/lib/chef/provider/systemd_unit.rb +2 -0
  185. data/lib/chef/provider/template.rb +3 -3
  186. data/lib/chef/provider/user.rb +42 -42
  187. data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
  188. data/lib/chef/resource.rb +27 -16
  189. data/lib/chef/resource/apt_repository.rb +0 -1
  190. data/lib/chef/resource/chef_gem.rb +1 -1
  191. data/lib/chef/resource/dnf_package.rb +6 -3
  192. data/lib/chef/resource/dsc_resource.rb +9 -1
  193. data/lib/chef/resource/execute.rb +70 -6
  194. data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
  195. data/lib/chef/resource/freebsd_package.rb +1 -1
  196. data/lib/chef/resource/gem_package.rb +1 -1
  197. data/lib/chef/resource/launchd.rb +13 -1
  198. data/lib/chef/resource/package.rb +2 -2
  199. data/lib/chef/resource/registry_key.rb +1 -1
  200. data/lib/chef/resource/yum_package.rb +12 -3
  201. data/lib/chef/resource/yum_repository.rb +0 -1
  202. data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
  203. data/lib/chef/resource_collection/resource_set.rb +2 -2
  204. data/lib/chef/resource_reporter.rb +1 -1
  205. data/lib/chef/run_context.rb +3 -3
  206. data/lib/chef/run_list/run_list_item.rb +1 -1
  207. data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
  208. data/lib/chef/server_api.rb +2 -0
  209. data/lib/chef/server_api_versions.rb +40 -0
  210. data/lib/chef/shell.rb +1 -1
  211. data/lib/chef/shell/ext.rb +3 -3
  212. data/lib/chef/shell/shell_session.rb +1 -1
  213. data/lib/chef/user.rb +9 -11
  214. data/lib/chef/user_v1.rb +9 -11
  215. data/lib/chef/util/diff.rb +1 -1
  216. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
  217. data/lib/chef/util/selinux.rb +1 -1
  218. data/lib/chef/util/windows/net_group.rb +18 -30
  219. data/lib/chef/util/windows/net_use.rb +7 -11
  220. data/lib/chef/util/windows/net_user.rb +11 -17
  221. data/lib/chef/util/windows/volume.rb +9 -15
  222. data/lib/chef/version.rb +1 -1
  223. data/lib/chef/version_class.rb +1 -1
  224. data/lib/chef/win32/api.rb +4 -6
  225. data/lib/chef/win32/api/file.rb +25 -31
  226. data/lib/chef/win32/api/installer.rb +2 -2
  227. data/lib/chef/win32/file.rb +4 -6
  228. data/lib/chef/win32/registry.rb +9 -9
  229. data/lib/chef/win32/security.rb +2 -2
  230. data/lib/chef/win32/security/acl.rb +2 -2
  231. data/lib/chef/win32/unicode.rb +2 -2
  232. data/lib/chef/win32/version.rb +1 -1
  233. data/spec/data/prefer_metadata_json/metadata.json +51 -0
  234. data/spec/data/prefer_metadata_json/metadata.rb +6 -0
  235. data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
  236. data/spec/functional/knife/ssh_spec.rb +5 -5
  237. data/spec/functional/resource/batch_spec.rb +5 -1
  238. data/spec/functional/resource/dsc_script_spec.rb +2 -4
  239. data/spec/functional/resource/execute_spec.rb +17 -0
  240. data/spec/functional/resource/user/dscl_spec.rb +2 -4
  241. data/spec/integration/client/client_spec.rb +33 -0
  242. data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
  243. data/spec/spec_helper.rb +4 -0
  244. data/spec/support/chef_helpers.rb +5 -7
  245. data/spec/support/platform_helpers.rb +6 -0
  246. data/spec/support/platforms/prof/gc.rb +4 -6
  247. data/spec/support/shared/context/client.rb +1 -1
  248. data/spec/support/shared/functional/execute_resource.rb +150 -0
  249. data/spec/support/shared/functional/windows_script.rb +74 -4
  250. data/spec/support/shared/unit/execute_resource.rb +37 -0
  251. data/spec/support/shared/unit/provider/file.rb +10 -0
  252. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
  253. data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
  254. data/spec/unit/http/api_versions_spec.rb +69 -0
  255. data/spec/unit/knife/ssh_spec.rb +34 -36
  256. data/spec/unit/mixin/versioned_api_spec.rb +107 -0
  257. data/spec/unit/mixin/which.rb +160 -0
  258. data/spec/unit/platform_spec.rb +28 -1
  259. data/spec/unit/provider/deploy_spec.rb +1 -1
  260. data/spec/unit/provider/directory_spec.rb +10 -0
  261. data/spec/unit/provider/dsc_resource_spec.rb +175 -0
  262. data/spec/unit/provider/execute_spec.rb +0 -1
  263. data/spec/unit/provider/launchd_spec.rb +2 -2
  264. data/spec/unit/provider/package/aix_spec.rb +22 -22
  265. data/spec/unit/provider/package/apt_spec.rb +27 -27
  266. data/spec/unit/provider/package/cab_spec.rb +59 -5
  267. data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
  268. data/spec/unit/provider/package/dpkg_spec.rb +16 -16
  269. data/spec/unit/provider/package/easy_install_spec.rb +18 -18
  270. data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
  271. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  272. data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
  273. data/spec/unit/provider/package/homebrew_spec.rb +9 -9
  274. data/spec/unit/provider/package/ips_spec.rb +37 -31
  275. data/spec/unit/provider/package/macports_spec.rb +10 -10
  276. data/spec/unit/provider/package/openbsd_spec.rb +10 -10
  277. data/spec/unit/provider/package/pacman_spec.rb +6 -6
  278. data/spec/unit/provider/package/paludis_spec.rb +7 -7
  279. data/spec/unit/provider/package/portage_spec.rb +6 -7
  280. data/spec/unit/provider/package/rpm_spec.rb +23 -23
  281. data/spec/unit/provider/package/rubygems_spec.rb +38 -38
  282. data/spec/unit/provider/package/solaris_spec.rb +15 -15
  283. data/spec/unit/provider/package/windows_spec.rb +2 -1
  284. data/spec/unit/provider/package/yum_spec.rb +51 -43
  285. data/spec/unit/provider/package/zypper_spec.rb +34 -34
  286. data/spec/unit/provider/package_spec.rb +8 -0
  287. data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
  288. data/spec/unit/provider/route_spec.rb +7 -1
  289. data/spec/unit/provider/script_spec.rb +49 -6
  290. data/spec/unit/resource/dsc_resource_spec.rb +6 -0
  291. data/spec/unit/resource/execute_spec.rb +214 -0
  292. data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
  293. data/spec/unit/resource/freebsd_package_spec.rb +2 -2
  294. data/spec/unit/resource/package_spec.rb +5 -0
  295. data/spec/unit/resource/yum_package_spec.rb +42 -1
  296. data/spec/unit/resource_reporter_spec.rb +1 -1
  297. data/spec/unit/resource_spec.rb +18 -0
  298. data/spec/unit/server_api_versions_spec.rb +44 -0
  299. data/spec/unit/util/selinux_spec.rb +3 -14
  300. data/spec/unit/win32/error_spec.rb +67 -0
  301. data/spec/unit/win32/security_spec.rb +66 -0
  302. data/tasks/changelog.rb +1 -1
  303. data/tasks/dependencies.rb +20 -4
  304. metadata +39 -18
  305. data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -68,7 +68,7 @@ describe Chef::Provider::Package::Freebsd::Port do
68
68
  it "should check 'pkg_info' if system uses pkg_* tools" do
69
69
  allow(@new_resource).to receive(:supports_pkgng?)
70
70
  expect(@new_resource).to receive(:supports_pkgng?).and_return(false)
71
- expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info)
71
+ expect(@provider).to receive(:shell_out!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info)
72
72
  expect(@provider.current_installed_version).to eq("3.1.7")
73
73
  end
74
74
 
@@ -76,8 +76,8 @@ describe Chef::Provider::Package::Freebsd::Port do
76
76
  pkg_enabled = OpenStruct.new(:stdout => "yes\n")
77
77
  [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version|
78
78
  @node.automatic_attrs[:os_version] = freebsd_version
79
- expect(@new_resource).to receive(:shell_out!).with("make -V WITH_PKGNG", env: nil).and_return(pkg_enabled)
80
- expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
79
+ expect(@new_resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
80
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
81
81
  expect(@provider.current_installed_version).to eq("3.1.7")
82
82
  end
83
83
  end
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do
85
85
  it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do
86
86
  freebsd_version = 1000017
87
87
  @node.automatic_attrs[:os_version] = freebsd_version
88
- expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
88
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
89
89
  expect(@provider.current_installed_version).to eq("3.1.7")
90
90
  end
91
91
  end
@@ -98,7 +98,7 @@ describe Chef::Provider::Package::Freebsd::Port do
98
98
  it "should return candidate version if port exists" do
99
99
  allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
100
100
  allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
101
- expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
101
+ expect(@provider).to receive(:shell_out!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
102
102
  and_return(@port_version)
103
103
  expect(@provider.candidate_version).to eq("5.0.5")
104
104
  end
@@ -122,13 +122,13 @@ describe Chef::Provider::Package::Freebsd::Port do
122
122
 
123
123
  it "should query system for path given just a name" do
124
124
  whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n")
125
- expect(@provider).to receive(:shell_out!).with("whereis -s zsh", env: nil, timeout: 900).and_return(whereis)
125
+ expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
126
126
  expect(@provider.port_dir).to eq("/usr/ports/shells/zsh")
127
127
  end
128
128
 
129
129
  it "should raise exception if not found" do
130
130
  whereis = OpenStruct.new(:stdout => "zsh:\n")
131
- expect(@provider).to receive(:shell_out!).with("whereis -s zsh", env: nil, timeout: 900).and_return(whereis)
131
+ expect(@provider).to receive(:shell_out!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
132
132
  expect { @provider.port_dir }.to raise_error(Chef::Exceptions::Package, "Could not find port with the name zsh")
133
133
  end
134
134
  end
@@ -141,7 +141,7 @@ describe Chef::Provider::Package::Freebsd::Port do
141
141
  it "should run make install in port directory" do
142
142
  allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
143
143
  expect(@provider).to receive(:shell_out!).
144
- with("make -DBATCH install clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil).
144
+ with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil).
145
145
  and_return(@install_result)
146
146
  @provider.install_package("zsh", "5.0.5")
147
147
  end
@@ -155,7 +155,7 @@ describe Chef::Provider::Package::Freebsd::Port do
155
155
  it "should run make deinstall in port directory" do
156
156
  allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
157
157
  expect(@provider).to receive(:shell_out!).
158
- with("make deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil).
158
+ with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil).
159
159
  and_return(@install_result)
160
160
  @provider.remove_package("zsh", "5.0.5")
161
161
  end
@@ -209,7 +209,7 @@ describe Chef::Provider::Package::Homebrew do
209
209
  allow(provider.new_resource).to receive(:version).and_return("24.3")
210
210
  allow(provider.current_resource).to receive(:version).and_return(nil)
211
211
  allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
212
- expect(provider).to receive(:get_response_from_command).with("brew install emacs")
212
+ expect(provider).to receive(:get_response_from_command).with("brew", "install", nil, "emacs")
213
213
  provider.install_package("emacs", "24.3")
214
214
  end
215
215
 
@@ -221,9 +221,9 @@ describe Chef::Provider::Package::Homebrew do
221
221
  end
222
222
 
223
223
  it "uses options to the brew command if specified" do
224
- allow(provider.new_resource).to receive(:options).and_return("--cocoa")
224
+ new_resource.options "--cocoa"
225
225
  allow(provider.current_resource).to receive(:version).and_return("24.3")
226
- allow(provider).to receive(:get_response_from_command).with("brew install --cocoa emacs")
226
+ allow(provider).to receive(:get_response_from_command).with("brew", "install", "--cocoa", "emacs")
227
227
  provider.install_package("emacs", "24.3")
228
228
  end
229
229
  end
@@ -232,7 +232,7 @@ describe Chef::Provider::Package::Homebrew do
232
232
  it "uses brew upgrade to upgrade the package if it is installed" do
233
233
  allow(provider.current_resource).to receive(:version).and_return("24")
234
234
  allow(provider).to receive(:brew_info).and_return(installed_brew_info)
235
- expect(provider).to receive(:get_response_from_command).with("brew upgrade emacs")
235
+ expect(provider).to receive(:get_response_from_command).with("brew", "upgrade", nil, "emacs")
236
236
  provider.upgrade_package("emacs", "24.3")
237
237
  end
238
238
 
@@ -246,15 +246,15 @@ describe Chef::Provider::Package::Homebrew do
246
246
  it "uses brew install to install the package if it is not installed" do
247
247
  allow(provider.current_resource).to receive(:version).and_return(nil)
248
248
  allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
249
- expect(provider).to receive(:get_response_from_command).with("brew install emacs")
249
+ expect(provider).to receive(:get_response_from_command).with("brew", "install", nil, "emacs")
250
250
  provider.upgrade_package("emacs", "24.3")
251
251
  end
252
252
 
253
253
  it "uses options to the brew command if specified" do
254
254
  allow(provider.current_resource).to receive(:version).and_return("24")
255
255
  allow(provider).to receive(:brew_info).and_return(installed_brew_info)
256
- allow(provider.new_resource).to receive(:options).and_return("--cocoa")
257
- expect(provider).to receive(:get_response_from_command).with("brew upgrade --cocoa emacs")
256
+ new_resource.options "--cocoa"
257
+ expect(provider).to receive(:get_response_from_command).with("brew", "upgrade", [ "--cocoa" ], "emacs")
258
258
  provider.upgrade_package("emacs", "24.3")
259
259
  end
260
260
  end
@@ -263,7 +263,7 @@ describe Chef::Provider::Package::Homebrew do
263
263
  it "uninstalls the package with brew uninstall" do
264
264
  allow(provider.current_resource).to receive(:version).and_return("24.3")
265
265
  allow(provider).to receive(:brew_info).and_return(installed_brew_info)
266
- expect(provider).to receive(:get_response_from_command).with("brew uninstall emacs")
266
+ expect(provider).to receive(:get_response_from_command).with("brew", "uninstall", nil, "emacs")
267
267
  provider.remove_package("emacs", "24.3")
268
268
  end
269
269
 
@@ -278,7 +278,7 @@ describe Chef::Provider::Package::Homebrew do
278
278
  it "uninstalls the package with brew uninstall --force" do
279
279
  allow(provider.current_resource).to receive(:version).and_return("24.3")
280
280
  allow(provider).to receive(:brew_info).and_return(installed_brew_info)
281
- expect(provider).to receive(:get_response_from_command).with("brew uninstall --force emacs")
281
+ expect(provider).to receive(:get_response_from_command).with("brew", "uninstall", "--force", nil, "emacs")
282
282
  provider.purge_package("emacs", "24.3")
283
283
  end
284
284
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Bryan McLellan <btm@chef.io>
3
- # Copyright:: Copyright 2012-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2012-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,9 +26,9 @@ describe Chef::Provider::Package::Ips do
26
26
  @node = Chef::Node.new
27
27
  @events = Chef::EventDispatch::Dispatcher.new
28
28
  @run_context = Chef::RunContext.new(@node, {}, @events)
29
- @new_resource = Chef::Resource::Package.new("crypto/gnupg", @run_context)
30
- @current_resource = Chef::Resource::Package.new("crypto/gnupg", @run_context)
31
- allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
29
+ @new_resource = Chef::Resource::IpsPackage.new("crypto/gnupg", @run_context)
30
+ @current_resource = Chef::Resource::IpsPackage.new("crypto/gnupg", @run_context)
31
+ allow(Chef::Resource::IpsPackage).to receive(:new).and_return(@current_resource)
32
32
  @provider = Chef::Provider::Package::Ips.new(@new_resource, @run_context)
33
33
  end
34
34
 
@@ -41,7 +41,7 @@ installed on the system. Try specifying -r to query remotely:
41
41
 
42
42
  crypto/gnupg
43
43
  PKG_STATUS
44
- return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
44
+ OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
45
45
  end
46
46
 
47
47
  def remote_output
@@ -59,33 +59,33 @@ Packaging Date: April 1, 2012 05:55:52 PM
59
59
  PKG_STATUS
60
60
  stdin = StringIO.new
61
61
  stderr = ""
62
- return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
62
+ OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
63
63
  end
64
64
 
65
65
  context "when loading current resource" do
66
66
  it "should create a current resource with the name of the new_resource" do
67
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
68
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
69
- expect(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
67
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
68
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
69
+ expect(Chef::Resource::IpsPackage).to receive(:new).and_return(@current_resource)
70
70
  @provider.load_current_resource
71
71
  end
72
72
 
73
73
  it "should set the current resources package name to the new resources package name" do
74
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
75
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
74
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
75
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
76
76
  @provider.load_current_resource
77
77
  expect(@current_resource.package_name).to eq(@new_resource.package_name)
78
78
  end
79
79
 
80
80
  it "should run pkg info with the package name" do
81
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
82
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
81
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
82
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
83
83
  @provider.load_current_resource
84
84
  end
85
85
 
86
86
  it "should set the installed version to nil on the current resource if package state is not installed" do
87
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
88
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
87
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
88
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
89
89
  @provider.load_current_resource
90
90
  expect(@current_resource.version).to be_nil
91
91
  end
@@ -107,31 +107,37 @@ Packaging Date: October 19, 2011 09:14:50 AM
107
107
  Size: 8.07 MB
108
108
  FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
109
109
  INSTALLED
110
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local)
111
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
110
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
111
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
112
112
  @provider.load_current_resource
113
113
  expect(@current_resource.version).to eq("2.0.17")
114
114
  end
115
115
 
116
116
  it "should return the current resource" do
117
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
118
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote_output)
117
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
118
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
119
119
  expect(@provider.load_current_resource).to eql(@current_resource)
120
120
  end
121
121
  end
122
122
 
123
123
  context "when installing a package" do
124
124
  it "should run pkg install with the package name and version" do
125
- expect(@provider).to receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900)
125
+ expect(@provider).to receive(:shell_out!).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
126
126
  @provider.install_package("crypto/gnupg", "2.0.17")
127
127
  end
128
128
 
129
129
  it "should run pkg install with the package name and version and options if specified" do
130
- expect(@provider).to receive(:shell_out).with("pkg --no-refresh install -q crypto/gnupg@2.0.17", timeout: 900)
131
- allow(@new_resource).to receive(:options).and_return("--no-refresh")
130
+ expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900)
131
+ @new_resource.options "--no-refresh"
132
132
  @provider.install_package("crypto/gnupg", "2.0.17")
133
133
  end
134
134
 
135
+ it "raises an error if package fails to install" do
136
+ expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
137
+ allow(@new_resource).to receive(:options).and_return("--no-refresh")
138
+ expect { @provider.install_package("crypto/gnupg", "2.0.17") }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
139
+ end
140
+
135
141
  it "should not include the human-readable version in the candidate_version" do
136
142
  remote = remote_output
137
143
  remote.stdout = <<-PKG_STATUS
@@ -146,8 +152,8 @@ Packaging Date: April 1, 2012 05:55:52 PM
146
152
  Size: 2.57 MB
147
153
  FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
148
154
  PKG_STATUS
149
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local_output)
150
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote)
155
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
156
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
151
157
  @provider.load_current_resource
152
158
  expect(@current_resource.version).to be_nil
153
159
  expect(@provider.candidate_version).to eql("1.8.4.1")
@@ -187,8 +193,8 @@ Packaging Date: October 19, 2011 09:14:50 AM
187
193
  FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z
188
194
  REMOTE
189
195
 
190
- expect(@provider).to receive(:shell_out).with("pkg info #{@new_resource.package_name}", timeout: 900).and_return(local)
191
- expect(@provider).to receive(:shell_out!).with("pkg info -r #{@new_resource.package_name}", timeout: 900).and_return(remote)
196
+ expect(@provider).to receive(:shell_out).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
197
+ expect(@provider).to receive(:shell_out!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
192
198
  expect(@provider).to receive(:install_package).exactly(0).times
193
199
  @provider.run_action(:install)
194
200
  end
@@ -199,7 +205,7 @@ REMOTE
199
205
  end
200
206
 
201
207
  it "should run pkg install with the --accept flag" do
202
- expect(@provider).to receive(:shell_out).with("pkg install -q --accept crypto/gnupg@2.0.17", timeout: 900)
208
+ expect(@provider).to receive(:shell_out).with("pkg", "install", "-q", "--accept", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
203
209
  @provider.install_package("crypto/gnupg", "2.0.17")
204
210
  end
205
211
  end
@@ -207,20 +213,20 @@ REMOTE
207
213
 
208
214
  context "when upgrading a package" do
209
215
  it "should run pkg install with the package name and version" do
210
- expect(@provider).to receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900)
216
+ expect(@provider).to receive(:shell_out).with("pkg", "install", "-q", "crypto/gnupg@2.0.17", timeout: 900).and_return(local_output)
211
217
  @provider.upgrade_package("crypto/gnupg", "2.0.17")
212
218
  end
213
219
  end
214
220
 
215
221
  context "when uninstalling a package" do
216
222
  it "should run pkg uninstall with the package name and version" do
217
- expect(@provider).to receive(:shell_out!).with("pkg uninstall -q crypto/gnupg@2.0.17", timeout: 900)
223
+ expect(@provider).to receive(:shell_out!).with("pkg", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
218
224
  @provider.remove_package("crypto/gnupg", "2.0.17")
219
225
  end
220
226
 
221
227
  it "should run pkg uninstall with the package name and version and options if specified" do
222
- expect(@provider).to receive(:shell_out!).with("pkg --no-refresh uninstall -q crypto/gnupg@2.0.17", timeout: 900)
223
- allow(@new_resource).to receive(:options).and_return("--no-refresh")
228
+ expect(@provider).to receive(:shell_out!).with("pkg", "--no-refresh", "uninstall", "-q", "crypto/gnupg@2.0.17", timeout: 900)
229
+ @new_resource.options "--no-refresh"
224
230
  @provider.remove_package("crypto/gnupg", "2.0.17")
225
231
  end
226
232
  end
@@ -105,7 +105,7 @@ EOF
105
105
  it "should run the port install command with the correct version" do
106
106
  expect(@current_resource).to receive(:version).and_return("4.1.6")
107
107
  @provider.current_resource = @current_resource
108
- expect(@provider).to receive(:shell_out!).with("port install zsh @4.2.7", timeout: 900)
108
+ expect(@provider).to receive(:shell_out!).with("port", "install", "zsh", "@4.2.7", timeout: 900)
109
109
 
110
110
  @provider.install_package("zsh", "4.2.7")
111
111
  end
@@ -122,7 +122,7 @@ EOF
122
122
  expect(@current_resource).to receive(:version).and_return("4.1.6")
123
123
  @provider.current_resource = @current_resource
124
124
  allow(@new_resource).to receive(:options).and_return("-f")
125
- expect(@provider).to receive(:shell_out!).with("port -f install zsh @4.2.7", timeout: 900)
125
+ expect(@provider).to receive(:shell_out!).with("port", "-f", "install", "zsh", "@4.2.7", timeout: 900)
126
126
 
127
127
  @provider.install_package("zsh", "4.2.7")
128
128
  end
@@ -130,36 +130,36 @@ EOF
130
130
 
131
131
  describe "purge_package" do
132
132
  it "should run the port uninstall command with the correct version" do
133
- expect(@provider).to receive(:shell_out!).with("port uninstall zsh @4.2.7", timeout: 900)
133
+ expect(@provider).to receive(:shell_out!).with("port", "uninstall", "zsh", "@4.2.7", timeout: 900)
134
134
  @provider.purge_package("zsh", "4.2.7")
135
135
  end
136
136
 
137
137
  it "should purge the currently active version if no explicit version is passed in" do
138
- expect(@provider).to receive(:shell_out!).with("port uninstall zsh", timeout: 900)
138
+ expect(@provider).to receive(:shell_out!).with("port", "uninstall", "zsh", timeout: 900)
139
139
  @provider.purge_package("zsh", nil)
140
140
  end
141
141
 
142
142
  it "should add options to the port command when specified" do
143
143
  allow(@new_resource).to receive(:options).and_return("-f")
144
- expect(@provider).to receive(:shell_out!).with("port -f uninstall zsh @4.2.7", timeout: 900)
144
+ expect(@provider).to receive(:shell_out!).with("port", "-f", "uninstall", "zsh", "@4.2.7", timeout: 900)
145
145
  @provider.purge_package("zsh", "4.2.7")
146
146
  end
147
147
  end
148
148
 
149
149
  describe "remove_package" do
150
150
  it "should run the port deactivate command with the correct version" do
151
- expect(@provider).to receive(:shell_out!).with("port deactivate zsh @4.2.7", timeout: 900)
151
+ expect(@provider).to receive(:shell_out!).with("port", "deactivate", "zsh", "@4.2.7", timeout: 900)
152
152
  @provider.remove_package("zsh", "4.2.7")
153
153
  end
154
154
 
155
155
  it "should remove the currently active version if no explicit version is passed in" do
156
- expect(@provider).to receive(:shell_out!).with("port deactivate zsh", timeout: 900)
156
+ expect(@provider).to receive(:shell_out!).with("port", "deactivate", "zsh", timeout: 900)
157
157
  @provider.remove_package("zsh", nil)
158
158
  end
159
159
 
160
160
  it "should add options to the port command when specified" do
161
161
  allow(@new_resource).to receive(:options).and_return("-f")
162
- expect(@provider).to receive(:shell_out!).with("port -f deactivate zsh @4.2.7", timeout: 900)
162
+ expect(@provider).to receive(:shell_out!).with("port", "-f", "deactivate", "zsh", "@4.2.7", timeout: 900)
163
163
  @provider.remove_package("zsh", "4.2.7")
164
164
  end
165
165
  end
@@ -169,7 +169,7 @@ EOF
169
169
  expect(@current_resource).to receive(:version).at_least(:once).and_return("4.1.6")
170
170
  @provider.current_resource = @current_resource
171
171
 
172
- expect(@provider).to receive(:shell_out!).with("port upgrade zsh @4.2.7", timeout: 900)
172
+ expect(@provider).to receive(:shell_out!).with("port", "upgrade", "zsh", "@4.2.7", timeout: 900)
173
173
 
174
174
  @provider.upgrade_package("zsh", "4.2.7")
175
175
  end
@@ -195,7 +195,7 @@ EOF
195
195
  expect(@current_resource).to receive(:version).at_least(:once).and_return("4.1.6")
196
196
  @provider.current_resource = @current_resource
197
197
 
198
- expect(@provider).to receive(:shell_out!).with("port -f upgrade zsh @4.2.7", timeout: 900)
198
+ expect(@provider).to receive(:shell_out!).with("port", "-f", "upgrade", "zsh", "@4.2.7", timeout: 900)
199
199
 
200
200
  @provider.upgrade_package("zsh", "4.2.7")
201
201
  end
@@ -45,17 +45,17 @@ describe Chef::Provider::Package::Openbsd do
45
45
 
46
46
  context "when not already installed" do
47
47
  before do
48
- allow(provider).to receive(:shell_out!).with("pkg_info -e \"#{name}->0\"", anything()).and_return(instance_double("shellout", :stdout => ""))
48
+ allow(provider).to receive(:shell_out!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
49
49
  end
50
50
 
51
51
  context "when there is a single candidate" do
52
52
 
53
53
  context "when source is not provided" do
54
54
  it "should run the installation command" do
55
- expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
55
+ expect(provider).to receive(:shell_out!).with("pkg_info", "-I", name, anything()).and_return(
56
56
  instance_double("shellout", :stdout => "#{name}-#{version}\n"))
57
57
  expect(provider).to receive(:shell_out!).with(
58
- "pkg_add -r #{name}-#{version}",
58
+ "pkg_add", "-r", "#{name}-#{version}",
59
59
  { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
60
60
  ) { OpenStruct.new :status => true }
61
61
  provider.run_action(:install)
@@ -69,7 +69,7 @@ describe Chef::Provider::Package::Openbsd do
69
69
 
70
70
  context "if no version is specified" do
71
71
  it "should raise an exception" do
72
- expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
72
+ expect(provider).to receive(:shell_out!).with("pkg_info", "-I", name, anything()).and_return(
73
73
  instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
74
74
  expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
75
75
  end
@@ -83,11 +83,11 @@ describe Chef::Provider::Package::Openbsd do
83
83
 
84
84
  context "if no version is specified" do
85
85
  it "should run the installation command" do
86
- expect(provider).to receive(:shell_out!).with("pkg_info -e \"#{package_name}->0\"", anything()).and_return(instance_double("shellout", :stdout => ""))
87
- expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
86
+ expect(provider).to receive(:shell_out!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
87
+ expect(provider).to receive(:shell_out!).with("pkg_info", "-I", name, anything()).and_return(
88
88
  instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n"))
89
89
  expect(provider).to receive(:shell_out!).with(
90
- "pkg_add -r #{name}-#{version}-#{flavor}",
90
+ "pkg_add", "-r", "#{name}-#{version}-#{flavor}",
91
91
  { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
92
92
  ) { OpenStruct.new :status => true }
93
93
  provider.run_action(:install)
@@ -98,12 +98,12 @@ describe Chef::Provider::Package::Openbsd do
98
98
 
99
99
  context "if a version is specified" do
100
100
  it "should use the flavor from the version" do
101
- expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}-#{version}-#{flavor_b}\"", anything()).and_return(
101
+ expect(provider).to receive(:shell_out!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return(
102
102
  instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n"))
103
103
 
104
104
  new_resource.version("#{version}-#{flavor_b}")
105
105
  expect(provider).to receive(:shell_out!).with(
106
- "pkg_add -r #{name}-#{version}-#{flavor_b}",
106
+ "pkg_add", "-r", "#{name}-#{version}-#{flavor_b}",
107
107
  { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
108
108
  ) { OpenStruct.new :status => true }
109
109
  provider.run_action(:install)
@@ -123,7 +123,7 @@ describe Chef::Provider::Package::Openbsd do
123
123
  end
124
124
  it "should run the command to delete the installed package" do
125
125
  expect(@provider).to receive(:shell_out!).with(
126
- "pkg_delete #{@name}", env: nil, timeout: 900
126
+ "pkg_delete", @name, env: nil, timeout: 900
127
127
  ) { OpenStruct.new :status => true }
128
128
  @provider.remove_package(@name, nil)
129
129
  end