microwave 1.0.4 → 11.400.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -250,7 +250,7 @@ describe Chef::Provider::User do
250
250
  @provider.user_exists = false
251
251
  @provider.should_receive(:create_user).and_return(true)
252
252
  @provider.action_create
253
- @provider.converge
253
+ @provider.set_updated_status
254
254
  @new_resource.should be_updated
255
255
  end
256
256
 
@@ -259,7 +259,6 @@ describe Chef::Provider::User do
259
259
  @provider.stub!(:compare_user).and_return(true)
260
260
  @provider.should_receive(:manage_user).and_return(true)
261
261
  @provider.action_create
262
- @provider.converge
263
262
  end
264
263
 
265
264
  it "should set the the new_resources updated flag when it creates the user if we call manage_user" do
@@ -267,7 +266,7 @@ describe Chef::Provider::User do
267
266
  @provider.stub!(:compare_user).and_return(true)
268
267
  @provider.stub!(:manage_user).and_return(true)
269
268
  @provider.action_create
270
- @provider.converge
269
+ @provider.set_updated_status
271
270
  @new_resource.should be_updated
272
271
  end
273
272
  end
@@ -281,21 +280,19 @@ describe Chef::Provider::User do
281
280
  @provider.user_exists = false
282
281
  @provider.should_not_receive(:remove_user)
283
282
  @provider.action_remove
284
- @provider.converge
285
283
  end
286
284
 
287
285
  it "should call remove_user if the user exists" do
288
286
  @provider.user_exists = true
289
287
  @provider.should_receive(:remove_user)
290
288
  @provider.action_remove
291
- @provider.converge
292
289
  end
293
290
 
294
291
  it "should set the new_resources updated flag to true if the user is removed" do
295
292
  @provider.user_exists = true
296
293
  @provider.should_receive(:remove_user)
297
294
  @provider.action_remove
298
- @provider.converge
295
+ @provider.set_updated_status
299
296
  @new_resource.should be_updated
300
297
  end
301
298
  end
@@ -320,14 +317,13 @@ describe Chef::Provider::User do
320
317
  @provider.should_receive(:compare_user).and_return(true)
321
318
  @provider.should_receive(:manage_user).and_return(true)
322
319
  @provider.action_manage
323
- @provider.converge
324
320
  end
325
321
 
326
322
  it "should set the new resources updated flag to true if manage_user is called" do
327
323
  @provider.stub!(:compare_user).and_return(true)
328
324
  @provider.stub!(:manage_user).and_return(true)
329
325
  @provider.action_manage
330
- @provider.converge
326
+ @provider.set_updated_status
331
327
  @new_resource.should be_updated
332
328
  end
333
329
 
@@ -335,14 +331,12 @@ describe Chef::Provider::User do
335
331
  @provider.user_exists = false
336
332
  @provider.should_not_receive(:manage_user)
337
333
  @provider.action_manage
338
- @provider.converge
339
334
  end
340
335
 
341
336
  it "should not run manage_user if the user exists but has no differing attributes" do
342
337
  @provider.should_receive(:compare_user).and_return(false)
343
338
  @provider.should_not_receive(:manage_user)
344
339
  @provider.action_manage
345
- @provider.converge
346
340
  end
347
341
  end
348
342
 
@@ -366,14 +360,13 @@ describe Chef::Provider::User do
366
360
  @provider.should_receive(:compare_user).and_return(true)
367
361
  @provider.should_receive(:manage_user).and_return(true)
368
362
  @provider.action_modify
369
- @provider.converge
370
363
  end
371
364
 
372
365
  it "should set the new resources updated flag to true if manage_user is called" do
373
366
  @provider.stub!(:compare_user).and_return(true)
374
367
  @provider.stub!(:manage_user).and_return(true)
375
368
  @provider.action_modify
376
- @provider.converge
369
+ @provider.set_updated_status
377
370
  @new_resource.should be_updated
378
371
  end
379
372
 
@@ -381,7 +374,6 @@ describe Chef::Provider::User do
381
374
  @provider.should_receive(:compare_user).and_return(false)
382
375
  @provider.should_not_receive(:manage_user)
383
376
  @provider.action_modify
384
- @provider.converge
385
377
  end
386
378
 
387
379
  it "should raise a Chef::Exceptions::User if the user doesn't exist" do
@@ -399,14 +391,13 @@ describe Chef::Provider::User do
399
391
  @provider.stub!(:check_lock).and_return(false)
400
392
  @provider.should_receive(:lock_user).and_return(true)
401
393
  @provider.action_lock
402
- @provider.converge
403
394
  end
404
395
 
405
396
  it "should set the new resources updated flag to true if lock_user is called" do
406
397
  @provider.stub!(:check_lock).and_return(false)
407
398
  @provider.should_receive(:lock_user)
408
399
  @provider.action_lock
409
- @provider.converge
400
+ @provider.set_updated_status
410
401
  @new_resource.should be_updated
411
402
  end
412
403
 
@@ -439,7 +430,7 @@ describe Chef::Provider::User do
439
430
  @provider.stub!(:check_lock).and_return(true)
440
431
  @provider.should_receive(:unlock_user).and_return(true)
441
432
  @provider.action_unlock
442
- @provider.converge
433
+ @provider.set_updated_status
443
434
  @new_resource.should be_updated
444
435
  end
445
436
 
@@ -73,6 +73,10 @@ describe Chef::Provider do
73
73
  @provider.current_resource.should eql(nil)
74
74
  end
75
75
 
76
+ it "should not support whyrun by default" do
77
+ @provider.send(:whyrun_supported?).should eql(false)
78
+ end
79
+
76
80
  it "should return true for action_nothing" do
77
81
  @provider.action_nothing.should eql(true)
78
82
  end
@@ -82,7 +86,6 @@ describe Chef::Provider do
82
86
  temporary_collection = nil
83
87
  snitch = Proc.new {temporary_collection = @run_context.resource_collection}
84
88
  @provider.send(:recipe_eval, &snitch)
85
- @provider.converge
86
89
  temporary_collection.should be_an_instance_of(Chef::ResourceCollection)
87
90
  @provider.run_context.instance_variable_get(:@resource_collection).should == "doesn't matter what this is"
88
91
  end
@@ -93,7 +96,6 @@ describe Chef::Provider do
93
96
  Chef::RunContext.stub!(:new).and_raise("not supposed to happen")
94
97
  snitch = Proc.new {temporary_collection = @run_context.resource_collection}
95
98
  @provider.send(:recipe_eval, &snitch)
96
- @provider.converge
97
99
  end
98
100
 
99
101
  context "when no converge actions are queued" do
@@ -103,7 +105,6 @@ describe Chef::Provider do
103
105
  end
104
106
 
105
107
  it "does not mark the new resource as updated" do
106
- @provider.converge
107
108
  @resource.should_not be_updated
108
109
  @resource.should_not be_updated_by_last_action
109
110
  end
@@ -24,14 +24,16 @@ require 'spec_helper'
24
24
  describe Chef::Recipe do
25
25
  before(:each) do
26
26
  @cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
27
- @cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
27
+ cl = Chef::CookbookLoader.new(@cookbook_repo)
28
+ cl.load_cookbooks
29
+ @cookbook_collection = Chef::CookbookCollection.new(cl)
28
30
  @node = Chef::Node.new
29
- @node[:tags] = Array.new
31
+ @node.normal[:tags] = Array.new
30
32
  @events = Chef::EventDispatch::Dispatcher.new
31
33
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
32
34
  @recipe = Chef::Recipe.new("hjk", "test", @run_context)
33
35
 
34
- # Shef/ext.rb is on the run path, and it defines
36
+ # Shell/ext.rb is on the run path, and it defines
35
37
  # Chef::Recipe#resources to call pp, which we don't want when
36
38
  # we're running tests.
37
39
  @recipe.stub!(:pp)
@@ -108,8 +110,8 @@ describe Chef::Recipe do
108
110
 
109
111
  it "locate resource for particular platform" do
110
112
  Object.const_set('ShaunTheSheep', Class.new(Chef::Resource){ provides :laughter, :on_platforms => ["television"] })
111
- @node.platform("television")
112
- @node.platform_version("123")
113
+ @node.automatic[:platform] = "television"
114
+ @node.automatic[:platform_version] = "123"
113
115
  res = @recipe.laughter "timmy"
114
116
  res.name.should eql("timmy")
115
117
  res.kind_of?(ShaunTheSheep)
@@ -151,7 +153,7 @@ describe Chef::Recipe do
151
153
  end
152
154
  end
153
155
  @run_context.definitions[:crow] = crow_define
154
- @node[:foo] = false
156
+ @node.normal[:foo] = false
155
157
  @recipe.crow "mine" do
156
158
  something node[:foo]
157
159
  end
@@ -204,9 +206,9 @@ describe Chef::Recipe do
204
206
  res.pretty_kitty.should eql(true)
205
207
  end
206
208
 
207
- it "should store that it has seen a recipe in node.run_state[:seen_recipes]" do
209
+ it "should store that it has seen a recipe in the run_context" do
208
210
  @run_context.include_recipe "openldap"
209
- @node.run_state[:seen_recipes].should have_key("openldap")
211
+ @run_context.loaded_recipe?("openldap").should be_true
210
212
  end
211
213
 
212
214
  it "should not include the same recipe twice" do
@@ -0,0 +1,376 @@
1
+ #
2
+ # Author:: Prajakta Purohit (prajakta@opscode.com)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::Provider::RegistryKey do
22
+
23
+ let(:value1) { { :name => "one", :type => :string, :data => "1" } }
24
+ let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
25
+ let(:key) { 'Software\OpscodeNumbers' }
26
+ let(:key_parent) { 'Software' }
27
+ let(:key_to_delete) { 'OpscodeNumbers' }
28
+ let(:sub_key) {'OpscodePrimes'}
29
+ let(:missing_key_path) {'HKCU\Software'}
30
+
31
+ before(:each) do
32
+ Chef::Win32::Registry.any_instance.stub(:machine_architecture).and_return(:x86_64)
33
+ @registry = Chef::Win32::Registry.new()
34
+
35
+ #Making the values for registry constants available on unix
36
+ Object.send(:remove_const, 'Win32') if defined?(Win32)
37
+ Win32 = Module.new
38
+ Win32::Registry = Class.new
39
+ Win32::Registry::KEY_SET_VALUE = 0x0002
40
+ Win32::Registry::KEY_QUERY_VALUE = 0x0001
41
+ Win32::Registry::KEY_WRITE = 0x00020000 | 0x0002 | 0x0004
42
+ Win32::Registry::KEY_READ = 0x00020000 | 0x0001 | 0x0008 | 0x0010
43
+
44
+ Win32::Registry::Error = Class.new(RuntimeError)
45
+
46
+ @hive_mock = mock("::Win32::Registry::HKEY_CURRENT_USER")
47
+ @reg_mock = mock("reg")
48
+ end
49
+
50
+ describe "get_values" do
51
+ it "gets all values for a key if the key exists" do
52
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
53
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
54
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
55
+ @reg_mock.should_receive(:map)
56
+ @registry.get_values(key_path)
57
+ end
58
+
59
+ it "throws an exception if key does not exist" do
60
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
61
+ @registry.should_receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
62
+ lambda{@registry.get_values(key_path)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
63
+ end
64
+ end
65
+
66
+ describe "set_value" do
67
+ it "does nothing if key and hive and value exist" do
68
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
69
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
70
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(true)
71
+ @registry.should_receive(:data_exists?).with(key_path, value1).and_return(true)
72
+ @registry.set_value(key_path, value1)
73
+ end
74
+
75
+ it "updates value if key and hive and value exist, but data is different" do
76
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
77
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
78
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(true)
79
+ @registry.should_receive(:data_exists?).with(key_path, value1).and_return(false)
80
+ @hive_mock.should_receive(:open).with(key, Win32::Registry::KEY_SET_VALUE | ::Win32::Registry::KEY_QUERY_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
81
+ @registry.should_receive(:get_type_from_name).with(:string).and_return(1)
82
+ @reg_mock.should_receive(:write).with("one", 1, "1")
83
+ @registry.set_value(key_path, value1)
84
+ end
85
+
86
+ it "creates value if the key exists and the value does not exist" do
87
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
88
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
89
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(false)
90
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_SET_VALUE | ::Win32::Registry::KEY_QUERY_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
91
+ @registry.should_receive(:get_type_from_name).with(:string).and_return(1)
92
+ @reg_mock.should_receive(:write).with("one", 1, "1")
93
+ @registry.set_value(key_path, value1)
94
+ end
95
+
96
+ it "should raise an exception if the key does not exist" do
97
+ @registry.should_receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
98
+ lambda {@registry.set_value(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
99
+ end
100
+ end
101
+
102
+ describe "delete_value" do
103
+ it "deletes value if value exists" do
104
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(true)
105
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
106
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_SET_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
107
+ @reg_mock.should_receive(:delete_value).with("one").and_return(true)
108
+ @registry.delete_value(key_path, value1)
109
+ end
110
+
111
+ it "raises an exception if the key does not exist" do
112
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(true)
113
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
114
+ @registry.delete_value(key_path, value1)
115
+ end
116
+
117
+ it "does nothing if the value does not exist" do
118
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(false)
119
+ @registry.delete_value(key_path, value1)
120
+ end
121
+ end
122
+
123
+ describe "create_key" do
124
+ it "creates key if intermediate keys are missing and recursive is set to true" do
125
+ @registry.should_receive(:keys_missing?).with(key_path).and_return(true)
126
+ @registry.should_receive(:create_missing).with(key_path)
127
+ @registry.should_receive(:key_exists?).with(key_path).and_return(false)
128
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
129
+ @hive_mock.should_receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
130
+ @registry.create_key(key_path, true)
131
+ end
132
+
133
+ it "raises an exception if intermediate keys are missing and recursive is set to false" do
134
+ @registry.should_receive(:keys_missing?).with(key_path).and_return(true)
135
+ lambda{@registry.create_key(key_path, false)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
136
+ end
137
+
138
+ it "does nothing if the key exists" do
139
+ @registry.should_receive(:keys_missing?).with(key_path).and_return(true)
140
+ @registry.should_receive(:create_missing).with(key_path)
141
+ @registry.should_receive(:key_exists?).with(key_path).and_return(true)
142
+ @registry.create_key(key_path, true)
143
+ end
144
+
145
+ it "create key if intermediate keys not missing and recursive is set to false" do
146
+ @registry.should_receive(:keys_missing?).with(key_path).and_return(false)
147
+ @registry.should_receive(:key_exists?).with(key_path).and_return(false)
148
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
149
+ @hive_mock.should_receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
150
+ @registry.create_key(key_path, false)
151
+ end
152
+
153
+ it "create key if intermediate keys not missing and recursive is set to true" do
154
+ @registry.should_receive(:keys_missing?).with(key_path).and_return(false)
155
+ @registry.should_receive(:key_exists?).with(key_path).and_return(false)
156
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
157
+ @hive_mock.should_receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
158
+ @registry.create_key(key_path, true)
159
+ end
160
+ end
161
+
162
+ describe "delete_key", :windows_only do
163
+ it "deletes key if it has subkeys and recursive is set to true" do
164
+ @registry.should_receive(:key_exists?).with(key_path).and_return(true)
165
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
166
+ @registry.should_receive(:has_subkeys?).with(key_path).and_return(true)
167
+ @registry.should_receive(:get_subkeys).with(key_path).and_return([sub_key])
168
+ @registry.should_receive(:key_exists?).with(key_path+"\\"+sub_key).and_return(true)
169
+ @registry.should_receive(:get_hive_and_key).with(key_path+"\\"+sub_key).and_return([@hive_mock, key+"\\"+sub_key])
170
+ @registry.should_receive(:has_subkeys?).with(key_path+"\\"+sub_key).and_return(false)
171
+ @registry.should_receive(:delete_key_ex).twice
172
+ @registry.delete_key(key_path, true)
173
+ end
174
+
175
+ it "raises an exception if it has subkeys but recursive is set to false" do
176
+ @registry.should_receive(:key_exists?).with(key_path).and_return(true)
177
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
178
+ @registry.should_receive(:has_subkeys?).with(key_path).and_return(true)
179
+ lambda{@registry.delete_key(key_path, false)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
180
+ end
181
+
182
+ it "deletes key if the key exists and has no subkeys" do
183
+ @registry.should_receive(:key_exists?).with(key_path).and_return(true)
184
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
185
+ @registry.should_receive(:has_subkeys?).with(key_path).and_return(false)
186
+ @registry.should_receive(:delete_key_ex)
187
+ @registry.delete_key(key_path, true)
188
+ end
189
+ end
190
+
191
+ describe "key_exists?" do
192
+ it "returns true if key_exists" do
193
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
194
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
195
+ @registry.key_exists?(key_path).should == true
196
+ end
197
+
198
+ it "returns false if key does not exist" do
199
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
200
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_raise(::Win32::Registry::Error)
201
+ @registry.key_exists?(key_path).should == false
202
+ end
203
+ end
204
+
205
+ describe "key_exists!" do
206
+ it "throws an exception if the key_parent does not exist" do
207
+ @registry.should_receive(:key_exists?).with(key_path).and_return(false)
208
+ lambda{@registry.key_exists!(key_path)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
209
+ end
210
+ end
211
+
212
+ describe "hive_exists?" do
213
+ it "returns true if the hive exists" do
214
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
215
+ @registry.hive_exists?(key_path) == true
216
+ end
217
+
218
+ it "returns false if the hive does not exist" do
219
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegHiveMissing)
220
+ @registry.hive_exists?(key_path) == false
221
+ end
222
+ end
223
+
224
+ describe "has_subkeys?" do
225
+ it "returns true if the key has subkeys" do
226
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
227
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
228
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
229
+ @reg_mock.should_receive(:each_key).and_yield(key)
230
+ @registry.has_subkeys?(key_path) == true
231
+ end
232
+
233
+ it "returns false if the key does not have subkeys" do
234
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
235
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
236
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
237
+ @reg_mock.should_receive(:each_key).and_return(no_args())
238
+ @registry.has_subkeys?(key_path).should == false
239
+ end
240
+
241
+ it "throws an exception if the key does not exist" do
242
+ @registry.should_receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
243
+ lambda {@registry.set_value(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
244
+ end
245
+ end
246
+
247
+ describe "get_subkeys" do
248
+ it "returns the subkeys if they exist" do
249
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
250
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
251
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
252
+ @reg_mock.should_receive(:each_key).and_yield(sub_key)
253
+ @registry.get_subkeys(key_path)
254
+ end
255
+ end
256
+
257
+ describe "value_exists?" do
258
+ it "throws an exception if the key does not exist" do
259
+ @registry.should_receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
260
+ lambda {@registry.value_exists?(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
261
+ end
262
+
263
+ it "returns true if the value exists" do
264
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
265
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
266
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
267
+ @reg_mock.should_receive(:any?).and_yield("one")
268
+ @registry.value_exists?(key_path, value1) == true
269
+ end
270
+
271
+ it "returns false if the value does not exist" do
272
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
273
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
274
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
275
+ @reg_mock.should_receive(:any?).and_yield(no_args())
276
+ @registry.value_exists?(key_path, value1) == false
277
+ end
278
+ end
279
+
280
+ describe "data_exists?" do
281
+ it "throws an exception if the key does not exist" do
282
+ @registry.should_receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
283
+ lambda {@registry.data_exists?(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
284
+ end
285
+
286
+ it "returns true if the data exists" do
287
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
288
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
289
+ @registry.should_receive(:get_type_from_name).with(:string).and_return(1)
290
+ @reg_mock.should_receive(:each).with(no_args()).and_yield("one", 1, "1")
291
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
292
+ @registry.data_exists?(key_path, value1).should == true
293
+ end
294
+
295
+ it "returns false if the data does not exist" do
296
+ @registry.should_receive(:key_exists!).with(key_path).and_return(true)
297
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
298
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
299
+ @registry.should_receive(:get_type_from_name).with(:string).and_return(1)
300
+ @reg_mock.should_receive(:each).with(no_args()).and_yield("one", 1, "2")
301
+ @registry.data_exists?(key_path, value1).should == false
302
+ end
303
+ end
304
+
305
+ describe "value_exists!" do
306
+ it "does nothing if the value exists" do
307
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(true)
308
+ @registry.value_exists!(key_path, value1)
309
+ end
310
+
311
+ it "throws an exception if the value does not exist" do
312
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(false)
313
+ lambda{@registry.value_exists!(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegValueMissing)
314
+ end
315
+ end
316
+
317
+ describe "data_exists!" do
318
+ it "does nothing if the data exists" do
319
+ @registry.should_receive(:data_exists?).with(key_path, value1).and_return(true)
320
+ @registry.data_exists!(key_path, value1)
321
+ end
322
+
323
+ it "throws an exception if the data does not exist" do
324
+ @registry.should_receive(:data_exists?).with(key_path, value1).and_return(false)
325
+ lambda{@registry.data_exists!(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegDataMissing)
326
+ end
327
+ end
328
+
329
+ describe "type_matches?" do
330
+ it "returns true if type matches" do
331
+ @registry.should_receive(:value_exists!).with(key_path, value1).and_return(true)
332
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
333
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
334
+ @registry.should_receive(:get_type_from_name).with(:string).and_return(1)
335
+ @reg_mock.should_receive(:each).and_yield("one", 1)
336
+ @registry.type_matches?(key_path, value1).should == true
337
+ end
338
+
339
+ it "returns false if type does not match" do
340
+ @registry.should_receive(:value_exists!).with(key_path, value1).and_return(true)
341
+ @registry.should_receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
342
+ @hive_mock.should_receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
343
+ @reg_mock.should_receive(:each).and_yield("two", 2)
344
+ @registry.type_matches?(key_path, value1).should == false
345
+ end
346
+
347
+ it "throws an exception if value does not exist" do
348
+ @registry.should_receive(:value_exists?).with(key_path, value1).and_return(false)
349
+ lambda{@registry.type_matches?(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegValueMissing)
350
+ end
351
+ end
352
+
353
+ describe "type_matches!" do
354
+ it "does nothing if the type_matches" do
355
+ @registry.should_receive(:type_matches?).with(key_path, value1).and_return(true)
356
+ @registry.type_matches!(key_path, value1)
357
+ end
358
+
359
+ it "throws an exception if the type does not match" do
360
+ @registry.should_receive(:type_matches?).with(key_path, value1).and_return(false)
361
+ lambda{@registry.type_matches!(key_path, value1)}.should raise_error(Chef::Exceptions::Win32RegTypesMismatch)
362
+ end
363
+ end
364
+
365
+ describe "keys_missing?" do
366
+ it "returns true if the keys are missing" do
367
+ @registry.should_receive(:key_exists?).with(missing_key_path).and_return(false)
368
+ @registry.keys_missing?(key_path).should == true
369
+ end
370
+
371
+ it "returns false if no keys in the path are missing" do
372
+ @registry.should_receive(:key_exists?).with(missing_key_path).and_return(true)
373
+ @registry.keys_missing?(key_path).should == false
374
+ end
375
+ end
376
+ end