microwave 1.0.4 → 11.400.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/CONTRIBUTING.md +155 -0
  2. data/README.md +89 -0
  3. data/Rakefile +2 -2
  4. data/bin/chef-apply +25 -0
  5. data/bin/chef-shell +34 -0
  6. data/bin/chef-solo +0 -2
  7. data/bin/shef +6 -5
  8. data/lib/chef.rb +2 -4
  9. data/spec/data/big_json.json +2 -1
  10. data/spec/data/big_json_plus_one.json +2 -1
  11. data/spec/data/cookbooks/chefignore +2 -0
  12. data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
  13. data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
  14. data/spec/data/git_bundles/sinatra-test-app-with-callback-files.gitbundle +0 -0
  15. data/spec/data/git_bundles/sinatra-test-app-with-symlinks.gitbundle +0 -0
  16. data/spec/data/git_bundles/sinatra-test-app.gitbundle +0 -0
  17. data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
  18. data/spec/data/nodes/default.rb +3 -3
  19. data/spec/data/nodes/test.example.com.rb +3 -3
  20. data/spec/data/nodes/test.rb +3 -3
  21. data/spec/data/partial_one.erb +1 -0
  22. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
  23. data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
  24. data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
  25. data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
  26. data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
  27. data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
  28. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  29. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
  30. data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
  31. data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
  32. data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
  33. data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
  34. data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
  35. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  36. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
  37. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
  38. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
  39. data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
  40. data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
  41. data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
  42. data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
  43. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  44. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
  45. data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
  46. data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
  47. data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
  48. data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
  49. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  50. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
  51. data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
  52. data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
  53. data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
  54. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  55. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
  56. data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
  57. data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
  58. data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
  59. data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
  60. data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
  61. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
  62. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
  63. data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
  64. data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
  65. data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
  66. data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
  67. data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
  68. data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
  69. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  70. data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
  71. data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
  72. data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
  73. data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
  74. data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
  75. data/spec/data/shef-config.rb +10 -0
  76. data/spec/functional/dsl/registry_helper_spec.rb +63 -0
  77. data/spec/functional/knife/cookbook_delete_spec.rb +0 -2
  78. data/spec/functional/knife/exec_spec.rb +4 -6
  79. data/spec/functional/knife/smoke_test.rb +34 -0
  80. data/spec/functional/knife/ssh_spec.rb +64 -3
  81. data/spec/functional/resource/cookbook_file_spec.rb +33 -2
  82. data/spec/functional/resource/deploy_revision_spec.rb +515 -0
  83. data/spec/functional/resource/directory_spec.rb +4 -0
  84. data/spec/functional/resource/file_spec.rb +56 -22
  85. data/spec/functional/resource/link_spec.rb +12 -10
  86. data/spec/functional/resource/registry_spec.rb +572 -0
  87. data/spec/functional/resource/remote_directory_spec.rb +142 -36
  88. data/spec/functional/resource/remote_file_spec.rb +28 -3
  89. data/spec/functional/resource/template_spec.rb +23 -2
  90. data/spec/functional/run_lock_spec.rb +238 -0
  91. data/spec/functional/shell_spec.rb +101 -0
  92. data/spec/functional/tiny_server_spec.rb +5 -4
  93. data/spec/functional/win32/registry_helper_spec.rb +632 -0
  94. data/spec/functional/win32/security_spec.rb +37 -0
  95. data/spec/spec_helper.rb +15 -3
  96. data/spec/stress/win32/security_spec.rb +5 -5
  97. data/spec/support/chef_helpers.rb +14 -3
  98. data/spec/support/lib/chef/resource/cat.rb +3 -5
  99. data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
  100. data/spec/support/lib/chef/resource/zen_master.rb +8 -10
  101. data/spec/support/matchers/leak.rb +1 -1
  102. data/spec/support/platform_helpers.rb +18 -0
  103. data/spec/support/shared/functional/directory_resource.rb +85 -23
  104. data/spec/support/shared/functional/file_resource.rb +198 -53
  105. data/spec/support/shared/functional/securable_resource.rb +140 -105
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
  107. data/spec/support/shared/unit/file_system_support.rb +110 -0
  108. data/spec/support/shared/unit/platform_introspector.rb +162 -0
  109. data/spec/tiny_server.rb +29 -10
  110. data/spec/unit/api_client/registration_spec.rb +172 -0
  111. data/spec/unit/api_client_spec.rb +156 -103
  112. data/spec/unit/application/apply.rb +84 -0
  113. data/spec/unit/application/knife_spec.rb +5 -0
  114. data/spec/unit/application_spec.rb +57 -2
  115. data/spec/unit/chef_fs/diff_spec.rb +329 -0
  116. data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
  117. data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
  118. data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
  119. data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
  120. data/spec/unit/chef_fs/file_system_spec.rb +136 -0
  121. data/spec/unit/client_spec.rb +188 -16
  122. data/spec/unit/config_spec.rb +54 -4
  123. data/spec/unit/cookbook/chefignore_spec.rb +2 -1
  124. data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
  125. data/spec/unit/cookbook_loader_spec.rb +153 -91
  126. data/spec/unit/cookbook_manifest_spec.rb +81 -81
  127. data/spec/unit/cookbook_spec.rb +3 -20
  128. data/spec/unit/cookbook_version_spec.rb +23 -122
  129. data/spec/unit/digester_spec.rb +50 -0
  130. data/spec/unit/dsl/data_query_spec.rb +66 -0
  131. data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
  132. data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
  133. data/spec/unit/encrypted_data_bag_item_spec.rb +126 -10
  134. data/spec/unit/environment_spec.rb +0 -130
  135. data/spec/unit/exceptions_spec.rb +2 -3
  136. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +23 -3
  137. data/spec/unit/json_compat_spec.rb +69 -0
  138. data/spec/unit/knife/bootstrap_spec.rb +81 -28
  139. data/spec/unit/knife/client_reregister_spec.rb +23 -22
  140. data/spec/unit/knife/configure_spec.rb +29 -26
  141. data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
  142. data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
  143. data/spec/unit/knife/cookbook_test_spec.rb +1 -0
  144. data/spec/unit/knife/cookbook_upload_spec.rb +41 -2
  145. data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -1
  146. data/spec/unit/knife/core/ui_spec.rb +156 -7
  147. data/spec/unit/knife/data_bag_create_spec.rb +14 -0
  148. data/spec/unit/knife/data_bag_edit_spec.rb +14 -4
  149. data/spec/unit/knife/data_bag_from_file_spec.rb +17 -5
  150. data/spec/unit/knife/data_bag_show_spec.rb +11 -4
  151. data/spec/unit/knife/index_rebuild_spec.rb +96 -33
  152. data/spec/unit/knife/knife_help.rb +7 -7
  153. data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
  154. data/spec/unit/knife/ssh_spec.rb +121 -15
  155. data/spec/unit/knife/status_spec.rb +2 -2
  156. data/spec/unit/knife/user_create_spec.rb +86 -0
  157. data/spec/unit/knife/user_delete_spec.rb +39 -0
  158. data/spec/unit/knife/user_edit_spec.rb +42 -0
  159. data/spec/unit/knife/user_list_spec.rb +32 -0
  160. data/spec/unit/knife/user_reregister_spec.rb +53 -0
  161. data/spec/unit/knife/user_show_spec.rb +41 -0
  162. data/spec/unit/knife_spec.rb +53 -0
  163. data/spec/unit/lwrp_spec.rb +59 -17
  164. data/spec/unit/mixin/checksum_spec.rb +2 -2
  165. data/spec/unit/mixin/deep_merge_spec.rb +56 -491
  166. data/spec/unit/mixin/deprecation_spec.rb +23 -0
  167. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
  168. data/spec/unit/mixin/params_validate_spec.rb +4 -2
  169. data/spec/unit/mixin/securable_spec.rb +5 -3
  170. data/spec/unit/mixin/template_spec.rb +119 -0
  171. data/spec/unit/node/attribute_spec.rb +272 -137
  172. data/spec/unit/node/immutable_collections_spec.rb +139 -0
  173. data/spec/unit/node_spec.rb +411 -339
  174. data/spec/unit/platform_spec.rb +8 -8
  175. data/spec/unit/provider/breakpoint_spec.rb +8 -8
  176. data/spec/unit/provider/cookbook_file_spec.rb +4 -8
  177. data/spec/unit/provider/deploy/revision_spec.rb +2 -8
  178. data/spec/unit/provider/deploy_spec.rb +6 -40
  179. data/spec/unit/provider/directory_spec.rb +103 -68
  180. data/spec/unit/provider/erl_call_spec.rb +0 -2
  181. data/spec/unit/provider/file_spec.rb +69 -59
  182. data/spec/unit/provider/git_spec.rb +0 -10
  183. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  184. data/spec/unit/provider/group/usermod_spec.rb +2 -2
  185. data/spec/unit/provider/http_request_spec.rb +28 -69
  186. data/spec/unit/provider/ifconfig_spec.rb +2 -2
  187. data/spec/unit/provider/link_spec.rb +1 -1
  188. data/spec/unit/provider/ohai_spec.rb +4 -4
  189. data/spec/unit/provider/package/apt_spec.rb +0 -1
  190. data/spec/unit/provider/package/ips_spec.rb +0 -1
  191. data/spec/unit/provider/package/rubygems_spec.rb +0 -18
  192. data/spec/unit/provider/package/yum_spec.rb +79 -15
  193. data/spec/unit/provider/package_spec.rb +7 -5
  194. data/spec/unit/provider/registry_key_spec.rb +269 -0
  195. data/spec/unit/provider/remote_directory_spec.rb +24 -7
  196. data/spec/unit/provider/remote_file_spec.rb +36 -0
  197. data/spec/unit/provider/route_spec.rb +3 -6
  198. data/spec/unit/provider/ruby_block_spec.rb +8 -0
  199. data/spec/unit/provider/service/arch_service_spec.rb +4 -4
  200. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  201. data/spec/unit/provider/service/freebsd_service_spec.rb +4 -4
  202. data/spec/unit/provider/service/init_service_spec.rb +26 -3
  203. data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
  204. data/spec/unit/provider/service/invokercd_service_spec.rb +3 -3
  205. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  206. data/spec/unit/provider/service/simple_service_spec.rb +3 -3
  207. data/spec/unit/provider/service/upstart_service_spec.rb +7 -7
  208. data/spec/unit/provider/service_spec.rb +2 -2
  209. data/spec/unit/provider/subversion_spec.rb +1 -1
  210. data/spec/unit/provider/template_spec.rb +35 -11
  211. data/spec/unit/provider/user/dscl_spec.rb +57 -31
  212. data/spec/unit/provider/user_spec.rb +7 -16
  213. data/spec/unit/provider_spec.rb +4 -3
  214. data/spec/unit/recipe_spec.rb +10 -8
  215. data/spec/unit/registry_helper_spec.rb +376 -0
  216. data/spec/unit/resource/log_spec.rb +9 -0
  217. data/spec/unit/resource/registry_key_spec.rb +171 -0
  218. data/spec/unit/resource/remote_file_spec.rb +21 -23
  219. data/spec/unit/resource/ruby_block_spec.rb +7 -3
  220. data/spec/unit/resource/service_spec.rb +11 -0
  221. data/spec/unit/resource_spec.rb +27 -4
  222. data/spec/unit/rest/auth_credentials_spec.rb +2 -14
  223. data/spec/unit/rest_spec.rb +122 -187
  224. data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
  225. data/spec/unit/run_context_spec.rb +18 -4
  226. data/spec/unit/run_list_spec.rb +0 -209
  227. data/spec/unit/run_lock_spec.rb +37 -0
  228. data/spec/unit/runner_spec.rb +101 -2
  229. data/spec/unit/scan_access_control_spec.rb +4 -4
  230. data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
  231. data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
  232. data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +12 -12
  233. data/spec/unit/shell_out_spec.rb +18 -0
  234. data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
  235. data/spec/unit/user_spec.rb +255 -0
  236. metadata +162 -157
  237. data/README.rdoc +0 -177
  238. data/spec/unit/certificate_spec.rb +0 -76
  239. data/spec/unit/checksum_cache_spec.rb +0 -209
  240. data/spec/unit/checksum_spec.rb +0 -94
  241. data/spec/unit/couchdb_spec.rb +0 -274
  242. data/spec/unit/index_queue_spec.rb +0 -391
  243. data/spec/unit/json_compat_spect.rb +0 -53
  244. data/spec/unit/mixin/language_spec.rb +0 -305
  245. data/spec/unit/openid_registration_spec.rb +0 -153
  246. data/spec/unit/solr_query/query_transform_spec.rb +0 -454
  247. data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
  248. data/spec/unit/solr_query_spec.rb +0 -203
  249. data/spec/unit/webui_user_spec.rb +0 -238
@@ -183,7 +183,7 @@ describe Chef::Provider::Ifconfig do
183
183
 
184
184
  it "should write network-script for centos" do
185
185
  @provider.stub!(:load_current_resource)
186
- @node[:platform] = "centos"
186
+ @node.automatic_attrs[:platform] = "centos"
187
187
  @provider.stub!(:run_command)
188
188
  config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
189
189
  config_file = StringIO.new
@@ -199,7 +199,7 @@ describe Chef::Provider::Ifconfig do
199
199
  describe Chef::Provider::Ifconfig, "delete_config for action_delete" do
200
200
 
201
201
  it "should delete network-script if it exists for centos" do
202
- @node[:platform] = "centos"
202
+ @node.automatic_attrs[:platform] = "centos"
203
203
  @current_resource.device "eth0"
204
204
  @provider.stub!(:load_current_resource)
205
205
  @provider.stub!(:run_command)
@@ -25,7 +25,7 @@ if Chef::Platform.windows?
25
25
  require 'chef/win32/file' #probably need this in spec_helper
26
26
  end
27
27
 
28
- describe Chef::Resource::Link do
28
+ describe Chef::Resource::Link, :not_supported_on_win2k3 do
29
29
  let(:provider) do
30
30
  node = Chef::Node.new
31
31
  @events = Chef::EventDispatch::Dispatcher.new
@@ -34,7 +34,7 @@ describe Chef::Provider::Ohai do
34
34
  :platform => @platform,
35
35
  :platform_version => @platform_version,
36
36
  :data => {
37
- :origdata => "somevalue"
37
+ :origdata => "somevalue"
38
38
  },
39
39
  :data2 => {
40
40
  :origdata => "somevalue",
@@ -49,7 +49,7 @@ describe Chef::Provider::Ohai do
49
49
  Chef::Platform.stub!(:find_platform_and_version).and_return({ "platform" => @platform,
50
50
  "platform_version" => @platform_version})
51
51
  # Fake node with a dummy save
52
- @node = Chef::Node.new(@hostname)
52
+ @node = Chef::Node.new
53
53
  @node.name(@fqdn)
54
54
  @node.stub!(:save).and_return(@node)
55
55
  @events = Chef::EventDispatch::Dispatcher.new
@@ -57,14 +57,14 @@ describe Chef::Provider::Ohai do
57
57
  @new_resource = Chef::Resource::Ohai.new("ohai_reload")
58
58
  ohai = Ohai::System.new
59
59
  ohai.all_plugins
60
- @node.process_external_attrs(ohai.data,{})
60
+ @node.consume_external_attrs(ohai.data,{})
61
61
 
62
62
  @provider = Chef::Provider::Ohai.new(@new_resource, @run_context)
63
63
  end
64
64
 
65
65
  describe "when reloading ohai" do
66
66
  before do
67
- @node[:origdata] = 'somevalue'
67
+ @node.automatic_attrs[:origdata] = 'somevalue'
68
68
  end
69
69
 
70
70
  it "applies updated ohai data to the node" do
@@ -22,7 +22,6 @@ require 'ostruct'
22
22
  describe Chef::Provider::Package::Apt do
23
23
  before(:each) do
24
24
  @node = Chef::Node.new
25
- @node.cookbook_collection = {}
26
25
  @events = Chef::EventDispatch::Dispatcher.new
27
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
28
27
  @new_resource = Chef::Resource::Package.new("irssi", @run_context)
@@ -24,7 +24,6 @@ require 'ostruct'
24
24
  describe Chef::Provider::Package::Ips do
25
25
  before(:each) do
26
26
  @node = Chef::Node.new
27
- @node.cookbook_collection = {}
28
27
  @events = Chef::EventDispatch::Dispatcher.new
29
28
  @run_context = Chef::RunContext.new(@node, {}, @events)
30
29
  @new_resource = Chef::Resource::Package.new("crypto/gnupg", @run_context)
@@ -439,7 +439,6 @@ describe Chef::Provider::Package::Rubygems do
439
439
  it "installs the gem via the gems api when no explicit options are used" do
440
440
  @provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
441
441
  @provider.action_install.should be_true
442
- @provider.converge
443
442
  end
444
443
 
445
444
  it "installs the gem via the gems api when a remote source is provided" do
@@ -447,14 +446,12 @@ describe Chef::Provider::Package::Rubygems do
447
446
  sources = ['http://gems.example.org']
448
447
  @provider.gem_env.should_receive(:install).with(@gem_dep, :sources => sources)
449
448
  @provider.action_install.should be_true
450
- @provider.converge
451
449
  end
452
450
 
453
451
  it "installs the gem from file via the gems api when no explicit options are used" do
454
452
  @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
455
453
  @provider.gem_env.should_receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
456
454
  @provider.action_install.should be_true
457
- @provider.converge
458
455
  end
459
456
 
460
457
  it "installs the gem from file via the gems api when the package is a path and the source is nil" do
@@ -464,7 +461,6 @@ describe Chef::Provider::Package::Rubygems do
464
461
  @new_resource.source.should == CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem'
465
462
  @provider.gem_env.should_receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
466
463
  @provider.action_install.should be_true
467
- @provider.converge
468
464
  end
469
465
 
470
466
  # this catches 'gem_package "foo"' when "./foo" is a file in the cwd, and instead of installing './foo' it fetches the remote gem
@@ -473,7 +469,6 @@ describe Chef::Provider::Package::Rubygems do
473
469
  @new_resource.package_name('rspec-core')
474
470
  @provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
475
471
  @provider.action_install.should be_true
476
- @provider.converge
477
472
  end
478
473
 
479
474
  it "installs the gem by shelling out when options are provided as a String" do
@@ -481,14 +476,12 @@ describe Chef::Provider::Package::Rubygems do
481
476
  expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" -i /alt/install/location"
482
477
  @provider.should_receive(:shell_out!).with(expected, :env => nil)
483
478
  @provider.action_install.should be_true
484
- @provider.converge
485
479
  end
486
480
 
487
481
  it "installs the gem via the gems api when options are given as a Hash" do
488
482
  @new_resource.options(:install_dir => '/alt/install/location')
489
483
  @provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location')
490
484
  @provider.action_install.should be_true
491
- @provider.converge
492
485
  end
493
486
 
494
487
  describe "at a specific version" do
@@ -499,7 +492,6 @@ describe Chef::Provider::Package::Rubygems do
499
492
  it "installs the gem via the gems api" do
500
493
  @provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
501
494
  @provider.action_install.should be_true
502
- @provider.converge
503
495
  end
504
496
  end
505
497
  describe "at version specified with comparison operator" do
@@ -509,7 +501,6 @@ describe Chef::Provider::Package::Rubygems do
509
501
 
510
502
  @provider.gem_env.should_not_receive(:install)
511
503
  @provider.action_install
512
- @provider.converge
513
504
  end
514
505
 
515
506
  it "allows user to specify gem version with fuzzy operator" do
@@ -518,7 +509,6 @@ describe Chef::Provider::Package::Rubygems do
518
509
 
519
510
  @provider.gem_env.should_not_receive(:install)
520
511
  @provider.action_install
521
- @provider.converge
522
512
  end
523
513
  end
524
514
  end
@@ -528,7 +518,6 @@ describe Chef::Provider::Package::Rubygems do
528
518
  @new_resource.gem_binary('/usr/weird/bin/gem')
529
519
  @provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\"", :env=>nil)
530
520
  @provider.action_install.should be_true
531
- @provider.converge
532
521
  end
533
522
 
534
523
  it "installs the gem from file by shelling out to gem install" do
@@ -537,7 +526,6 @@ describe Chef::Provider::Package::Rubygems do
537
526
  @new_resource.version('>= 0')
538
527
  @provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", :env=>nil)
539
528
  @provider.action_install.should be_true
540
- @provider.converge
541
529
  end
542
530
 
543
531
  it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
@@ -549,7 +537,6 @@ describe Chef::Provider::Package::Rubygems do
549
537
  @new_resource.source.should == CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem'
550
538
  @provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", :env=>nil)
551
539
  @provider.action_install.should be_true
552
- @provider.converge
553
540
  end
554
541
  end
555
542
 
@@ -572,7 +559,6 @@ describe Chef::Provider::Package::Rubygems do
572
559
  # the behavior we're testing:
573
560
  @provider.gem_env.should_receive(:uninstall).with('rspec', nil)
574
561
  @provider.action_remove
575
- @provider.converge
576
562
  end
577
563
 
578
564
  it "uninstalls via the api when options are given as a Hash" do
@@ -583,21 +569,18 @@ describe Chef::Provider::Package::Rubygems do
583
569
  @new_resource.options(:install_dir => '/alt/install/location')
584
570
  @provider.gem_env.should_receive(:uninstall).with('rspec', nil, :install_dir => '/alt/install/location')
585
571
  @provider.action_remove
586
- @provider.converge
587
572
  end
588
573
 
589
574
  it "uninstalls via the gem command when options are given as a String" do
590
575
  @new_resource.options('-i /alt/install/location')
591
576
  @provider.should_receive(:shell_out!).with("gem uninstall rspec -q -x -I -a -i /alt/install/location", :env=>nil)
592
577
  @provider.action_remove
593
- @provider.converge
594
578
  end
595
579
 
596
580
  it "uninstalls a specific version of a gem when a version is provided" do
597
581
  @new_resource.version('1.2.3')
598
582
  @provider.gem_env.should_receive(:uninstall).with('rspec', '1.2.3')
599
583
  @provider.action_remove
600
- @provider.converge
601
584
  end
602
585
  end
603
586
 
@@ -606,7 +589,6 @@ describe Chef::Provider::Package::Rubygems do
606
589
  @new_resource.gem_binary('/usr/weird/bin/gem')
607
590
  @provider.should_receive(:shell_out!).with("/usr/weird/bin/gem uninstall rspec -q -x -I -a", :env=>nil)
608
591
  @provider.action_remove
609
- @provider.converge
610
592
  end
611
593
  end
612
594
  end
@@ -34,7 +34,8 @@ describe Chef::Provider::Package::Yum do
34
34
  :package_available? => true,
35
35
  :version_available? => true,
36
36
  :allow_multi_install => [ "kernel" ],
37
- :package_repository => "base"
37
+ :package_repository => "base",
38
+ :disable_extra_repo_control => true
38
39
  )
39
40
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
40
41
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -92,6 +93,7 @@ describe Chef::Provider::Package::Yum do
92
93
  end
93
94
  end
94
95
  @yum_cache.stub!(:package_available?).and_return(true)
96
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
95
97
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
96
98
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
97
99
  @provider.load_current_resource
@@ -125,6 +127,7 @@ describe Chef::Provider::Package::Yum do
125
127
  nil
126
128
  end
127
129
  @yum_cache.stub!(:package_available?).and_return(true)
130
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
128
131
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
129
132
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
130
133
  # annoying side effect of the fun stub'ing above
@@ -155,6 +158,7 @@ describe Chef::Provider::Package::Yum do
155
158
  nil
156
159
  end
157
160
  @yum_cache.stub!(:package_available?).and_return(true)
161
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
158
162
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
159
163
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
160
164
  @provider.load_current_resource
@@ -189,6 +193,7 @@ describe Chef::Provider::Package::Yum do
189
193
  end
190
194
  end.and_return("something")
191
195
  @yum_cache.stub!(:package_available?).and_return(true)
196
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
192
197
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
193
198
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
194
199
  @provider.load_current_resource
@@ -209,6 +214,24 @@ describe Chef::Provider::Package::Yum do
209
214
  @provider.load_current_resource
210
215
  end
211
216
 
217
+ it "should detect --enablerepo or --disablerepo when passed among options, collect them preserving order and notify the yum cache" do
218
+ @new_resource.stub!(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
219
+ @yum_cache.should_receive(:enable_extra_repo_control).with("--enablerepo=foo --disablerepo=a,b,c --enablerepo=bar")
220
+ @provider.load_current_resource
221
+ end
222
+
223
+ it "should let the yum cache know extra repos are disabled if --enablerepo or --disablerepo aren't among options" do
224
+ @new_resource.stub!(:options).and_return("--stuff --otherthings")
225
+ @yum_cache.should_receive(:disable_extra_repo_control)
226
+ @provider.load_current_resource
227
+ end
228
+
229
+ it "should let the yum cache know extra repos are disabled if options aren't set" do
230
+ @new_resource.stub!(:options).and_return(nil)
231
+ @yum_cache.should_receive(:disable_extra_repo_control)
232
+ @provider.load_current_resource
233
+ end
234
+
212
235
  it "should search provides if package name can't be found then set package_name to match" do
213
236
  @yum_cache = mock(
214
237
  'Chef::Provider::Yum::YumCache',
@@ -217,7 +240,8 @@ describe Chef::Provider::Package::Yum do
217
240
  :installed_version => "1.2.4-11.18.el5",
218
241
  :candidate_version => "1.2.4-11.18.el5",
219
242
  :package_available? => false,
220
- :version_available? => true
243
+ :version_available? => true,
244
+ :disable_extra_repo_control => true
221
245
  )
222
246
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
223
247
  pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "1.2.4-11.18.el5", "x86_64", [])
@@ -235,7 +259,8 @@ describe Chef::Provider::Package::Yum do
235
259
  :installed_version => "1.2.4-11.18.el5",
236
260
  :candidate_version => "1.2.4-11.18.el5",
237
261
  :package_available? => false,
238
- :version_available? => true
262
+ :version_available? => true,
263
+ :disable_extra_repo_control => true
239
264
  )
240
265
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
241
266
  pkg_x = Chef::Provider::Package::Yum::RPMPackage.new("test-package-x", "1.2.4-11.18.el5", "x86_64", [])
@@ -255,7 +280,8 @@ describe Chef::Provider::Package::Yum do
255
280
  :installed_version => "1.2.4-11.18.el5",
256
281
  :candidate_version => "1.2.4-11.18.el5",
257
282
  :package_available? => false,
258
- :version_available? => true
283
+ :version_available? => true,
284
+ :disable_extra_repo_control => true
259
285
  )
260
286
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
261
287
  @yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -272,7 +298,8 @@ describe Chef::Provider::Package::Yum do
272
298
  :installed_version => "1.2.4-11.18.el5",
273
299
  :candidate_version => "1.2.4-11.18.el5",
274
300
  :package_available? => false,
275
- :version_available? => true
301
+ :version_available? => true,
302
+ :disable_extra_repo_control => true
276
303
  )
277
304
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
278
305
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -295,7 +322,8 @@ describe Chef::Provider::Package::Yum do
295
322
  :installed_version => "1.2.4-11.18.el5",
296
323
  :candidate_version => "1.2.4-11.18.el5",
297
324
  :package_available? => false,
298
- :version_available? => true
325
+ :version_available? => true,
326
+ :disable_extra_repo_control => true
299
327
  )
300
328
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
301
329
  @yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -363,7 +391,8 @@ describe Chef::Provider::Package::Yum do
363
391
  :installed_version => "1.2.4-11.18.el5",
364
392
  :candidate_version => "1.2.4-11.18.el5_2.3",
365
393
  :package_available? => true,
366
- :version_available? => nil
394
+ :version_available? => nil,
395
+ :disable_extra_repo_control => true
367
396
  )
368
397
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
369
398
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -380,7 +409,8 @@ describe Chef::Provider::Package::Yum do
380
409
  :candidate_version => "1.2.4-11.15.el5",
381
410
  :package_available? => true,
382
411
  :version_available? => true,
383
- :allow_multi_install => [ "kernel" ]
412
+ :allow_multi_install => [ "kernel" ],
413
+ :disable_extra_repo_control => true
384
414
  )
385
415
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
386
416
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -398,7 +428,8 @@ describe Chef::Provider::Package::Yum do
398
428
  :package_available? => true,
399
429
  :version_available? => true,
400
430
  :allow_multi_install => [ "cups" ],
401
- :package_repository => "base"
431
+ :package_repository => "base",
432
+ :disable_extra_repo_control => true
402
433
  )
403
434
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
404
435
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -420,7 +451,8 @@ describe Chef::Provider::Package::Yum do
420
451
  :package_available? => true,
421
452
  :version_available? => true,
422
453
  :allow_multi_install => [],
423
- :package_repository => "base"
454
+ :package_repository => "base",
455
+ :disable_extra_repo_control => true
424
456
  )
425
457
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
426
458
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -485,7 +517,8 @@ describe Chef::Provider::Package::Yum do
485
517
  :candidate_version => "1.2.4-11.15.el5",
486
518
  :package_available? => true,
487
519
  :version_available? => true,
488
- :allow_multi_install => [ "kernel" ]
520
+ :allow_multi_install => [ "kernel" ],
521
+ :disable_extra_repo_control => true
489
522
  )
490
523
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
491
524
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -504,7 +537,6 @@ describe Chef::Provider::Package::Yum do
504
537
  "11"
505
538
  )
506
539
  @provider.action_upgrade
507
- @provider.converge
508
540
  end
509
541
 
510
542
  it "should call action_upgrade in the parent if the candidate version is nil" do
@@ -513,7 +545,6 @@ describe Chef::Provider::Package::Yum do
513
545
  @provider.candidate_version = nil
514
546
  @provider.should_not_receive(:upgrade_package)
515
547
  @provider.action_upgrade
516
- @provider.converge
517
548
  end
518
549
 
519
550
  it "should call action_upgrade in the parent if the candidate is newer" do
@@ -525,7 +556,6 @@ describe Chef::Provider::Package::Yum do
525
556
  "11"
526
557
  )
527
558
  @provider.action_upgrade
528
- @provider.converge
529
559
  end
530
560
 
531
561
  it "should not call action_upgrade in the parent if the candidate is older" do
@@ -535,7 +565,6 @@ describe Chef::Provider::Package::Yum do
535
565
  @provider.candidate_version = '11'
536
566
  @provider.should_not_receive(:upgrade_package)
537
567
  @provider.action_upgrade
538
- @provider.converge
539
568
  end
540
569
  end
541
570
 
@@ -1613,6 +1642,12 @@ EOF
1613
1642
  @yc.refresh
1614
1643
  end
1615
1644
 
1645
+ it "should pass extra_repo_control args to yum-dump.py" do
1646
+ @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
1647
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :waitlast=>true)
1648
+ @yc.refresh
1649
+ end
1650
+
1616
1651
  it "should warn about invalid data with too many separators" do
1617
1652
  @yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_separators, @stderr).and_return(@status)
1618
1653
  Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
@@ -1792,4 +1827,33 @@ EOF
1792
1827
  end
1793
1828
  end
1794
1829
 
1830
+ describe "enable_extra_repo_control" do
1831
+ it "should set @extra_repo_control to arg" do
1832
+ @yc.enable_extra_repo_control("--enablerepo=test")
1833
+ @yc.extra_repo_control.should be == "--enablerepo=test"
1834
+ end
1835
+
1836
+ it "should call reload once when set to flag cache for update" do
1837
+ @yc.should_receive(:reload).once
1838
+ @yc.enable_extra_repo_control("--enablerepo=test")
1839
+ @yc.enable_extra_repo_control("--enablerepo=test")
1840
+ end
1841
+ end
1842
+
1843
+ describe "disable_extra_repo_control" do
1844
+ it "should set @extra_repo_control to nil" do
1845
+ @yc.enable_extra_repo_control("--enablerepo=test")
1846
+ @yc.disable_extra_repo_control
1847
+ @yc.extra_repo_control.should be == nil
1848
+ end
1849
+
1850
+ it "should call reload once when cleared to flag cache for update" do
1851
+ @yc.should_receive(:reload).once
1852
+ @yc.enable_extra_repo_control("--enablerepo=test")
1853
+ @yc.should_receive(:reload).once
1854
+ @yc.disable_extra_repo_control
1855
+ @yc.disable_extra_repo_control
1856
+ end
1857
+ end
1858
+
1795
1859
  end