chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -1
  3. data/README.md +6 -4
  4. data/Rakefile +1 -4
  5. data/chef-windows.gemspec +21 -0
  6. data/chef.gemspec +58 -0
  7. data/lib/chef/api_client/registration.rb +9 -4
  8. data/lib/chef/application.rb +3 -84
  9. data/lib/chef/application/apply.rb +9 -2
  10. data/lib/chef/application/client.rb +8 -3
  11. data/lib/chef/application/solo.rb +7 -1
  12. data/lib/chef/application/windows_service.rb +21 -6
  13. data/lib/chef/application/windows_service_manager.rb +2 -3
  14. data/lib/chef/audit/runner.rb +1 -0
  15. data/lib/chef/chef_class.rb +1 -11
  16. data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
  17. data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
  18. data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
  19. data/lib/chef/client.rb +28 -1
  20. data/lib/chef/cookbook/cookbook_collection.rb +14 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +115 -9
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +6 -2
  25. data/lib/chef/data_bag.rb +1 -1
  26. data/lib/chef/data_bag_item.rb +1 -1
  27. data/lib/chef/digester.rb +5 -1
  28. data/lib/chef/dsl/chef_provisioning.rb +57 -0
  29. data/lib/chef/dsl/cheffish.rb +64 -0
  30. data/lib/chef/dsl/declare_resource.rb +108 -0
  31. data/lib/chef/dsl/platform_introspection.rb +3 -3
  32. data/lib/chef/dsl/recipe.rb +3 -73
  33. data/lib/chef/dsl/resources.rb +27 -1
  34. data/lib/chef/event_dispatch/base.rb +3 -0
  35. data/lib/chef/event_dispatch/dispatcher.rb +5 -0
  36. data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
  37. data/lib/chef/exceptions.rb +21 -1
  38. data/lib/chef/file_access_control/unix.rb +12 -12
  39. data/lib/chef/file_content_management/deploy/cp.rb +2 -2
  40. data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
  41. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  42. data/lib/chef/formatters/base.rb +7 -0
  43. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
  44. data/lib/chef/formatters/indentable_output_stream.rb +5 -0
  45. data/lib/chef/http.rb +19 -3
  46. data/lib/chef/http/decompressor.rb +2 -2
  47. data/lib/chef/json_compat.rb +1 -0
  48. data/lib/chef/knife.rb +16 -2
  49. data/lib/chef/knife/bootstrap.rb +55 -10
  50. data/lib/chef/knife/cookbook_site_install.rb +5 -1
  51. data/lib/chef/knife/core/bootstrap_context.rb +2 -1
  52. data/lib/chef/knife/core/node_presenter.rb +1 -1
  53. data/lib/chef/knife/ssh.rb +30 -16
  54. data/lib/chef/knife/ssl_check.rb +4 -2
  55. data/lib/chef/knife/ssl_fetch.rb +3 -2
  56. data/lib/chef/knife/status.rb +14 -1
  57. data/lib/chef/log.rb +14 -0
  58. data/lib/chef/mixin/get_source_from_package.rb +7 -2
  59. data/lib/chef/mixin/properties.rb +302 -0
  60. data/lib/chef/mixin/proxified_socket.rb +38 -0
  61. data/lib/chef/mixin/subclass_directive.rb +37 -0
  62. data/lib/chef/node.rb +13 -5
  63. data/lib/chef/platform/query_helpers.rb +14 -3
  64. data/lib/chef/platform/service_helpers.rb +20 -38
  65. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  66. data/lib/chef/policy_builder/policyfile.rb +1 -0
  67. data/lib/chef/property.rb +51 -12
  68. data/lib/chef/provider.rb +40 -35
  69. data/lib/chef/provider/deploy.rb +1 -1
  70. data/lib/chef/provider/dsc_resource.rb +54 -20
  71. data/lib/chef/provider/execute.rb +25 -4
  72. data/lib/chef/provider/group.rb +1 -1
  73. data/lib/chef/provider/lwrp_base.rb +1 -0
  74. data/lib/chef/provider/package.rb +76 -30
  75. data/lib/chef/provider/package/dpkg.rb +152 -69
  76. data/lib/chef/provider/package/openbsd.rb +6 -8
  77. data/lib/chef/provider/package/solaris.rb +2 -0
  78. data/lib/chef/provider/package/windows.rb +95 -14
  79. data/lib/chef/provider/package/windows/exe.rb +129 -0
  80. data/lib/chef/provider/package/windows/msi.rb +37 -13
  81. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
  82. data/lib/chef/provider/package/yum.rb +13 -3
  83. data/lib/chef/provider/powershell_script.rb +3 -0
  84. data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
  85. data/lib/chef/provider/remote_file/http.rb +1 -1
  86. data/lib/chef/provider/script.rb +1 -0
  87. data/lib/chef/provider/service.rb +13 -10
  88. data/lib/chef/provider/service/solaris.rb +43 -17
  89. data/lib/chef/provider/service/upstart.rb +3 -3
  90. data/lib/chef/provider/user.rb +1 -1
  91. data/lib/chef/provider/user/dscl.rb +111 -100
  92. data/lib/chef/provider/user/windows.rb +5 -3
  93. data/lib/chef/recipe.rb +3 -5
  94. data/lib/chef/resource.rb +77 -320
  95. data/lib/chef/resource/action_class.rb +4 -0
  96. data/lib/chef/resource/dpkg_package.rb +4 -3
  97. data/lib/chef/resource/dsc_resource.rb +40 -2
  98. data/lib/chef/resource/execute.rb +9 -1
  99. data/lib/chef/resource/ksh.rb +32 -0
  100. data/lib/chef/resource/lwrp_base.rb +6 -10
  101. data/lib/chef/resource/package.rb +8 -9
  102. data/lib/chef/resource/registry_key.rb +1 -1
  103. data/lib/chef/resource/resource_notification.rb +14 -1
  104. data/lib/chef/resource/script.rb +1 -1
  105. data/lib/chef/resource/windows_package.rb +1 -1
  106. data/lib/chef/resource_builder.rb +14 -7
  107. data/lib/chef/resource_reporter.rb +6 -0
  108. data/lib/chef/resources.rb +1 -7
  109. data/lib/chef/rest.rb +1 -1
  110. data/lib/chef/run_context.rb +45 -2
  111. data/lib/chef/run_list/run_list_expansion.rb +47 -0
  112. data/lib/chef/runner.rb +25 -0
  113. data/lib/chef/search/query.rb +16 -2
  114. data/lib/chef/util/diff.rb +2 -2
  115. data/lib/chef/util/powershell/ps_credential.rb +2 -3
  116. data/lib/chef/version.rb +1 -1
  117. data/lib/chef/win32/api/file.rb +51 -1
  118. data/lib/chef/win32/file.rb +5 -0
  119. data/lib/chef/win32/file/version_info.rb +93 -0
  120. data/lib/chef/win32/mutex.rb +1 -1
  121. data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
  122. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
  123. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
  124. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
  125. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
  126. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
  127. data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
  128. data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
  129. data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
  130. data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
  131. data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
  132. data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
  133. data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
  134. data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
  135. data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
  136. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
  137. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
  138. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
  139. data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
  140. data/spec/functional/application_spec.rb +1 -1
  141. data/spec/functional/audit/runner_spec.rb +4 -0
  142. data/spec/functional/knife/ssh_spec.rb +5 -5
  143. data/spec/functional/notifications_spec.rb +74 -4
  144. data/spec/functional/resource/aix_service_spec.rb +2 -2
  145. data/spec/functional/resource/dpkg_package_spec.rb +339 -0
  146. data/spec/functional/resource/ifconfig_spec.rb +3 -1
  147. data/spec/functional/resource/mount_spec.rb +5 -2
  148. data/spec/functional/resource/package_spec.rb +1 -1
  149. data/spec/functional/resource/user/windows_spec.rb +8 -0
  150. data/spec/functional/resource/windows_package_spec.rb +177 -0
  151. data/spec/functional/win32/version_info_spec.rb +50 -0
  152. data/spec/integration/client/client_spec.rb +80 -0
  153. data/spec/integration/knife/download_spec.rb +9 -0
  154. data/spec/integration/knife/upload_spec.rb +28 -1
  155. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
  156. data/spec/integration/recipes/resource_action_spec.rb +211 -116
  157. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
  158. data/spec/integration/solo/solo_spec.rb +34 -0
  159. data/spec/spec_helper.rb +11 -1
  160. data/spec/support/platform_helpers.rb +8 -0
  161. data/spec/support/shared/integration/integration_helper.rb +6 -0
  162. data/spec/support/shared/unit/execute_resource.rb +5 -0
  163. data/spec/support/shared/unit/platform_introspector.rb +7 -0
  164. data/spec/tiny_server.rb +6 -2
  165. data/spec/unit/api_client/registration_spec.rb +5 -4
  166. data/spec/unit/application_spec.rb +1 -181
  167. data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
  168. data/spec/unit/cookbook/metadata_spec.rb +122 -2
  169. data/spec/unit/http_spec.rb +102 -0
  170. data/spec/unit/knife/bootstrap_spec.rb +55 -13
  171. data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
  172. data/spec/unit/knife/ssl_check_spec.rb +7 -3
  173. data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
  174. data/spec/unit/knife/status_spec.rb +13 -13
  175. data/spec/unit/knife_spec.rb +26 -2
  176. data/spec/unit/lwrp_spec.rb +1 -1
  177. data/spec/unit/mixin/properties_spec.rb +97 -0
  178. data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
  179. data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
  180. data/spec/unit/node_spec.rb +9 -1
  181. data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
  182. data/spec/unit/property/validation_spec.rb +14 -12
  183. data/spec/unit/property_spec.rb +56 -0
  184. data/spec/unit/provider/deploy_spec.rb +1 -1
  185. data/spec/unit/provider/dsc_resource_spec.rb +63 -24
  186. data/spec/unit/provider/execute_spec.rb +95 -28
  187. data/spec/unit/provider/package/dpkg_spec.rb +185 -96
  188. data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
  189. data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
  190. data/spec/unit/provider/package/windows_spec.rb +227 -26
  191. data/spec/unit/provider/package/yum_spec.rb +6 -0
  192. data/spec/unit/provider/package_spec.rb +495 -366
  193. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
  194. data/spec/unit/provider/script_spec.rb +2 -2
  195. data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
  196. data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
  197. data/spec/unit/provider/user/dscl_spec.rb +14 -0
  198. data/spec/unit/provider/user/windows_spec.rb +2 -2
  199. data/spec/unit/provider/user_spec.rb +9 -0
  200. data/spec/unit/provider_resolver_spec.rb +6 -30
  201. data/spec/unit/recipe_spec.rb +46 -20
  202. data/spec/unit/resource/chef_gem_spec.rb +1 -1
  203. data/spec/unit/resource/dsc_resource_spec.rb +14 -3
  204. data/spec/unit/resource/ksh_spec.rb +40 -0
  205. data/spec/unit/resource/registry_key_spec.rb +2 -2
  206. data/spec/unit/resource/resource_notification_spec.rb +44 -45
  207. data/spec/unit/resource_reporter_spec.rb +7 -0
  208. data/spec/unit/resource_spec.rb +268 -253
  209. data/spec/unit/rest_spec.rb +2 -2
  210. data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
  211. data/spec/unit/search/query_spec.rb +19 -1
  212. data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
  213. data/spec/unit/windows_service_spec.rb +83 -38
  214. data/tasks/external_tests.rb +19 -9
  215. data/tasks/rspec.rb +1 -1
  216. metadata +70 -21
  217. data/spec/support/pedant/Gemfile +0 -3
  218. data/spec/support/pedant/pedant_config.rb +0 -129
  219. data/spec/support/pedant/run_pedant.rb +0 -63
  220. data/spec/support/pedant/stickywicket.pem +0 -27
  221. data/spec/unit/provider/package_spec.rbe +0 -0
@@ -1844,6 +1844,12 @@ EOF
1844
1844
  expect(@yc.python_bin).to eq("/usr/bin/python")
1845
1845
  end
1846
1846
 
1847
+ it "should return /usr/bin/python if the interpreter is /bin/bash" do
1848
+ other = StringIO.new("#!/bin/bash\n# The yum executable redirecting to dnf from dnf-yum compatible package.")
1849
+ allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
1850
+ expect(@yc.python_bin).to eq("/usr/bin/python")
1851
+ end
1852
+
1847
1853
  it "should return the interpreter for yum" do
1848
1854
  other = StringIO.new("#!/usr/bin/super_python\n\nlasjdfdsaljf\nlasdjfs")
1849
1855
  allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2008-2015 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");
@@ -19,347 +19,351 @@
19
19
  require 'spec_helper'
20
20
 
21
21
  describe Chef::Provider::Package do
22
- before do
23
- @node = Chef::Node.new
24
- @events = Chef::EventDispatch::Dispatcher.new
25
- @run_context = Chef::RunContext.new(@node, {}, @events)
26
- @new_resource = Chef::Resource::Package.new('emacs')
27
- @current_resource = Chef::Resource::Package.new('emacs')
28
- @provider = Chef::Provider::Package.new(@new_resource, @run_context)
29
- @provider.current_resource = @current_resource
30
-
31
- @provider.candidate_version = "1.0"
22
+ let(:node) do
23
+ node = Chef::Node.new
24
+ node.automatic_attrs[:platform] = :just_testing
25
+ node.automatic_attrs[:platform_version] = :just_testing
26
+ node
27
+ end
28
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
29
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
30
+ let(:new_resource) { Chef::Resource::Package.new('emacs') }
31
+ let(:current_resource) { Chef::Resource::Package.new('emacs') }
32
+ let(:candidate_version) { "1.0" }
33
+ let(:provider) do
34
+ provider = Chef::Provider::Package.new(new_resource, run_context)
35
+ provider.current_resource = current_resource
36
+ provider.candidate_version = candidate_version
37
+ provider
32
38
  end
33
39
 
34
40
  describe "when installing a package" do
35
41
  before(:each) do
36
- @provider.current_resource = @current_resource
37
- allow(@provider).to receive(:install_package).and_return(true)
42
+ provider.current_resource = current_resource
43
+ allow(provider).to receive(:install_package).and_return(true)
38
44
  end
39
45
 
40
46
  it "raises a Chef::Exceptions::InvalidResourceSpecification if both multipackage and source are provided" do
41
- @new_resource.package_name(['a', 'b'])
42
- @new_resource.source('foo')
43
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification)
47
+ new_resource.package_name(['a', 'b'])
48
+ new_resource.source('foo')
49
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification)
44
50
  end
45
51
 
46
52
  it "should raise a Chef::Exceptions::Package if no version is specified, and no candidate is available" do
47
- @provider.candidate_version = nil
48
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
53
+ provider.candidate_version = nil
54
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
49
55
  end
50
56
 
51
57
  it "should call preseed_package if a response_file is given" do
52
- @new_resource.response_file("foo")
53
- expect(@provider).to receive(:get_preseed_file).with(
54
- @new_resource.name,
55
- @provider.candidate_version
58
+ new_resource.response_file("foo")
59
+ expect(provider).to receive(:get_preseed_file).with(
60
+ new_resource.name,
61
+ provider.candidate_version
56
62
  ).and_return("/var/cache/preseed-test")
57
63
 
58
- expect(@provider).to receive(:preseed_package).with(
64
+ expect(provider).to receive(:preseed_package).with(
59
65
  "/var/cache/preseed-test"
60
66
  ).and_return(true)
61
- @provider.run_action(:install)
67
+ provider.run_action(:install)
62
68
  end
63
69
 
64
70
  it "should not call preseed_package if a response_file is not given" do
65
- expect(@provider).not_to receive(:preseed_package)
66
- @provider.run_action(:install)
71
+ expect(provider).not_to receive(:preseed_package)
72
+ provider.run_action(:install)
67
73
  end
68
74
 
69
75
  it "should install the package at the candidate_version if it is not already installed" do
70
- expect(@provider).to receive(:install_package).with(
71
- @new_resource.name,
72
- @provider.candidate_version
76
+ expect(provider).to receive(:install_package).with(
77
+ new_resource.name,
78
+ provider.candidate_version
73
79
  ).and_return(true)
74
- @provider.run_action(:install)
75
- expect(@new_resource).to be_updated_by_last_action
80
+ provider.run_action(:install)
81
+ expect(new_resource).to be_updated_by_last_action
76
82
  end
77
83
 
78
84
  it "should install the package at the version specified if it is not already installed" do
79
- @new_resource.version("1.0")
80
- expect(@provider).to receive(:install_package).with(
81
- @new_resource.name,
82
- @new_resource.version
85
+ new_resource.version("1.0")
86
+ expect(provider).to receive(:install_package).with(
87
+ new_resource.name,
88
+ new_resource.version
83
89
  ).and_return(true)
84
- @provider.run_action(:install)
85
- expect(@new_resource).to be_updated_by_last_action
90
+ provider.run_action(:install)
91
+ expect(new_resource).to be_updated_by_last_action
86
92
  end
87
93
 
88
94
  it "should install the package at the version specified if a different version is installed" do
89
- @new_resource.version("1.0")
90
- allow(@current_resource).to receive(:version).and_return("0.99")
91
- expect(@provider).to receive(:install_package).with(
92
- @new_resource.name,
93
- @new_resource.version
95
+ new_resource.version("1.0")
96
+ allow(current_resource).to receive(:version).and_return("0.99")
97
+ expect(provider).to receive(:install_package).with(
98
+ new_resource.name,
99
+ new_resource.version
94
100
  ).and_return(true)
95
- @provider.run_action(:install)
96
- expect(@new_resource).to be_updated_by_last_action
101
+ provider.run_action(:install)
102
+ expect(new_resource).to be_updated_by_last_action
97
103
  end
98
104
 
99
105
  it "should not install the package if it is already installed and no version is specified" do
100
- @current_resource.version("1.0")
101
- expect(@provider).not_to receive(:install_package)
102
- @provider.run_action(:install)
103
- expect(@new_resource).not_to be_updated_by_last_action
106
+ current_resource.version("1.0")
107
+ expect(provider).not_to receive(:install_package)
108
+ provider.run_action(:install)
109
+ expect(new_resource).not_to be_updated_by_last_action
104
110
  end
105
111
 
106
112
  it "should not install the package if it is already installed at the version specified" do
107
- @current_resource.version("1.0")
108
- @new_resource.version("1.0")
109
- expect(@provider).not_to receive(:install_package)
110
- @provider.run_action(:install)
111
- expect(@new_resource).not_to be_updated_by_last_action
113
+ current_resource.version("1.0")
114
+ new_resource.version("1.0")
115
+ expect(provider).not_to receive(:install_package)
116
+ provider.run_action(:install)
117
+ expect(new_resource).not_to be_updated_by_last_action
112
118
  end
113
119
 
114
120
  it "should call the candidate_version accessor only once if the package is already installed and no version is specified" do
115
- @current_resource.version("1.0")
116
- allow(@provider).to receive(:candidate_version).and_return("1.0")
117
- @provider.run_action(:install)
121
+ current_resource.version("1.0")
122
+ allow(provider).to receive(:candidate_version).and_return("1.0")
123
+ provider.run_action(:install)
118
124
  end
119
125
 
120
126
  it "should call the candidate_version accessor only once if the package is already installed at the version specified" do
121
- @current_resource.version("1.0")
122
- @new_resource.version("1.0")
123
- @provider.run_action(:install)
127
+ current_resource.version("1.0")
128
+ new_resource.version("1.0")
129
+ provider.run_action(:install)
124
130
  end
125
131
 
126
132
  it "should set the resource to updated if it installs the package" do
127
- @provider.run_action(:install)
128
- expect(@new_resource).to be_updated
133
+ provider.run_action(:install)
134
+ expect(new_resource).to be_updated
129
135
  end
130
136
 
131
137
  end
132
138
 
133
139
  describe "when upgrading the package" do
134
140
  before(:each) do
135
- allow(@provider).to receive(:upgrade_package).and_return(true)
141
+ allow(provider).to receive(:upgrade_package).and_return(true)
136
142
  end
137
143
 
138
144
  it "should upgrade the package if the current version is not the candidate version" do
139
- expect(@provider).to receive(:upgrade_package).with(
140
- @new_resource.name,
141
- @provider.candidate_version
145
+ expect(provider).to receive(:upgrade_package).with(
146
+ new_resource.name,
147
+ provider.candidate_version
142
148
  ).and_return(true)
143
- @provider.run_action(:upgrade)
144
- expect(@new_resource).to be_updated_by_last_action
149
+ provider.run_action(:upgrade)
150
+ expect(new_resource).to be_updated_by_last_action
145
151
  end
146
152
 
147
153
  it "should set the resource to updated if it installs the package" do
148
- @provider.run_action(:upgrade)
149
- expect(@new_resource).to be_updated
154
+ provider.run_action(:upgrade)
155
+ expect(new_resource).to be_updated
150
156
  end
151
157
 
152
158
  it "should not install the package if the current version is the candidate version" do
153
- @current_resource.version "1.0"
154
- expect(@provider).not_to receive(:upgrade_package)
155
- @provider.run_action(:upgrade)
156
- expect(@new_resource).not_to be_updated_by_last_action
159
+ current_resource.version "1.0"
160
+ expect(provider).not_to receive(:upgrade_package)
161
+ provider.run_action(:upgrade)
162
+ expect(new_resource).not_to be_updated_by_last_action
157
163
  end
158
164
 
159
165
  it "should print the word 'uninstalled' if there was no original version" do
160
- allow(@current_resource).to receive(:version).and_return(nil)
166
+ allow(current_resource).to receive(:version).and_return(nil)
161
167
  expect(Chef::Log).to receive(:info).with("package[emacs] upgraded emacs to 1.0")
162
- @provider.run_action(:upgrade)
163
- expect(@new_resource).to be_updated_by_last_action
168
+ provider.run_action(:upgrade)
169
+ expect(new_resource).to be_updated_by_last_action
164
170
  end
165
171
 
166
172
  it "should raise a Chef::Exceptions::Package if current version and candidate are nil" do
167
- allow(@current_resource).to receive(:version).and_return(nil)
168
- @provider.candidate_version = nil
169
- expect { @provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
173
+ allow(current_resource).to receive(:version).and_return(nil)
174
+ provider.candidate_version = nil
175
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
170
176
  end
171
177
 
172
178
  it "should not install the package if candidate version is nil" do
173
- @current_resource.version "1.0"
174
- @provider.candidate_version = nil
175
- expect(@provider).not_to receive(:upgrade_package)
176
- @provider.run_action(:upgrade)
177
- expect(@new_resource).not_to be_updated_by_last_action
179
+ current_resource.version "1.0"
180
+ provider.candidate_version = nil
181
+ expect(provider).not_to receive(:upgrade_package)
182
+ provider.run_action(:upgrade)
183
+ expect(new_resource).not_to be_updated_by_last_action
178
184
  end
179
185
  end
180
186
 
181
187
  describe "When removing the package" do
182
188
  before(:each) do
183
- allow(@provider).to receive(:remove_package).and_return(true)
184
- @current_resource.version '1.4.2'
189
+ allow(provider).to receive(:remove_package).and_return(true)
190
+ current_resource.version '1.4.2'
185
191
  end
186
192
 
187
193
  it "should remove the package if it is installed" do
188
- expect(@provider).to be_removing_package
189
- expect(@provider).to receive(:remove_package).with('emacs', nil)
190
- @provider.run_action(:remove)
191
- expect(@new_resource).to be_updated
192
- expect(@new_resource).to be_updated_by_last_action
194
+ expect(provider).to be_removing_package
195
+ expect(provider).to receive(:remove_package).with('emacs', nil)
196
+ provider.run_action(:remove)
197
+ expect(new_resource).to be_updated
198
+ expect(new_resource).to be_updated_by_last_action
193
199
  end
194
200
 
195
201
  it "should remove the package at a specific version if it is installed at that version" do
196
- @new_resource.version "1.4.2"
197
- expect(@provider).to be_removing_package
198
- expect(@provider).to receive(:remove_package).with('emacs', '1.4.2')
199
- @provider.run_action(:remove)
200
- expect(@new_resource).to be_updated_by_last_action
202
+ new_resource.version "1.4.2"
203
+ expect(provider).to be_removing_package
204
+ expect(provider).to receive(:remove_package).with('emacs', '1.4.2')
205
+ provider.run_action(:remove)
206
+ expect(new_resource).to be_updated_by_last_action
201
207
  end
202
208
 
203
209
  it "should not remove the package at a specific version if it is not installed at that version" do
204
- @new_resource.version "1.0"
205
- expect(@provider).not_to be_removing_package
206
- expect(@provider).not_to receive(:remove_package)
207
- @provider.run_action(:remove)
208
- expect(@new_resource).not_to be_updated_by_last_action
210
+ new_resource.version "1.0"
211
+ expect(provider).not_to be_removing_package
212
+ expect(provider).not_to receive(:remove_package)
213
+ provider.run_action(:remove)
214
+ expect(new_resource).not_to be_updated_by_last_action
209
215
  end
210
216
 
211
217
  it "should not remove the package if it is not installed" do
212
- expect(@provider).not_to receive(:remove_package)
213
- allow(@current_resource).to receive(:version).and_return(nil)
214
- @provider.run_action(:remove)
215
- expect(@new_resource).not_to be_updated_by_last_action
218
+ expect(provider).not_to receive(:remove_package)
219
+ allow(current_resource).to receive(:version).and_return(nil)
220
+ provider.run_action(:remove)
221
+ expect(new_resource).not_to be_updated_by_last_action
216
222
  end
217
223
 
218
224
  it "should set the resource to updated if it removes the package" do
219
- @provider.run_action(:remove)
220
- expect(@new_resource).to be_updated
225
+ provider.run_action(:remove)
226
+ expect(new_resource).to be_updated
221
227
  end
222
228
 
223
229
  end
224
230
 
225
231
  describe "When purging the package" do
226
232
  before(:each) do
227
- allow(@provider).to receive(:purge_package).and_return(true)
228
- @current_resource.version '1.4.2'
233
+ allow(provider).to receive(:purge_package).and_return(true)
234
+ current_resource.version '1.4.2'
229
235
  end
230
236
 
231
237
  it "should purge the package if it is installed" do
232
- expect(@provider).to be_removing_package
233
- expect(@provider).to receive(:purge_package).with('emacs', nil)
234
- @provider.run_action(:purge)
235
- expect(@new_resource).to be_updated
236
- expect(@new_resource).to be_updated_by_last_action
238
+ expect(provider).to be_removing_package
239
+ expect(provider).to receive(:purge_package).with('emacs', nil)
240
+ provider.run_action(:purge)
241
+ expect(new_resource).to be_updated
242
+ expect(new_resource).to be_updated_by_last_action
237
243
  end
238
244
 
239
245
  it "should purge the package at a specific version if it is installed at that version" do
240
- @new_resource.version "1.4.2"
241
- expect(@provider).to be_removing_package
242
- expect(@provider).to receive(:purge_package).with('emacs', '1.4.2')
243
- @provider.run_action(:purge)
244
- expect(@new_resource).to be_updated_by_last_action
246
+ new_resource.version "1.4.2"
247
+ expect(provider).to be_removing_package
248
+ expect(provider).to receive(:purge_package).with('emacs', '1.4.2')
249
+ provider.run_action(:purge)
250
+ expect(new_resource).to be_updated_by_last_action
245
251
  end
246
252
 
247
253
  it "should not purge the package at a specific version if it is not installed at that version" do
248
- @new_resource.version "1.0"
249
- expect(@provider).not_to be_removing_package
250
- expect(@provider).not_to receive(:purge_package)
251
- @provider.run_action(:purge)
252
- expect(@new_resource).not_to be_updated_by_last_action
254
+ new_resource.version "1.0"
255
+ expect(provider).not_to be_removing_package
256
+ expect(provider).not_to receive(:purge_package)
257
+ provider.run_action(:purge)
258
+ expect(new_resource).not_to be_updated_by_last_action
253
259
  end
254
260
 
255
261
  it "should not purge the package if it is not installed" do
256
- @current_resource.instance_variable_set(:@version, nil)
257
- expect(@provider).not_to be_removing_package
262
+ current_resource.instance_variable_set(:@version, nil)
263
+ expect(provider).not_to be_removing_package
258
264
 
259
- expect(@provider).not_to receive(:purge_package)
260
- @provider.run_action(:purge)
261
- expect(@new_resource).not_to be_updated_by_last_action
265
+ expect(provider).not_to receive(:purge_package)
266
+ provider.run_action(:purge)
267
+ expect(new_resource).not_to be_updated_by_last_action
262
268
  end
263
269
 
264
270
  it "should set the resource to updated if it purges the package" do
265
- @provider.run_action(:purge)
266
- expect(@new_resource).to be_updated
271
+ provider.run_action(:purge)
272
+ expect(new_resource).to be_updated
267
273
  end
268
274
 
269
275
  end
270
276
 
271
277
  describe "when reconfiguring the package" do
272
278
  before(:each) do
273
- allow(@provider).to receive(:reconfig_package).and_return(true)
279
+ allow(provider).to receive(:reconfig_package).and_return(true)
274
280
  end
275
281
 
276
282
  it "should info log, reconfigure the package and update the resource" do
277
- allow(@current_resource).to receive(:version).and_return('1.0')
278
- allow(@new_resource).to receive(:response_file).and_return(true)
279
- expect(@provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test')
280
- allow(@provider).to receive(:preseed_package).and_return(true)
281
- allow(@provider).to receive(:reconfig_package).and_return(true)
283
+ allow(current_resource).to receive(:version).and_return('1.0')
284
+ allow(new_resource).to receive(:response_file).and_return(true)
285
+ expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test')
286
+ allow(provider).to receive(:preseed_package).and_return(true)
287
+ allow(provider).to receive(:reconfig_package).and_return(true)
282
288
  expect(Chef::Log).to receive(:info).with("package[emacs] reconfigured")
283
- expect(@provider).to receive(:reconfig_package)
284
- @provider.run_action(:reconfig)
285
- expect(@new_resource).to be_updated
286
- expect(@new_resource).to be_updated_by_last_action
289
+ expect(provider).to receive(:reconfig_package)
290
+ provider.run_action(:reconfig)
291
+ expect(new_resource).to be_updated
292
+ expect(new_resource).to be_updated_by_last_action
287
293
  end
288
294
 
289
295
  it "should debug log and not reconfigure the package if the package is not installed" do
290
- allow(@current_resource).to receive(:version).and_return(nil)
296
+ allow(current_resource).to receive(:version).and_return(nil)
291
297
  expect(Chef::Log).to receive(:debug).with("package[emacs] is NOT installed - nothing to do")
292
- expect(@provider).not_to receive(:reconfig_package)
293
- @provider.run_action(:reconfig)
294
- expect(@new_resource).not_to be_updated_by_last_action
298
+ expect(provider).not_to receive(:reconfig_package)
299
+ provider.run_action(:reconfig)
300
+ expect(new_resource).not_to be_updated_by_last_action
295
301
  end
296
302
 
297
303
  it "should debug log and not reconfigure the package if no response_file is given" do
298
- allow(@current_resource).to receive(:version).and_return('1.0')
299
- allow(@new_resource).to receive(:response_file).and_return(nil)
304
+ allow(current_resource).to receive(:version).and_return('1.0')
305
+ allow(new_resource).to receive(:response_file).and_return(nil)
300
306
  expect(Chef::Log).to receive(:debug).with("package[emacs] no response_file provided - nothing to do")
301
- expect(@provider).not_to receive(:reconfig_package)
302
- @provider.run_action(:reconfig)
303
- expect(@new_resource).not_to be_updated_by_last_action
307
+ expect(provider).not_to receive(:reconfig_package)
308
+ provider.run_action(:reconfig)
309
+ expect(new_resource).not_to be_updated_by_last_action
304
310
  end
305
311
 
306
312
  it "should debug log and not reconfigure the package if the response_file has not changed" do
307
- allow(@current_resource).to receive(:version).and_return('1.0')
308
- allow(@new_resource).to receive(:response_file).and_return(true)
309
- expect(@provider).to receive(:get_preseed_file).and_return(false)
310
- allow(@provider).to receive(:preseed_package).and_return(false)
313
+ allow(current_resource).to receive(:version).and_return('1.0')
314
+ allow(new_resource).to receive(:response_file).and_return(true)
315
+ expect(provider).to receive(:get_preseed_file).and_return(false)
316
+ allow(provider).to receive(:preseed_package).and_return(false)
311
317
  expect(Chef::Log).to receive(:debug).with("package[emacs] preseeding has not changed - nothing to do")
312
- expect(@provider).not_to receive(:reconfig_package)
313
- @provider.run_action(:reconfig)
314
- expect(@new_resource).not_to be_updated_by_last_action
318
+ expect(provider).not_to receive(:reconfig_package)
319
+ provider.run_action(:reconfig)
320
+ expect(new_resource).not_to be_updated_by_last_action
315
321
  end
316
322
  end
317
323
 
318
324
  describe "when running commands to be implemented by subclasses" do
319
325
  it "should raises UnsupportedAction for install" do
320
- expect { @provider.install_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
326
+ expect { provider.install_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
321
327
  end
322
328
 
323
329
  it "should raises UnsupportedAction for upgrade" do
324
- expect { @provider.upgrade_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
330
+ expect { provider.upgrade_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
325
331
  end
326
332
 
327
333
  it "should raises UnsupportedAction for remove" do
328
- expect { @provider.remove_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
334
+ expect { provider.remove_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
329
335
  end
330
336
 
331
337
  it "should raises UnsupportedAction for purge" do
332
- expect { @provider.purge_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
338
+ expect { provider.purge_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
333
339
  end
334
340
 
335
341
  it "should raise UnsupportedAction for preseed_package" do
336
342
  preseed_file = "/tmp/sun-jdk-package-preseed-file.seed"
337
- expect { @provider.preseed_package(preseed_file) }.to raise_error(Chef::Exceptions::UnsupportedAction)
343
+ expect { provider.preseed_package(preseed_file) }.to raise_error(Chef::Exceptions::UnsupportedAction)
338
344
  end
339
345
 
340
346
  it "should raise UnsupportedAction for reconfig" do
341
- expect { @provider.reconfig_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
347
+ expect { provider.reconfig_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
342
348
  end
343
349
  end
344
350
 
345
351
  describe "when given a response file" do
346
- before(:each) do
347
- @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
348
- Chef::Cookbook::FileVendor.fetch_from_disk(@cookbook_repo)
349
-
350
- @node = Chef::Node.new
351
- cl = Chef::CookbookLoader.new(@cookbook_repo)
352
- cl.load_cookbooks
353
- @cookbook_collection = Chef::CookbookCollection.new(cl)
354
-
355
- @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
356
- @provider.run_context = @run_context
357
-
358
- @node.automatic_attrs[:platform] = 'PLATFORM: just testing'
359
- @node.automatic_attrs[:platform_version] = 'PLATFORM VERSION: just testing'
360
-
361
- @new_resource.response_file('java.response')
362
- @new_resource.cookbook_name = 'java'
352
+ let(:cookbook_repo) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) }
353
+ let(:cookbook_loader) do
354
+ Chef::Cookbook::FileVendor.fetch_from_disk(cookbook_repo)
355
+ Chef::CookbookLoader.new(cookbook_repo)
356
+ end
357
+ let(:cookbook_collection) do
358
+ cookbook_loader.load_cookbooks
359
+ Chef::CookbookCollection.new(cookbook_loader)
360
+ end
361
+ let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
362
+ let(:new_resource) do
363
+ new_resource = Chef::Resource::Package.new('emacs')
364
+ new_resource.response_file('java.response')
365
+ new_resource.cookbook_name = 'java'
366
+ new_resource
363
367
  end
364
368
 
365
369
  describe "creating the cookbook file resource to fetch the response file" do
@@ -369,62 +373,60 @@ describe Chef::Provider::Package do
369
373
 
370
374
  it "sets the preseed resource's runcontext to its own run context" do
371
375
  allow(Chef::FileCache).to receive(:create_cache_path).and_return("/tmp/preseed/java")
372
- expect(@provider.preseed_resource('java', '6').run_context).not_to be_nil
373
- expect(@provider.preseed_resource('java', '6').run_context).to equal(@provider.run_context)
376
+ expect(provider.preseed_resource('java', '6').run_context).not_to be_nil
377
+ expect(provider.preseed_resource('java', '6').run_context).to equal(provider.run_context)
374
378
  end
375
379
 
376
380
  it "should set the cookbook name of the remote file to the new resources cookbook name" do
377
- expect(@provider.preseed_resource('java', '6').cookbook_name).to eq('java')
381
+ expect(provider.preseed_resource('java', '6').cookbook_name).to eq('java')
378
382
  end
379
383
 
380
384
  it "should set remote files source to the new resources response file" do
381
- expect(@provider.preseed_resource('java', '6').source).to eq('java.response')
385
+ expect(provider.preseed_resource('java', '6').source).to eq('java.response')
382
386
  end
383
387
 
384
388
  it "should never back up the cached response file" do
385
- expect(@provider.preseed_resource('java', '6').backup).to be_falsey
389
+ expect(provider.preseed_resource('java', '6').backup).to be_falsey
386
390
  end
387
391
 
388
392
  it "sets the install path of the resource to $file_cache/$cookbook/$pkg_name-$pkg_version.seed" do
389
- expect(@provider.preseed_resource('java', '6').path).to eq('/tmp/preseed/java/java-6.seed')
393
+ expect(provider.preseed_resource('java', '6').path).to eq('/tmp/preseed/java/java-6.seed')
390
394
  end
391
395
  end
392
396
 
393
397
  describe "when installing the preseed file to the cache location" do
394
- before do
395
- @node.automatic_attrs[:platform] = :just_testing
396
- @node.automatic_attrs[:platform_version] = :just_testing
397
-
398
- @response_file_destination = Dir.tmpdir + '/preseed--java--java-6.seed'
398
+ let(:response_file_destination) { Dir.tmpdir + '/preseed--java--java-6.seed' }
399
+ let(:response_file_resource) {
400
+ response_file_resource = Chef::Resource::CookbookFile.new(response_file_destination, run_context)
401
+ response_file_resource.cookbook_name = 'java'
402
+ response_file_resource.backup(false)
403
+ response_file_resource.source('java.response')
404
+ response_file_resource
405
+ }
399
406
 
400
- @response_file_resource = Chef::Resource::CookbookFile.new(@response_file_destination, @run_context)
401
- @response_file_resource.cookbook_name = 'java'
402
- @response_file_resource.backup(false)
403
- @response_file_resource.source('java.response')
404
-
405
-
406
- expect(@provider).to receive(:preseed_resource).with('java', '6').and_return(@response_file_resource)
407
+ before do
408
+ expect(provider).to receive(:preseed_resource).with('java', '6').and_return(response_file_resource)
407
409
  end
408
410
 
409
411
  after do
410
- FileUtils.rm(@response_file_destination) if ::File.exist?(@response_file_destination)
412
+ FileUtils.rm(response_file_destination) if ::File.exist?(response_file_destination)
411
413
  end
412
414
 
413
415
  it "creates the preseed file in the cache" do
414
- expect(@response_file_resource).to receive(:run_action).with(:create)
415
- @provider.get_preseed_file("java", "6")
416
+ expect(response_file_resource).to receive(:run_action).with(:create)
417
+ provider.get_preseed_file("java", "6")
416
418
  end
417
419
 
418
420
  it "returns the path to the response file if the response file was updated" do
419
- expect(@provider.get_preseed_file("java", "6")).to eq(@response_file_destination)
421
+ expect(provider.get_preseed_file("java", "6")).to eq(response_file_destination)
420
422
  end
421
423
 
422
424
  it "should return false if the response file has not been updated" do
423
- @response_file_resource.updated_by_last_action(false)
424
- expect(@response_file_resource).not_to be_updated_by_last_action
425
+ response_file_resource.updated_by_last_action(false)
426
+ expect(response_file_resource).not_to be_updated_by_last_action
425
427
  # don't let the response_file_resource set updated to true
426
- expect(@response_file_resource).to receive(:run_action).with(:create)
427
- expect(@provider.get_preseed_file("java", "6")).to be(false)
428
+ expect(response_file_resource).to receive(:run_action).with(:create)
429
+ expect(provider.get_preseed_file("java", "6")).to be(false)
428
430
  end
429
431
 
430
432
  end
@@ -432,276 +434,403 @@ describe Chef::Provider::Package do
432
434
  end
433
435
  end
434
436
 
437
+ describe "Subclass with use_multipackage_api" do
438
+ class MyPackageResource < Chef::Resource::Package
439
+ end
440
+
441
+ class MyPackageProvider < Chef::Provider::Package
442
+ use_multipackage_api
443
+ end
444
+
445
+ let(:node) { Chef::Node.new }
446
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
447
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
448
+ let(:new_resource) { MyPackageResource.new("installs the packages") }
449
+ let(:current_resource) { MyPackageResource.new("installs the packages") }
450
+ let(:provider) do
451
+ provider = MyPackageProvider.new(new_resource, run_context)
452
+ provider.current_resource = current_resource
453
+ provider
454
+ end
455
+
456
+ it "has use_multipackage_api? methods on the class and instance" do
457
+ expect(MyPackageProvider.use_multipackage_api?).to be true
458
+ expect(provider.use_multipackage_api?).to be true
459
+ end
460
+
461
+ it "offers a_to_s to subclasses to convert an array of strings to a single string" do
462
+ expect(provider.send(:a_to_s, "a", nil, "b", "", "c", " ", "d e", "f-g")).to eq("a b c d e f-g")
463
+ end
464
+
465
+ it "when user passes string to package_name, passes arrays to install_package" do
466
+ new_resource.package_name "vim"
467
+ new_resource.version nil
468
+ provider.candidate_version = [ "1.0" ]
469
+ expect(provider).to receive(:install_package).with(
470
+ [ "vim" ],
471
+ [ "1.0" ]
472
+ ).and_return(true)
473
+ provider.run_action(:install)
474
+ expect(new_resource).to be_updated_by_last_action
475
+ expect(new_resource.version).to eql(nil)
476
+ end
477
+
478
+ it "when user pases string to package_name and version, passes arrays to install_package" do
479
+ new_resource.package_name "vim"
480
+ new_resource.version "1.0"
481
+ provider.candidate_version = [ "1.0" ]
482
+ expect(provider).to receive(:install_package).with(
483
+ [ "vim" ],
484
+ [ "1.0" ]
485
+ ).and_return(true)
486
+ provider.run_action(:install)
487
+ expect(new_resource).to be_updated_by_last_action
488
+ expect(new_resource.version).to eql("1.0")
489
+ end
490
+
491
+ it "when user passes string to package_name, passes arrays to upgrade_package" do
492
+ new_resource.package_name "vim"
493
+ new_resource.version nil
494
+ provider.candidate_version = [ "1.0" ]
495
+ expect(provider).to receive(:upgrade_package).with(
496
+ [ "vim" ],
497
+ [ "1.0" ]
498
+ ).and_return(true)
499
+ provider.run_action(:upgrade)
500
+ expect(new_resource).to be_updated_by_last_action
501
+ expect(new_resource.version).to eql(nil)
502
+ end
503
+
504
+ it "when user pases string to package_name and version, passes arrays to upgrade_package" do
505
+ new_resource.package_name "vim"
506
+ new_resource.version "1.0"
507
+ provider.candidate_version = [ "1.0" ]
508
+ expect(provider).to receive(:upgrade_package).with(
509
+ [ "vim" ],
510
+ [ "1.0" ]
511
+ ).and_return(true)
512
+ provider.run_action(:upgrade)
513
+ expect(new_resource).to be_updated_by_last_action
514
+ expect(new_resource.version).to eql("1.0")
515
+ end
516
+
517
+ it "when user passes string to package_name, passes arrays to remove_package" do
518
+ new_resource.package_name "vim"
519
+ current_resource.package_name "vim"
520
+ current_resource.version [ "1.0" ]
521
+ provider.candidate_version = [ "1.0" ]
522
+ expect(provider).to receive(:remove_package).with(
523
+ [ "vim" ],
524
+ [ nil ]
525
+ ).and_return(true)
526
+ provider.run_action(:remove)
527
+ expect(new_resource).to be_updated_by_last_action
528
+ expect(new_resource.version).to eql(nil)
529
+ end
530
+
531
+ it "when user passes string to package_name, passes arrays to purge_package" do
532
+ new_resource.package_name "vim"
533
+ current_resource.package_name "vim"
534
+ current_resource.version [ "1.0" ]
535
+ provider.candidate_version = [ "1.0" ]
536
+ expect(provider).to receive(:purge_package).with(
537
+ [ "vim" ],
538
+ [ nil ]
539
+ ).and_return(true)
540
+ provider.run_action(:purge)
541
+ expect(new_resource).to be_updated_by_last_action
542
+ expect(new_resource.version).to eql(nil)
543
+ end
544
+
545
+ it "when user passes string to package_name, passes arrays to reconfig_package" do
546
+ new_resource.package_name "vim"
547
+ current_resource.package_name "vim"
548
+ current_resource.version [ "1.0" ]
549
+ allow(new_resource).to receive(:response_file).and_return(true)
550
+ expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test')
551
+ allow(provider).to receive(:preseed_package).and_return(true)
552
+ allow(provider).to receive(:reconfig_package).and_return(true)
553
+ expect(provider).to receive(:reconfig_package).with(
554
+ [ "vim" ],
555
+ [ "1.0" ],
556
+ ).and_return(true)
557
+ provider.run_action(:reconfig)
558
+ expect(new_resource).to be_updated_by_last_action
559
+ end
560
+ end
561
+
435
562
  describe "Chef::Provider::Package - Multi" do
436
- before do
437
- @node = Chef::Node.new
438
- @events = Chef::EventDispatch::Dispatcher.new
439
- @run_context = Chef::RunContext.new(@node, {}, @events)
440
- @new_resource = Chef::Resource::Package.new(['emacs', 'vi'])
441
- @current_resource = Chef::Resource::Package.new(['emacs', 'vi'])
442
- @provider = Chef::Provider::Package.new(@new_resource, @run_context)
443
- @provider.current_resource = @current_resource
444
- @provider.candidate_version = ['1.0', '6.2']
563
+ let(:node) { Chef::Node.new }
564
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
565
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
566
+ let(:new_resource) { Chef::Resource::Package.new(['emacs', 'vi']) }
567
+ let(:current_resource) { Chef::Resource::Package.new(['emacs', 'vi']) }
568
+ let(:candidate_version) { [ "1.0", "6.2" ] }
569
+ let(:provider) do
570
+ provider = Chef::Provider::Package.new(new_resource, run_context)
571
+ provider.current_resource = current_resource
572
+ provider.candidate_version = candidate_version
573
+ provider
445
574
  end
446
575
 
447
576
  describe "when installing multiple packages" do
448
577
  before(:each) do
449
- @provider.current_resource = @current_resource
450
- allow(@provider).to receive(:install_package).and_return(true)
578
+ provider.current_resource = current_resource
579
+ allow(provider).to receive(:install_package).and_return(true)
451
580
  end
452
581
 
453
582
  it "installs the candidate versions when none are installed" do
454
- expect(@provider).to receive(:install_package).with(
583
+ expect(provider).to receive(:install_package).with(
455
584
  ["emacs", "vi"],
456
585
  ["1.0", "6.2"]
457
586
  ).and_return(true)
458
- @provider.run_action(:install)
459
- expect(@new_resource).to be_updated
587
+ provider.run_action(:install)
588
+ expect(new_resource).to be_updated
460
589
  end
461
590
 
462
591
  it "installs the candidate versions when some are installed" do
463
- expect(@provider).to receive(:install_package).with(
592
+ expect(provider).to receive(:install_package).with(
464
593
  [ 'vi' ],
465
594
  [ '6.2' ]
466
595
  ).and_return(true)
467
- @current_resource.version(['1.0', nil])
468
- @provider.run_action(:install)
469
- expect(@new_resource).to be_updated
596
+ current_resource.version(['1.0', nil])
597
+ provider.run_action(:install)
598
+ expect(new_resource).to be_updated
470
599
  end
471
600
 
472
601
  it "installs the specified version when some are out of date" do
473
- @current_resource.version(['1.0', '6.2'])
474
- @new_resource.version(['1.0', '6.1'])
475
- @provider.run_action(:install)
476
- expect(@new_resource).to be_updated
602
+ current_resource.version(['1.0', '6.2'])
603
+ new_resource.version(['1.0', '6.1'])
604
+ provider.run_action(:install)
605
+ expect(new_resource).to be_updated
477
606
  end
478
607
 
479
608
  it "does not install any version if all are installed at the right version" do
480
- @current_resource.version(['1.0', '6.2'])
481
- @new_resource.version(['1.0', '6.2'])
482
- @provider.run_action(:install)
483
- expect(@new_resource).not_to be_updated_by_last_action
609
+ current_resource.version(['1.0', '6.2'])
610
+ new_resource.version(['1.0', '6.2'])
611
+ provider.run_action(:install)
612
+ expect(new_resource).not_to be_updated_by_last_action
484
613
  end
485
614
 
486
615
  it "does not install any version if all are installed, and no version was specified" do
487
- @current_resource.version(['1.0', '6.2'])
488
- @provider.run_action(:install)
489
- expect(@new_resource).not_to be_updated_by_last_action
616
+ current_resource.version(['1.0', '6.2'])
617
+ provider.run_action(:install)
618
+ expect(new_resource).not_to be_updated_by_last_action
490
619
  end
491
620
 
492
621
  it "raises an exception if both are not installed and no caondidates are available" do
493
- @current_resource.version([nil, nil])
494
- @provider.candidate_version = [nil, nil]
495
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
622
+ current_resource.version([nil, nil])
623
+ provider.candidate_version = [nil, nil]
624
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
496
625
  end
497
626
 
498
627
  it "raises an exception if one is not installed and no candidates are available" do
499
- @current_resource.version(['1.0', nil])
500
- @provider.candidate_version = ['1.0', nil]
501
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
628
+ current_resource.version(['1.0', nil])
629
+ provider.candidate_version = ['1.0', nil]
630
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
502
631
  end
503
632
 
504
633
  it "does not raise an exception if the packages are installed or have a candidate" do
505
- @current_resource.version(['1.0', nil])
506
- @provider.candidate_version = [nil, '6.2']
507
- expect { @provider.run_action(:install) }.not_to raise_error
634
+ current_resource.version(['1.0', nil])
635
+ provider.candidate_version = [nil, '6.2']
636
+ expect { provider.run_action(:install) }.not_to raise_error
508
637
  end
509
638
 
510
639
  it "raises an exception if an explicit version is asked for, an old version is installed, but no candidate" do
511
- @new_resource.version ['1.0', '6.2']
512
- @current_resource.version(['1.0', '6.1'])
513
- @provider.candidate_version = ['1.0', nil]
514
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
640
+ new_resource.version ['1.0', '6.2']
641
+ current_resource.version(['1.0', '6.1'])
642
+ provider.candidate_version = ['1.0', nil]
643
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
515
644
  end
516
645
 
517
646
  it "does not raise an exception if an explicit version is asked for, and is installed, but no candidate" do
518
- @new_resource.version ['1.0', '6.2']
519
- @current_resource.version(['1.0', '6.2'])
520
- @provider.candidate_version = ['1.0', nil]
521
- expect { @provider.run_action(:install) }.not_to raise_error
647
+ new_resource.version ['1.0', '6.2']
648
+ current_resource.version(['1.0', '6.2'])
649
+ provider.candidate_version = ['1.0', nil]
650
+ expect { provider.run_action(:install) }.not_to raise_error
522
651
  end
523
652
 
524
653
  it "raise an exception if an explicit version is asked for, and is not installed, and no candidate" do
525
- @new_resource.version ['1.0', '6.2']
526
- @current_resource.version(['1.0', nil])
527
- @provider.candidate_version = ['1.0', nil]
528
- expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
654
+ new_resource.version ['1.0', '6.2']
655
+ current_resource.version(['1.0', nil])
656
+ provider.candidate_version = ['1.0', nil]
657
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
529
658
  end
530
659
 
531
660
  it "does not raise an exception if an explicit version is asked for, and is not installed, and there is a candidate" do
532
- @new_resource.version ['1.0', '6.2']
533
- @current_resource.version(['1.0', nil])
534
- @provider.candidate_version = ['1.0', '6.2']
535
- expect { @provider.run_action(:install) }.not_to raise_error
661
+ new_resource.version ['1.0', '6.2']
662
+ current_resource.version(['1.0', nil])
663
+ provider.candidate_version = ['1.0', '6.2']
664
+ expect { provider.run_action(:install) }.not_to raise_error
536
665
  end
537
666
  end
538
667
 
539
668
  describe "when upgrading multiple packages" do
540
669
  before(:each) do
541
- @provider.current_resource = @current_resource
542
- allow(@provider).to receive(:upgrade_package).and_return(true)
670
+ provider.current_resource = current_resource
671
+ allow(provider).to receive(:upgrade_package).and_return(true)
543
672
  end
544
673
 
545
674
  it "should upgrade the package if the current versions are not the candidate version" do
546
- @current_resource.version ['0.9', '6.1']
547
- expect(@provider).to receive(:upgrade_package).with(
548
- @new_resource.package_name,
549
- @provider.candidate_version
675
+ current_resource.version ['0.9', '6.1']
676
+ expect(provider).to receive(:upgrade_package).with(
677
+ new_resource.package_name,
678
+ provider.candidate_version
550
679
  ).and_return(true)
551
- @provider.run_action(:upgrade)
552
- expect(@new_resource).to be_updated_by_last_action
680
+ provider.run_action(:upgrade)
681
+ expect(new_resource).to be_updated_by_last_action
553
682
  end
554
683
 
555
684
  it "should upgrade the package if some of current versions are not the candidate versions" do
556
- @current_resource.version ['1.0', '6.1']
557
- expect(@provider).to receive(:upgrade_package).with(
685
+ current_resource.version ['1.0', '6.1']
686
+ expect(provider).to receive(:upgrade_package).with(
558
687
  ["vi"],
559
688
  ["6.2"]
560
689
  ).and_return(true)
561
- @provider.run_action(:upgrade)
562
- expect(@new_resource).to be_updated_by_last_action
690
+ provider.run_action(:upgrade)
691
+ expect(new_resource).to be_updated_by_last_action
563
692
  end
564
693
 
565
694
  it "should not install the package if the current versions are the candidate version" do
566
- @current_resource.version ['1.0', '6.2']
567
- expect(@provider).not_to receive(:upgrade_package)
568
- @provider.run_action(:upgrade)
569
- expect(@new_resource).not_to be_updated_by_last_action
695
+ current_resource.version ['1.0', '6.2']
696
+ expect(provider).not_to receive(:upgrade_package)
697
+ provider.run_action(:upgrade)
698
+ expect(new_resource).not_to be_updated_by_last_action
570
699
  end
571
700
 
572
701
  it "should raise an exception if both are not installed and no caondidates are available" do
573
- @current_resource.version([nil, nil])
574
- @provider.candidate_version = [nil, nil]
575
- expect { @provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
702
+ current_resource.version([nil, nil])
703
+ provider.candidate_version = [nil, nil]
704
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
576
705
  end
577
706
 
578
707
  it "should raise an exception if one is not installed and no candidates are available" do
579
- @current_resource.version(['1.0', nil])
580
- @provider.candidate_version = ['1.0', nil]
581
- expect { @provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
708
+ current_resource.version(['1.0', nil])
709
+ provider.candidate_version = ['1.0', nil]
710
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
582
711
  end
583
712
 
584
713
  it "should not raise an exception if the packages are installed or have a candidate" do
585
- @current_resource.version(['1.0', nil])
586
- @provider.candidate_version = [nil, '6.2']
587
- expect { @provider.run_action(:upgrade) }.not_to raise_error
714
+ current_resource.version(['1.0', nil])
715
+ provider.candidate_version = [nil, '6.2']
716
+ expect { provider.run_action(:upgrade) }.not_to raise_error
588
717
  end
589
718
 
590
719
  it "should not raise an exception if the packages are installed or have a candidate" do
591
- @current_resource.version(['1.0', nil])
592
- @provider.candidate_version = [nil, '6.2']
593
- expect { @provider.run_action(:upgrade) }.not_to raise_error
720
+ current_resource.version(['1.0', nil])
721
+ provider.candidate_version = [nil, '6.2']
722
+ expect { provider.run_action(:upgrade) }.not_to raise_error
594
723
  end
595
724
  end
596
725
 
597
726
  describe "When removing multiple packages " do
598
727
  before(:each) do
599
- allow(@provider).to receive(:remove_package).and_return(true)
600
- @current_resource.version ['1.0', '6.2']
728
+ allow(provider).to receive(:remove_package).and_return(true)
729
+ current_resource.version ['1.0', '6.2']
601
730
  end
602
731
 
603
732
  it "should remove the packages if all are installed" do
604
- expect(@provider).to be_removing_package
605
- expect(@provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
606
- @provider.run_action(:remove)
607
- expect(@new_resource).to be_updated
608
- expect(@new_resource).to be_updated_by_last_action
733
+ expect(provider).to be_removing_package
734
+ expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
735
+ provider.run_action(:remove)
736
+ expect(new_resource).to be_updated
737
+ expect(new_resource).to be_updated_by_last_action
609
738
  end
610
739
 
611
740
  it "should remove the packages if some are installed" do
612
- @current_resource.version ['1.0', nil]
613
- expect(@provider).to be_removing_package
614
- expect(@provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
615
- @provider.run_action(:remove)
616
- expect(@new_resource).to be_updated
617
- expect(@new_resource).to be_updated_by_last_action
741
+ current_resource.version ['1.0', nil]
742
+ expect(provider).to be_removing_package
743
+ expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
744
+ provider.run_action(:remove)
745
+ expect(new_resource).to be_updated
746
+ expect(new_resource).to be_updated_by_last_action
618
747
  end
619
748
 
620
749
  it "should remove the packages at a specific version if they are installed at that version" do
621
- @new_resource.version ['1.0', '6.2']
622
- expect(@provider).to be_removing_package
623
- expect(@provider).to receive(:remove_package).with(['emacs', 'vi'], ['1.0', '6.2'])
624
- @provider.run_action(:remove)
625
- expect(@new_resource).to be_updated_by_last_action
750
+ new_resource.version ['1.0', '6.2']
751
+ expect(provider).to be_removing_package
752
+ expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['1.0', '6.2'])
753
+ provider.run_action(:remove)
754
+ expect(new_resource).to be_updated_by_last_action
626
755
  end
627
756
 
628
757
  it "should remove the packages at a specific version any are is installed at that version" do
629
- @new_resource.version ['0.5', '6.2']
630
- expect(@provider).to be_removing_package
631
- expect(@provider).to receive(:remove_package).with(['emacs', 'vi'], ['0.5', '6.2'])
632
- @provider.run_action(:remove)
633
- expect(@new_resource).to be_updated_by_last_action
758
+ new_resource.version ['0.5', '6.2']
759
+ expect(provider).to be_removing_package
760
+ expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['0.5', '6.2'])
761
+ provider.run_action(:remove)
762
+ expect(new_resource).to be_updated_by_last_action
634
763
  end
635
764
 
636
765
  it "should not remove the packages at a specific version if they are not installed at that version" do
637
- @new_resource.version ['0.5', '6.0']
638
- expect(@provider).not_to be_removing_package
639
- expect(@provider).not_to receive(:remove_package)
640
- @provider.run_action(:remove)
641
- expect(@new_resource).not_to be_updated_by_last_action
766
+ new_resource.version ['0.5', '6.0']
767
+ expect(provider).not_to be_removing_package
768
+ expect(provider).not_to receive(:remove_package)
769
+ provider.run_action(:remove)
770
+ expect(new_resource).not_to be_updated_by_last_action
642
771
  end
643
772
 
644
773
  it "should not remove the packages if they are not installed" do
645
- expect(@provider).not_to receive(:remove_package)
646
- allow(@current_resource).to receive(:version).and_return(nil)
647
- @provider.run_action(:remove)
648
- expect(@new_resource).not_to be_updated_by_last_action
774
+ expect(provider).not_to receive(:remove_package)
775
+ allow(current_resource).to receive(:version).and_return(nil)
776
+ provider.run_action(:remove)
777
+ expect(new_resource).not_to be_updated_by_last_action
649
778
  end
650
779
 
651
780
  end
652
781
 
653
782
  describe "When purging multiple packages " do
654
783
  before(:each) do
655
- allow(@provider).to receive(:purge_package).and_return(true)
656
- @current_resource.version ['1.0', '6.2']
784
+ allow(provider).to receive(:purge_package).and_return(true)
785
+ current_resource.version ['1.0', '6.2']
657
786
  end
658
787
 
659
788
  it "should purge the packages if all are installed" do
660
- expect(@provider).to be_removing_package
661
- expect(@provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
662
- @provider.run_action(:purge)
663
- expect(@new_resource).to be_updated
664
- expect(@new_resource).to be_updated_by_last_action
789
+ expect(provider).to be_removing_package
790
+ expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
791
+ provider.run_action(:purge)
792
+ expect(new_resource).to be_updated
793
+ expect(new_resource).to be_updated_by_last_action
665
794
  end
666
795
 
667
796
  it "should purge the packages if some are installed" do
668
- @current_resource.version ['1.0', nil]
669
- expect(@provider).to be_removing_package
670
- expect(@provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
671
- @provider.run_action(:purge)
672
- expect(@new_resource).to be_updated
673
- expect(@new_resource).to be_updated_by_last_action
797
+ current_resource.version ['1.0', nil]
798
+ expect(provider).to be_removing_package
799
+ expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
800
+ provider.run_action(:purge)
801
+ expect(new_resource).to be_updated
802
+ expect(new_resource).to be_updated_by_last_action
674
803
  end
675
804
 
676
805
  it "should purge the packages at a specific version if they are installed at that version" do
677
- @new_resource.version ['1.0', '6.2']
678
- expect(@provider).to be_removing_package
679
- expect(@provider).to receive(:purge_package).with(['emacs', 'vi'], ['1.0', '6.2'])
680
- @provider.run_action(:purge)
681
- expect(@new_resource).to be_updated_by_last_action
806
+ new_resource.version ['1.0', '6.2']
807
+ expect(provider).to be_removing_package
808
+ expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['1.0', '6.2'])
809
+ provider.run_action(:purge)
810
+ expect(new_resource).to be_updated_by_last_action
682
811
  end
683
812
 
684
813
  it "should purge the packages at a specific version any are is installed at that version" do
685
- @new_resource.version ['0.5', '6.2']
686
- expect(@provider).to be_removing_package
687
- expect(@provider).to receive(:purge_package).with(['emacs', 'vi'], ['0.5', '6.2'])
688
- @provider.run_action(:purge)
689
- expect(@new_resource).to be_updated_by_last_action
814
+ new_resource.version ['0.5', '6.2']
815
+ expect(provider).to be_removing_package
816
+ expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['0.5', '6.2'])
817
+ provider.run_action(:purge)
818
+ expect(new_resource).to be_updated_by_last_action
690
819
  end
691
820
 
692
821
  it "should not purge the packages at a specific version if they are not installed at that version" do
693
- @new_resource.version ['0.5', '6.0']
694
- expect(@provider).not_to be_removing_package
695
- expect(@provider).not_to receive(:purge_package)
696
- @provider.run_action(:purge)
697
- expect(@new_resource).not_to be_updated_by_last_action
822
+ new_resource.version ['0.5', '6.0']
823
+ expect(provider).not_to be_removing_package
824
+ expect(provider).not_to receive(:purge_package)
825
+ provider.run_action(:purge)
826
+ expect(new_resource).not_to be_updated_by_last_action
698
827
  end
699
828
 
700
829
  it "should not purge the packages if they are not installed" do
701
- expect(@provider).not_to receive(:purge_package)
702
- allow(@current_resource).to receive(:version).and_return(nil)
703
- @provider.run_action(:purge)
704
- expect(@new_resource).not_to be_updated_by_last_action
830
+ expect(provider).not_to receive(:purge_package)
831
+ allow(current_resource).to receive(:version).and_return(nil)
832
+ provider.run_action(:purge)
833
+ expect(new_resource).not_to be_updated_by_last_action
705
834
  end
706
835
  end
707
836
 
@@ -710,30 +839,30 @@ describe "Chef::Provider::Package - Multi" do
710
839
  stubbed_method = method == :shell_out_with_timeout! ? :shell_out! : :shell_out
711
840
  [ %w{command arg1 arg2}, "command arg1 arg2" ].each do |command|
712
841
  it "#{method} defaults to 900 seconds" do
713
- expect(@provider).to receive(stubbed_method).with(*command, timeout: 900)
714
- @provider.send(method, *command)
842
+ expect(provider).to receive(stubbed_method).with(*command, timeout: 900)
843
+ provider.send(method, *command)
715
844
  end
716
845
  it "#{method} overrides the default timeout with its options" do
717
- expect(@provider).to receive(stubbed_method).with(*command, timeout: 1)
718
- @provider.send(method, *command, timeout: 1)
846
+ expect(provider).to receive(stubbed_method).with(*command, timeout: 1)
847
+ provider.send(method, *command, timeout: 1)
719
848
  end
720
849
  it "#{method} overrides both timeouts with the new_resource.timeout" do
721
- @new_resource.timeout(99)
722
- expect(@provider).to receive(stubbed_method).with(*command, timeout: 99)
723
- @provider.send(method, *command, timeout: 1)
850
+ new_resource.timeout(99)
851
+ expect(provider).to receive(stubbed_method).with(*command, timeout: 99)
852
+ provider.send(method, *command, timeout: 1)
724
853
  end
725
854
  it "#{method} defaults to 900 seconds and preserves options" do
726
- expect(@provider).to receive(stubbed_method).with(*command, env: nil, timeout: 900)
727
- @provider.send(method, *command, env: nil)
855
+ expect(provider).to receive(stubbed_method).with(*command, env: nil, timeout: 900)
856
+ provider.send(method, *command, env: nil)
728
857
  end
729
858
  it "#{method} overrides the default timeout with its options and preserves options" do
730
- expect(@provider).to receive(stubbed_method).with(*command, timeout: 1, env: nil)
731
- @provider.send(method, *command, timeout: 1, env: nil)
859
+ expect(provider).to receive(stubbed_method).with(*command, timeout: 1, env: nil)
860
+ provider.send(method, *command, timeout: 1, env: nil)
732
861
  end
733
862
  it "#{method} overrides both timeouts with the new_resource.timeout and preseves options" do
734
- @new_resource.timeout(99)
735
- expect(@provider).to receive(stubbed_method).with(*command, timeout: 99, env: nil)
736
- @provider.send(method, *command, timeout: 1, env: nil)
863
+ new_resource.timeout(99)
864
+ expect(provider).to receive(stubbed_method).with(*command, timeout: 99, env: nil)
865
+ provider.send(method, *command, timeout: 1, env: nil)
737
866
  end
738
867
  end
739
868
  end