chef 10.34.6 → 11.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (506) hide show
  1. data/CONTRIBUTING.md +155 -0
  2. data/README.md +89 -0
  3. data/Rakefile +4 -12
  4. data/bin/chef-apply +25 -0
  5. data/bin/chef-shell +34 -0
  6. data/bin/shef +6 -5
  7. data/distro/common/html/chef-client.8.html +4 -4
  8. data/distro/common/html/chef-expander.8.html +4 -4
  9. data/distro/common/html/chef-expanderctl.8.html +4 -4
  10. data/distro/common/html/chef-server-webui.8.html +4 -4
  11. data/distro/common/html/chef-server.8.html +4 -4
  12. data/distro/common/html/{shef.1.html → chef-shell.1.html} +49 -46
  13. data/distro/common/html/chef-solo.8.html +18 -12
  14. data/distro/common/html/chef-solr.8.html +4 -4
  15. data/distro/common/html/knife-bootstrap.1.html +4 -4
  16. data/distro/common/html/knife-client.1.html +4 -4
  17. data/distro/common/html/knife-configure.1.html +4 -4
  18. data/distro/common/html/knife-cookbook-site.1.html +4 -4
  19. data/distro/common/html/knife-cookbook.1.html +10 -7
  20. data/distro/common/html/knife-data-bag.1.html +10 -7
  21. data/distro/common/html/knife-environment.1.html +8 -6
  22. data/distro/common/html/knife-exec.1.html +9 -9
  23. data/distro/common/html/knife-index.1.html +4 -4
  24. data/distro/common/html/knife-node.1.html +4 -4
  25. data/distro/common/html/knife-role.1.html +4 -4
  26. data/distro/common/html/knife-search.1.html +4 -4
  27. data/distro/common/html/knife-ssh.1.html +4 -4
  28. data/distro/common/html/knife-status.1.html +4 -4
  29. data/distro/common/html/knife-tag.1.html +4 -4
  30. data/distro/common/html/knife.1.html +8 -13
  31. data/distro/common/man/man1/{shef.1 → chef-shell.1} +21 -57
  32. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  33. data/distro/common/man/man1/knife-client.1 +1 -1
  34. data/distro/common/man/man1/knife-configure.1 +1 -1
  35. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  36. data/distro/common/man/man1/knife-cookbook.1 +15 -2
  37. data/distro/common/man/man1/knife-data-bag.1 +15 -2
  38. data/distro/common/man/man1/knife-environment.1 +12 -2
  39. data/distro/common/man/man1/knife-exec.1 +4 -7
  40. data/distro/common/man/man1/knife-index.1 +1 -1
  41. data/distro/common/man/man1/knife-node.1 +1 -1
  42. data/distro/common/man/man1/knife-role.1 +1 -1
  43. data/distro/common/man/man1/knife-search.1 +1 -1
  44. data/distro/common/man/man1/knife-ssh.1 +1 -1
  45. data/distro/common/man/man1/knife-status.1 +1 -1
  46. data/distro/common/man/man1/knife-tag.1 +1 -1
  47. data/distro/common/man/man1/knife.1 +3 -6
  48. data/distro/common/man/man8/chef-client.8 +1 -1
  49. data/distro/common/man/man8/chef-expander.8 +1 -1
  50. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  51. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  52. data/distro/common/man/man8/chef-server.8 +1 -1
  53. data/distro/common/man/man8/chef-solo.8 +36 -4
  54. data/distro/common/man/man8/chef-solr.8 +1 -1
  55. data/distro/common/markdown/man1/{shef.mkd → chef-shell.mkd} +49 -43
  56. data/distro/common/markdown/man1/knife-exec.mkd +11 -6
  57. data/distro/common/markdown/man1/knife.mkd +4 -9
  58. data/distro/debian/etc/default/chef-client +0 -1
  59. data/distro/debian/etc/init.d/chef-client +2 -2
  60. data/lib/chef.rb +2 -5
  61. data/lib/chef/api_client.rb +20 -130
  62. data/lib/chef/api_client/registration.rb +126 -0
  63. data/lib/chef/application.rb +71 -14
  64. data/lib/chef/application/apply.rb +160 -0
  65. data/lib/chef/application/client.rb +25 -18
  66. data/lib/chef/application/knife.rb +0 -2
  67. data/lib/chef/application/solo.rb +23 -8
  68. data/lib/chef/application/windows_service.rb +5 -2
  69. data/lib/chef/applications.rb +1 -0
  70. data/lib/chef/chef_fs.rb +11 -0
  71. data/lib/chef/chef_fs/command_line.rb +232 -0
  72. data/lib/chef/chef_fs/file_pattern.rb +312 -0
  73. data/lib/chef/chef_fs/file_system.rb +358 -0
  74. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +47 -0
  75. data/lib/chef/chef_fs/file_system/base_fs_object.rb +121 -0
  76. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +109 -0
  77. data/{spec/unit/monkey_patches/uri_spec.rb → lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb} +12 -15
  78. data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +84 -0
  79. data/lib/chef/chef_fs/file_system/cookbook_dir.rb +188 -0
  80. data/lib/chef/chef_fs/file_system/cookbook_file.rb +78 -0
  81. data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +54 -0
  82. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +68 -0
  83. data/lib/chef/chef_fs/file_system/data_bag_dir.rb +78 -0
  84. data/lib/chef/chef_fs/file_system/data_bag_item.rb +59 -0
  85. data/lib/chef/chef_fs/file_system/data_bags_dir.rb +66 -0
  86. data/lib/chef/chef_fs/file_system/file_system_entry.rb +90 -0
  87. data/lib/chef/{index_queue.rb → chef_fs/file_system/file_system_error.rb} +14 -12
  88. data/lib/chef/{resource/whyrun_safe_ruby_block.rb → chef_fs/file_system/file_system_root_dir.rb} +10 -10
  89. data/lib/chef/chef_fs/file_system/must_delete_recursively_error.rb +31 -0
  90. data/lib/chef/chef_fs/file_system/nodes_dir.rb +47 -0
  91. data/lib/chef/{provider/whyrun_safe_ruby_block.rb → chef_fs/file_system/nonexistent_fs_object.rb} +19 -9
  92. data/lib/chef/chef_fs/file_system/not_found_error.rb +31 -0
  93. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +84 -0
  94. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +123 -0
  95. data/lib/chef/chef_fs/knife.rb +77 -0
  96. data/lib/chef/chef_fs/path_utils.rb +64 -0
  97. data/lib/chef/client.rb +44 -21
  98. data/lib/chef/config.rb +52 -43
  99. data/lib/chef/cookbook/synchronizer.rb +6 -8
  100. data/lib/chef/cookbook/syntax_check.rb +61 -14
  101. data/lib/chef/cookbook_loader.rb +39 -26
  102. data/lib/chef/cookbook_uploader.rb +17 -19
  103. data/lib/chef/cookbook_version.rb +3 -302
  104. data/lib/chef/daemon.rb +3 -18
  105. data/lib/chef/data_bag.rb +4 -97
  106. data/lib/chef/data_bag_item.rb +2 -65
  107. data/lib/chef/digester.rb +73 -0
  108. data/lib/chef/dsl.rb +6 -0
  109. data/lib/chef/dsl/data_query.rb +66 -0
  110. data/lib/chef/dsl/include_attribute.rb +60 -0
  111. data/lib/chef/dsl/include_recipe.rb +42 -0
  112. data/lib/chef/dsl/platform_introspection.rb +213 -0
  113. data/lib/chef/dsl/recipe.rb +84 -0
  114. data/lib/chef/dsl/registry_helper.rb +59 -0
  115. data/lib/chef/encrypted_data_bag_item.rb +74 -19
  116. data/lib/chef/environment.rb +9 -180
  117. data/lib/chef/exceptions.rb +87 -14
  118. data/lib/chef/formatters/base.rb +4 -1
  119. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +0 -4
  120. data/lib/chef/json_compat.rb +1 -97
  121. data/lib/chef/knife.rb +90 -41
  122. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  123. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  124. data/lib/chef/knife/bootstrap/chef-full.erb +3 -3
  125. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
  126. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  127. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
  128. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
  129. data/lib/chef/knife/configure.rb +1 -2
  130. data/lib/chef/knife/cookbook_metadata.rb +1 -0
  131. data/lib/chef/knife/cookbook_test.rb +3 -2
  132. data/lib/chef/knife/cookbook_upload.rb +12 -7
  133. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  134. data/lib/chef/knife/core/generic_presenter.rb +26 -13
  135. data/lib/chef/knife/core/node_editor.rb +36 -16
  136. data/lib/chef/knife/core/node_presenter.rb +1 -1
  137. data/lib/chef/knife/core/text_formatter.rb +23 -37
  138. data/lib/chef/knife/core/ui.rb +15 -9
  139. data/lib/chef/knife/delete.rb +39 -0
  140. data/lib/chef/knife/diff.rb +46 -0
  141. data/lib/chef/knife/download.rb +50 -0
  142. data/lib/chef/knife/environment_show.rb +7 -0
  143. data/lib/chef/knife/exec.rb +5 -5
  144. data/lib/chef/knife/help_topics.rb +1 -1
  145. data/lib/chef/knife/index_rebuild.rb +91 -7
  146. data/lib/chef/knife/list.rb +109 -0
  147. data/lib/chef/knife/raw.rb +108 -0
  148. data/lib/chef/knife/search.rb +40 -22
  149. data/lib/chef/knife/show.rb +32 -0
  150. data/lib/chef/knife/ssh.rb +6 -2
  151. data/lib/chef/knife/upload.rb +50 -0
  152. data/lib/chef/mixin/checksum.rb +3 -3
  153. data/lib/chef/mixin/deep_merge.rb +55 -197
  154. data/lib/chef/mixin/language.rb +9 -222
  155. data/lib/chef/mixin/language_include_attribute.rb +6 -38
  156. data/lib/chef/mixin/language_include_recipe.rb +3 -35
  157. data/lib/chef/mixin/params_validate.rb +6 -19
  158. data/lib/chef/mixin/recipe_definition_dsl_core.rb +8 -61
  159. data/lib/chef/mixin/securable.rb +32 -7
  160. data/lib/chef/mixin/template.rb +40 -0
  161. data/lib/chef/mixins.rb +0 -4
  162. data/lib/chef/monkey_patches/net_http.rb +0 -34
  163. data/lib/chef/node.rb +133 -309
  164. data/lib/chef/node/attribute.rb +333 -473
  165. data/lib/chef/node/attribute_collections.rb +199 -0
  166. data/lib/chef/node/immutable_collections.rb +186 -0
  167. data/lib/chef/platform.rb +7 -22
  168. data/lib/chef/provider.rb +2 -49
  169. data/lib/chef/provider/breakpoint.rb +6 -6
  170. data/lib/chef/provider/cookbook_file.rb +5 -33
  171. data/lib/chef/provider/deploy.rb +2 -1
  172. data/lib/chef/provider/directory.rb +14 -17
  173. data/lib/chef/provider/file.rb +19 -52
  174. data/lib/chef/provider/group.rb +31 -51
  175. data/lib/chef/provider/group/dscl.rb +13 -53
  176. data/lib/chef/provider/group/gpasswd.rb +19 -14
  177. data/lib/chef/provider/group/groupadd.rb +1 -41
  178. data/lib/chef/provider/group/groupmod.rb +36 -46
  179. data/lib/chef/provider/group/pw.rb +16 -59
  180. data/lib/chef/provider/group/suse.rb +13 -16
  181. data/lib/chef/provider/group/usermod.rb +18 -40
  182. data/lib/chef/provider/group/windows.rb +6 -13
  183. data/lib/chef/provider/http_request.rb +25 -42
  184. data/lib/chef/provider/link.rb +2 -0
  185. data/lib/chef/provider/lwrp_base.rb +150 -0
  186. data/lib/chef/provider/package/portage.rb +4 -9
  187. data/lib/chef/provider/package/rpm.rb +2 -2
  188. data/lib/chef/provider/package/rubygems.rb +9 -41
  189. data/lib/chef/provider/package/yum.rb +12 -19
  190. data/lib/chef/provider/registry_key.rb +156 -0
  191. data/lib/chef/provider/remote_directory.rb +2 -0
  192. data/lib/chef/provider/remote_file.rb +21 -12
  193. data/lib/chef/provider/ruby_block.rb +5 -2
  194. data/lib/chef/provider/service.rb +15 -0
  195. data/lib/chef/provider/service/init.rb +9 -7
  196. data/lib/chef/provider/service/macosx.rb +15 -73
  197. data/lib/chef/provider/service/simple.rb +1 -1
  198. data/lib/chef/provider/service/solaris.rb +3 -3
  199. data/lib/chef/provider/template.rb +22 -25
  200. data/lib/chef/provider/template_finder.rb +61 -0
  201. data/lib/chef/provider/user.rb +0 -1
  202. data/lib/chef/provider/user/dscl.rb +175 -568
  203. data/lib/chef/provider/user/useradd.rb +30 -47
  204. data/lib/chef/providers.rb +3 -2
  205. data/lib/chef/recipe.rb +14 -8
  206. data/lib/chef/resource.rb +13 -154
  207. data/lib/chef/resource/group.rb +1 -11
  208. data/lib/chef/resource/http_request.rb +2 -1
  209. data/lib/chef/resource/lwrp_base.rb +127 -0
  210. data/lib/chef/resource/mount.rb +10 -11
  211. data/lib/chef/resource/registry_key.rb +86 -0
  212. data/lib/chef/resource/remote_directory.rb +6 -5
  213. data/lib/chef/resource/remote_file.rb +22 -31
  214. data/lib/chef/resource/ruby_block.rb +2 -2
  215. data/lib/chef/resource/service.rb +14 -0
  216. data/lib/chef/resource/user.rb +0 -18
  217. data/lib/chef/resource_collection.rb +25 -21
  218. data/lib/chef/resources.rb +2 -1
  219. data/lib/chef/rest.rb +50 -131
  220. data/lib/chef/rest/auth_credentials.rb +4 -20
  221. data/lib/chef/rest/rest_request.rb +2 -7
  222. data/lib/chef/role.rb +1 -97
  223. data/lib/chef/run_context.rb +108 -130
  224. data/lib/chef/run_context/cookbook_compiler.rb +280 -0
  225. data/lib/chef/run_list.rb +0 -2
  226. data/lib/chef/run_list/run_list_expansion.rb +0 -15
  227. data/lib/chef/run_lock.rb +90 -0
  228. data/lib/chef/runner.rb +28 -5
  229. data/lib/chef/sandbox.rb +15 -148
  230. data/lib/chef/scan_access_control.rb +2 -4
  231. data/lib/chef/shef/ext.rb +3 -575
  232. data/lib/chef/{shef.rb → shell.rb} +35 -40
  233. data/lib/chef/shell/ext.rb +593 -0
  234. data/lib/chef/{shef → shell}/model_wrapper.rb +3 -3
  235. data/lib/chef/{shef/shef_rest.rb → shell/shell_rest.rb} +4 -4
  236. data/lib/chef/{shef/shef_session.rb → shell/shell_session.rb} +17 -15
  237. data/lib/chef/shell_out.rb +7 -0
  238. data/lib/chef/util/windows/net_group.rb +1 -5
  239. data/lib/chef/version.rb +3 -3
  240. data/lib/chef/win32/api/process.rb +0 -1
  241. data/lib/chef/win32/handle.rb +1 -8
  242. data/lib/chef/win32/registry.rb +371 -0
  243. data/spec/data/big_json.json +1 -2
  244. data/spec/data/big_json_plus_one.json +1 -2
  245. data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
  246. data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
  247. data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
  248. data/spec/data/nodes/default.rb +3 -3
  249. data/spec/data/nodes/test.example.com.rb +3 -3
  250. data/spec/data/nodes/test.rb +3 -3
  251. data/spec/data/partial_one.erb +1 -0
  252. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
  253. data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
  254. data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
  255. data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
  256. data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
  257. data/spec/data/{knife-home/.chef/plugins/knife/example_home_subcommand.rb → run_context/cookbooks/circular-dep1/recipes/default.rb} +0 -0
  258. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  259. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
  260. data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
  261. data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
  262. data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
  263. data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
  264. data/spec/data/{lwrp_const_scoping/resources/conflict.rb → run_context/cookbooks/circular-dep2/recipes/default.rb} +0 -0
  265. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  266. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
  267. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
  268. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
  269. data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
  270. data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
  271. data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
  272. data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
  273. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  274. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
  275. data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
  276. data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
  277. data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
  278. data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
  279. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  280. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
  281. data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
  282. data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
  283. data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
  284. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  285. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
  286. data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
  287. data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
  288. data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
  289. data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
  290. data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
  291. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
  292. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
  293. data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
  294. data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
  295. data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
  296. data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
  297. data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
  298. data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
  299. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  300. data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
  301. data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
  302. data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
  303. data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
  304. data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
  305. data/spec/data/shef-config.rb +7 -0
  306. data/spec/functional/dsl/registry_helper_spec.rb +63 -0
  307. data/spec/functional/knife/cookbook_delete_spec.rb +1 -1
  308. data/spec/functional/knife/exec_spec.rb +2 -2
  309. data/spec/functional/knife/ssh_spec.rb +5 -1
  310. data/spec/functional/resource/cookbook_file_spec.rb +7 -19
  311. data/spec/functional/resource/directory_spec.rb +4 -0
  312. data/spec/functional/resource/file_spec.rb +56 -22
  313. data/spec/functional/resource/link_spec.rb +2 -0
  314. data/spec/functional/resource/registry_spec.rb +576 -0
  315. data/spec/functional/resource/remote_directory_spec.rb +142 -36
  316. data/spec/functional/resource/remote_file_spec.rb +18 -0
  317. data/spec/functional/resource/template_spec.rb +23 -2
  318. data/spec/functional/run_lock_spec.rb +106 -0
  319. data/spec/functional/shell_spec.rb +100 -0
  320. data/spec/functional/win32/registry_helper_spec.rb +632 -0
  321. data/spec/spec_helper.rb +5 -29
  322. data/spec/stress/win32/security_spec.rb +1 -1
  323. data/spec/support/chef_helpers.rb +0 -2
  324. data/spec/support/platform_helpers.rb +8 -15
  325. data/spec/support/shared/functional/directory_resource.rb +84 -22
  326. data/spec/support/shared/functional/file_resource.rb +169 -71
  327. data/spec/support/shared/functional/securable_resource.rb +143 -119
  328. data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
  329. data/spec/support/shared/unit/file_system_support.rb +110 -0
  330. data/spec/support/shared/unit/platform_introspector.rb +162 -0
  331. data/spec/unit/api_client/registration_spec.rb +175 -0
  332. data/spec/unit/api_client_spec.rb +78 -156
  333. data/spec/unit/application/apply.rb +84 -0
  334. data/spec/unit/application/client_spec.rb +1 -37
  335. data/spec/unit/application/knife_spec.rb +5 -0
  336. data/spec/unit/application_spec.rb +57 -2
  337. data/spec/unit/checksum/storage/filesystem_spec.rb +1 -1
  338. data/spec/unit/chef_fs/diff_spec.rb +328 -0
  339. data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
  340. data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
  341. data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
  342. data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
  343. data/spec/unit/chef_fs/file_system_spec.rb +136 -0
  344. data/spec/unit/client_spec.rb +124 -33
  345. data/spec/unit/config_spec.rb +46 -13
  346. data/spec/unit/cookbook/synchronizer_spec.rb +1 -49
  347. data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
  348. data/spec/unit/cookbook_loader_spec.rb +153 -91
  349. data/spec/unit/cookbook_manifest_spec.rb +81 -81
  350. data/spec/unit/cookbook_spec.rb +3 -20
  351. data/spec/unit/cookbook_version_spec.rb +23 -122
  352. data/spec/unit/daemon_spec.rb +3 -24
  353. data/spec/unit/data_bag_spec.rb +6 -4
  354. data/spec/unit/digester_spec.rb +50 -0
  355. data/spec/unit/dsl/data_query_spec.rb +66 -0
  356. data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
  357. data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
  358. data/spec/unit/encrypted_data_bag_item_spec.rb +50 -105
  359. data/spec/unit/environment_spec.rb +0 -130
  360. data/spec/unit/exceptions_spec.rb +2 -3
  361. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +3 -3
  362. data/spec/unit/json_compat_spec.rb +15 -7
  363. data/spec/unit/knife/bootstrap_spec.rb +2 -0
  364. data/spec/unit/knife/configure_spec.rb +20 -14
  365. data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
  366. data/spec/unit/knife/cookbook_test_spec.rb +1 -0
  367. data/spec/unit/knife/cookbook_upload_spec.rb +43 -8
  368. data/spec/unit/knife/core/bootstrap_context_spec.rb +1 -1
  369. data/spec/unit/knife/core/ui_spec.rb +156 -125
  370. data/spec/unit/knife/data_bag_create_spec.rb +9 -0
  371. data/spec/unit/knife/data_bag_edit_spec.rb +1 -4
  372. data/spec/unit/knife/data_bag_from_file_spec.rb +4 -6
  373. data/spec/unit/knife/data_bag_show_spec.rb +11 -4
  374. data/spec/unit/knife/index_rebuild_spec.rb +96 -33
  375. data/spec/unit/knife/knife_help.rb +7 -7
  376. data/spec/unit/knife/node_edit_spec.rb +6 -33
  377. data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
  378. data/spec/unit/knife/ssh_spec.rb +12 -15
  379. data/spec/unit/knife/status_spec.rb +2 -2
  380. data/spec/unit/knife_spec.rb +53 -0
  381. data/spec/unit/lwrp_spec.rb +59 -42
  382. data/spec/unit/mixin/checksum_spec.rb +2 -2
  383. data/spec/unit/mixin/deep_merge_spec.rb +101 -799
  384. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
  385. data/spec/unit/mixin/params_validate_spec.rb +4 -37
  386. data/spec/unit/mixin/securable_spec.rb +5 -3
  387. data/spec/unit/mixin/template_spec.rb +119 -0
  388. data/spec/unit/node/attribute_spec.rb +195 -173
  389. data/spec/unit/node/immutable_collections_spec.rb +139 -0
  390. data/spec/unit/node_spec.rb +366 -370
  391. data/spec/unit/platform_spec.rb +9 -10
  392. data/spec/unit/provider/breakpoint_spec.rb +8 -8
  393. data/spec/unit/provider/cookbook_file_spec.rb +4 -8
  394. data/spec/unit/provider/directory_spec.rb +96 -64
  395. data/spec/unit/provider/env_spec.rb +2 -2
  396. data/spec/unit/provider/file_spec.rb +48 -39
  397. data/spec/unit/provider/group/dscl_spec.rb +0 -36
  398. data/spec/unit/provider/group/gpasswd_spec.rb +9 -16
  399. data/spec/unit/provider/group/groupadd_spec.rb +4 -3
  400. data/spec/unit/provider/group/groupmod_spec.rb +1 -0
  401. data/spec/unit/provider/group/pw_spec.rb +15 -12
  402. data/spec/unit/provider/group/usermod_spec.rb +6 -21
  403. data/spec/unit/provider/group/windows_spec.rb +8 -0
  404. data/spec/unit/provider/group_spec.rb +6 -28
  405. data/spec/unit/provider/http_request_spec.rb +28 -69
  406. data/spec/unit/provider/ifconfig_spec.rb +2 -2
  407. data/spec/unit/provider/ohai_spec.rb +4 -4
  408. data/spec/unit/provider/package/apt_spec.rb +0 -1
  409. data/spec/unit/provider/package/ips_spec.rb +0 -1
  410. data/spec/unit/provider/package/portage_spec.rb +0 -44
  411. data/spec/unit/provider/package/rpm_spec.rb +0 -12
  412. data/spec/unit/provider/package/rubygems_spec.rb +1 -44
  413. data/spec/unit/provider/package/yum_spec.rb +39 -36
  414. data/spec/unit/provider/package_spec.rb +7 -5
  415. data/spec/unit/provider/registry_key_spec.rb +269 -0
  416. data/spec/unit/provider/remote_directory_spec.rb +7 -3
  417. data/spec/unit/provider/remote_file_spec.rb +36 -0
  418. data/spec/unit/provider/route_spec.rb +4 -3
  419. data/spec/unit/provider/ruby_block_spec.rb +8 -0
  420. data/spec/unit/provider/service/arch_service_spec.rb +5 -5
  421. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  422. data/spec/unit/provider/service/freebsd_service_spec.rb +5 -5
  423. data/spec/unit/provider/service/init_service_spec.rb +27 -4
  424. data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
  425. data/spec/unit/provider/service/invokercd_service_spec.rb +4 -4
  426. data/spec/unit/provider/service/macosx_spec.rb +11 -66
  427. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  428. data/spec/unit/provider/service/simple_service_spec.rb +3 -3
  429. data/spec/unit/provider/service/upstart_service_spec.rb +9 -9
  430. data/spec/unit/provider/subversion_spec.rb +1 -1
  431. data/spec/unit/provider/template_spec.rb +35 -11
  432. data/spec/unit/provider/user/dscl_spec.rb +285 -681
  433. data/spec/unit/provider/user/useradd_spec.rb +1 -22
  434. data/spec/unit/provider/user_spec.rb +1 -1
  435. data/spec/unit/recipe_spec.rb +10 -8
  436. data/spec/unit/registry_helper_spec.rb +374 -0
  437. data/spec/unit/resource/mount_spec.rb +0 -11
  438. data/spec/unit/resource/registry_key_spec.rb +171 -0
  439. data/spec/unit/resource/remote_file_spec.rb +21 -23
  440. data/spec/unit/resource/ruby_block_spec.rb +7 -3
  441. data/spec/unit/resource/service_spec.rb +11 -0
  442. data/spec/unit/resource_spec.rb +4 -19
  443. data/spec/unit/rest/auth_credentials_spec.rb +2 -19
  444. data/spec/unit/rest_spec.rb +130 -284
  445. data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
  446. data/spec/unit/run_context_spec.rb +18 -4
  447. data/spec/unit/run_list_spec.rb +0 -209
  448. data/spec/unit/run_lock_spec.rb +37 -0
  449. data/spec/unit/runner_spec.rb +101 -2
  450. data/spec/unit/scan_access_control_spec.rb +4 -4
  451. data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
  452. data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
  453. data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +14 -69
  454. data/spec/unit/shell_out_spec.rb +18 -0
  455. data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
  456. metadata +275 -234
  457. checksums.yaml +0 -15
  458. data/README.rdoc +0 -177
  459. data/distro/common/html/knife-recipe.1.html +0 -92
  460. data/lib/chef/certificate.rb +0 -161
  461. data/lib/chef/checksum.rb +0 -167
  462. data/lib/chef/checksum_cache.rb +0 -190
  463. data/lib/chef/cookbook_version_selector.rb +0 -168
  464. data/lib/chef/couchdb.rb +0 -246
  465. data/lib/chef/index_queue/amqp_client.rb +0 -116
  466. data/lib/chef/index_queue/consumer.rb +0 -76
  467. data/lib/chef/index_queue/indexable.rb +0 -109
  468. data/lib/chef/knife/bootstrap/ubuntu12.10-gems.erb +0 -60
  469. data/lib/chef/monkey_patches/moneta.rb +0 -50
  470. data/lib/chef/monkey_patches/uri.rb +0 -70
  471. data/lib/chef/openid_registration.rb +0 -187
  472. data/lib/chef/provider/user/solaris.rb +0 -90
  473. data/lib/chef/solr_query.rb +0 -187
  474. data/lib/chef/solr_query/lucene.treetop +0 -150
  475. data/lib/chef/solr_query/lucene_nodes.rb +0 -285
  476. data/lib/chef/solr_query/query_transform.rb +0 -65
  477. data/lib/chef/solr_query/solr_http_request.rb +0 -132
  478. data/lib/chef/webui_user.rb +0 -231
  479. data/spec/data/cookbooks/openldap/files/default/.dotfile +0 -1
  480. data/spec/data/cookbooks/openldap/files/default/.ssh/id_rsa +0 -1
  481. data/spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir +0 -1
  482. data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile +0 -1
  483. data/spec/data/mac_users/10.7-8.plist.xml +0 -559
  484. data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
  485. data/spec/data/mac_users/10.7.plist.xml +0 -559
  486. data/spec/data/mac_users/10.7.shadow.xml +0 -11
  487. data/spec/data/mac_users/10.8.plist.xml +0 -559
  488. data/spec/data/mac_users/10.8.shadow.xml +0 -21
  489. data/spec/data/mac_users/10.9.plist.xml +0 -560
  490. data/spec/data/mac_users/10.9.shadow.xml +0 -21
  491. data/spec/functional/resource/base.rb +0 -40
  492. data/spec/functional/resource/group_spec.rb +0 -343
  493. data/spec/functional/resource/user/dscl_spec.rb +0 -199
  494. data/spec/unit/certificate_spec.rb +0 -76
  495. data/spec/unit/checksum_cache_spec.rb +0 -209
  496. data/spec/unit/checksum_spec.rb +0 -94
  497. data/spec/unit/couchdb_spec.rb +0 -274
  498. data/spec/unit/index_queue_spec.rb +0 -391
  499. data/spec/unit/mixin/language_spec.rb +0 -305
  500. data/spec/unit/openid_registration_spec.rb +0 -153
  501. data/spec/unit/provider/user/solaris_spec.rb +0 -414
  502. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +0 -47
  503. data/spec/unit/solr_query/query_transform_spec.rb +0 -454
  504. data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
  505. data/spec/unit/solr_query_spec.rb +0 -203
  506. 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)
@@ -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)
@@ -230,50 +230,6 @@ EOF
230
230
  lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
231
231
  end
232
232
 
233
- it "should find the candidate_version if a category is specifed and there are category duplicates" do
234
- output = <<EOF
235
- Searching...
236
- [ Results for search key : git ]
237
- [ Applications found : 14 ]
238
-
239
- * app-misc/digitemp [ Masked ]
240
- Latest version available: 3.5.0
241
- Latest version installed: [ Not Installed ]
242
- Size of files: 261 kB
243
- Homepage: http://www.digitemp.com/ http://www.ibutton.com/
244
- Description: Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol
245
- License: GPL-2
246
-
247
- * app-misc/git
248
- Latest version available: 4.3.20
249
- Latest version installed: [ Not Installed ]
250
- Size of files: 416 kB
251
- Homepage: http://www.gnu.org/software/git/
252
- Description: GNU Interactive Tools - increase speed and efficiency of most daily task
253
- License: GPL-2
254
-
255
- * dev-util/git
256
- Latest version available: 1.6.0.6
257
- Latest version installed: ignore
258
- Size of files: 2,725 kB
259
- Homepage: http://git.or.cz/
260
- Description: GIT - the stupid content tracker, the revision control system heavily used by the Linux kernel team
261
- License: GPL-2
262
-
263
- * dev-util/gitosis [ Masked ]
264
- Latest version available: 0.2_p20080825
265
- Latest version installed: [ Not Installed ]
266
- Size of files: 31 kB
267
- Homepage: http://eagain.net/gitweb/?p=gitosis.git;a=summary
268
- Description: gitosis -- software for hosting git repositories
269
- License: GPL-2
270
- EOF
271
-
272
- @status = mock("Status", :exitstatus => 0)
273
- @provider = Chef::Provider::Package::Portage.new(@new_resource, @run_context)
274
- @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status)
275
- @provider.candidate_version.should == "1.6.0.6"
276
- end
277
233
  end
278
234
 
279
235
  describe Chef::Provider::Package::Portage, "install_package" do
@@ -80,18 +80,6 @@ describe Chef::Provider::Package::Rpm do
80
80
  @provider.stub!(:popen4).and_return(status)
81
81
  lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package)
82
82
  end
83
-
84
- it "should not detect the package name as version when not installed" do
85
- @status = double("Status", :exitstatus => -1)
86
- @stdout = StringIO.new("package openssh-askpass is not installed")
87
- @new_resource = Chef::Resource::Package.new("openssh-askpass")
88
- @new_resource.source 'openssh-askpass'
89
- @provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context)
90
- @provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' openssh-askpass").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
91
- @provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' openssh-askpass").and_return(@status)
92
- @provider.load_current_resource
93
- @provider.current_resource.version.should be_nil
94
- end
95
83
  end
96
84
 
97
85
  describe "after the current resource is loaded" do
@@ -95,49 +95,6 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
95
95
  @gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0')).should == Gem::Version.new('1.3.0')
96
96
  end
97
97
 
98
- it "finds a matching gem candidate version on rubygems 2.0.0+" do
99
- dep = Gem::Dependency.new('rspec', '>= 0')
100
- dep_installer = Gem::DependencyInstaller.new
101
- @gem_env.stub!(:dependency_installer).and_return(dep_installer)
102
- best_gem = mock("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org")
103
- available_set = mock("Gem::AvailableSet test double")
104
- available_set.should_receive(:pick_best!)
105
- available_set.should_receive(:set).and_return([best_gem])
106
- dep_installer.should_receive(:find_gems_with_sources).with(dep).and_return(available_set)
107
- @gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0')).should == Gem::Version.new('1.3.0')
108
- end
109
-
110
- context "when rubygems was upgraded from 1.8->2.0" do
111
- # https://github.com/rubygems/rubygems/issues/404
112
- # tl;dr rubygems 1.8 and 2.0 can both be in the load path, which means that
113
- # require "rubygems/format" will load even though rubygems 2.0 doesn't have
114
- # that file.
115
-
116
- before do
117
- if defined?(Gem::Format)
118
- # tests are running under rubygems 1.8, or 2.0 upgraded from 1.8
119
- @remove_gem_format = false
120
- else
121
- Gem.const_set(:Format, Object.new)
122
- @remove_gem_format = true
123
- end
124
- Gem::Package.stub!(:respond_to?).with(:open).and_return(false)
125
- end
126
-
127
- after do
128
- if @remove_gem_format
129
- Gem.send(:remove_const, :Format)
130
- end
131
- end
132
-
133
- it "finds a matching gem candidate version on rubygems 2.0+ with some rubygems 1.8 code loaded" do
134
- package = mock("Gem::Package", :spec => "a gemspec from package")
135
- Gem::Package.should_receive(:new).with("/path/to/package.gem").and_return(package)
136
- @gem_env.spec_from_file("/path/to/package.gem").should == "a gemspec from package"
137
- end
138
-
139
- end
140
-
141
98
  it "gives the candidate version as nil if none is found" do
142
99
  dep = Gem::Dependency.new('rspec', '>= 0')
143
100
  latest = []
@@ -256,7 +213,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
256
213
  it "determines the installed versions of gems from the source index (part2: the unmockening)" do
257
214
  $stdout.stub!(:write)
258
215
  path_to_gem = if windows?
259
- `where gem`.split[1]
216
+ `where gem`.split[-1]
260
217
  else
261
218
  `which gem`.strip
262
219
  end
@@ -39,6 +39,7 @@ describe Chef::Provider::Package::Yum do
39
39
  )
40
40
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
41
41
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
42
+ @stderr = StringIO.new
42
43
  @pid = mock("PID")
43
44
  end
44
45
 
@@ -541,7 +542,7 @@ describe Chef::Provider::Package::Yum do
541
542
  it "should call action_upgrade in the parent if the candidate version is nil" do
542
543
  @provider.load_current_resource
543
544
  @current_resource = Chef::Resource::Package.new('cups')
544
- @provider.candidate_version = nil
545
+ @provider.candidate_version = nil
545
546
  @provider.should_not_receive(:upgrade_package)
546
547
  @provider.action_upgrade
547
548
  end
@@ -599,7 +600,7 @@ describe Chef::Provider::Package::Yum do
599
600
  @provider.stub!(:output_of_command).and_return([@status, "", ""])
600
601
  @provider.should_receive(:output_of_command).once.with(
601
602
  "yum -d0 -e0 -y install emacs-1.0",
602
- {:timeout => Chef::Config[:yum_timeout]}
603
+ {}
603
604
  )
604
605
  @provider.yum_command("yum -d0 -e0 -y install emacs-1.0")
605
606
  end
@@ -609,7 +610,7 @@ describe Chef::Provider::Package::Yum do
609
610
  @provider.stub!(:output_of_command).and_return([@status, "failure failure", "problem problem"])
610
611
  @provider.should_receive(:output_of_command).once.with(
611
612
  "yum -d0 -e0 -y install emacs-1.0",
612
- {:timeout => Chef::Config[:yum_timeout]}
613
+ {}
613
614
  )
614
615
  lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
615
616
  end
@@ -619,7 +620,7 @@ describe Chef::Provider::Package::Yum do
619
620
  @provider.stub!(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
620
621
  @provider.should_receive(:output_of_command).once.with(
621
622
  "yum -d0 -e0 -y install emacs-1.0",
622
- {:timeout => Chef::Config[:yum_timeout]}
623
+ {}
623
624
  )
624
625
  # will still raise an exception, can't stub out the subsequent call
625
626
  lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
@@ -630,7 +631,7 @@ describe Chef::Provider::Package::Yum do
630
631
  @provider.stub!(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
631
632
  @provider.should_receive(:output_of_command).twice.with(
632
633
  "yum -d0 -e0 -y install emacs-1.0",
633
- {:timeout => Chef::Config[:yum_timeout]}
634
+ {}
634
635
  )
635
636
  # will still raise an exception, can't stub out the subsequent call
636
637
  lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
@@ -1154,7 +1155,7 @@ describe Chef::Provider::Package::Yum::RPMDbPackage do
1154
1155
 
1155
1156
  describe "repoid" do
1156
1157
  it "should return the source repository repoid" do
1157
- @rpm_x.repoid.should be == "base"
1158
+ @rpm_x.repoid.should be == "base"
1158
1159
  @rpm_y.repoid.should be == "extras"
1159
1160
  @rpm_z.repoid.should be == "other"
1160
1161
  end
@@ -1543,10 +1544,7 @@ describe Chef::Provider::Package::Yum::YumCache do
1543
1544
  end
1544
1545
 
1545
1546
  before(:each) do
1546
- @stdin = mock("STDIN", :nil_object => true)
1547
- @stdout = mock("STDOUT", :nil_object => true)
1548
-
1549
- @stdout_good = <<EOF
1547
+ yum_dump_good_output = <<EOF
1550
1548
  [option installonlypkgs] kernel kernel-bigmem kernel-enterprise
1551
1549
  erlang-mochiweb 0 1.4.1 5.el5 x86_64 ['erlang-mochiweb = 1.4.1-5.el5', 'mochiweb = 1.4.1-5.el5'] i installed
1552
1550
  zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
@@ -1562,16 +1560,9 @@ znc-extra 0 0.098 1.el5 x86_64 [] a base
1562
1560
  znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1563
1561
  znc-test.beta1 0 0.098 1.el5 x86_64 [] a extras
1564
1562
  znc-test.test.beta1 0 0.098 1.el5 x86_64 [] a base
1565
- EOF
1566
- @stdout_bad_type = <<EOF
1567
- zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1568
- zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] c base
1569
- zlib-devel 0 1.2.3 3 i386 [] a extras
1570
- zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] bad installed
1571
- znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1572
1563
  EOF
1573
1564
 
1574
- @stdout_bad_separators = <<EOF
1565
+ yum_dump_bad_output_separators = <<EOF
1575
1566
  zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1576
1567
  zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] i base bad
1577
1568
  zlib-devel 0 1.2.3 3 i386 [] a extras
@@ -1579,20 +1570,36 @@ bad zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] i installed
1579
1570
  znc-modtcl 0 0.098 1.el5 x86_64 [] a base bad
1580
1571
  EOF
1581
1572
 
1582
- @stdout_no_output = ""
1573
+ yum_dump_bad_output_type = <<EOF
1574
+ zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1575
+ zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] c base
1576
+ zlib-devel 0 1.2.3 3 i386 [] a extras
1577
+ zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] bad installed
1578
+ znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1579
+ EOF
1583
1580
 
1584
- @stderr = <<EOF
1581
+ yum_dump_error = <<EOF
1585
1582
  yum-dump Config Error: File contains no section headers.
1586
1583
  file: file://///etc/yum.repos.d/CentOS-Base.repo, line: 12
1587
1584
  'qeqwewe\n'
1588
1585
  EOF
1589
- @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_good, :stderr => @stderr)
1586
+
1587
+ @status = mock("Status", :exitstatus => 0)
1588
+ @status_bad = mock("Status", :exitstatus => 1)
1589
+ @stdin = mock("STDIN", :nil_object => true)
1590
+ @stdout = mock("STDOUT", :nil_object => true)
1591
+ @stdout_good = yum_dump_good_output.split("\n")
1592
+ @stdout_bad_type = yum_dump_bad_output_type.split("\n")
1593
+ @stdout_bad_separators = yum_dump_bad_output_separators.split("\n")
1594
+ @stderr = mock("STDERR", :nil_object => true)
1595
+ @stderr.stub!(:readlines).and_return(yum_dump_error.split("\n"))
1596
+ @pid = mock("PID", :nil_object => true)
1590
1597
 
1591
1598
  # new singleton each time
1592
1599
  Chef::Provider::Package::Yum::YumCache.reset_instance
1593
1600
  @yc = Chef::Provider::Package::Yum::YumCache.instance
1594
1601
  # load valid data
1595
- @yc.stub!(:shell_out!).and_return(@status)
1602
+ @yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_good, @stderr).and_return(@status)
1596
1603
  end
1597
1604
 
1598
1605
  describe "initialize" do
@@ -1611,7 +1618,7 @@ EOF
1611
1618
 
1612
1619
  describe "refresh" do
1613
1620
  it "should implicitly call yum-dump.py only once by default after being instantiated" do
1614
- @yc.should_receive(:shell_out!).once
1621
+ @yc.should_receive(:popen4).once
1615
1622
  @yc.installed_version("zlib")
1616
1623
  @yc.reset
1617
1624
  @yc.installed_version("zlib")
@@ -1619,52 +1626,48 @@ EOF
1619
1626
 
1620
1627
  it "should run yum-dump.py using the system python when next_refresh is for :all" do
1621
1628
  @yc.reload
1622
- @yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides$}, :timeout=>Chef::Config[:yum_timeout])
1629
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides$}, :waitlast=>true)
1623
1630
  @yc.refresh
1624
1631
  end
1625
1632
 
1626
1633
  it "should run yum-dump.py with the installed flag when next_refresh is for :installed" do
1627
1634
  @yc.reload_installed
1628
- @yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed$}, :timeout=>Chef::Config[:yum_timeout])
1635
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --installed$}, :waitlast=>true)
1629
1636
  @yc.refresh
1630
1637
  end
1631
1638
 
1632
1639
  it "should run yum-dump.py with the all-provides flag when next_refresh is for :provides" do
1633
1640
  @yc.reload_provides
1634
- @yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides$}, :timeout=>Chef::Config[:yum_timeout])
1641
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides$}, :waitlast=>true)
1635
1642
  @yc.refresh
1636
1643
  end
1637
1644
 
1638
1645
  it "should pass extra_repo_control args to yum-dump.py" do
1639
1646
  @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
1640
- @yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :timeout=>Chef::Config[:yum_timeout])
1647
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :waitlast=>true)
1641
1648
  @yc.refresh
1642
1649
  end
1643
1650
 
1644
1651
  it "should warn about invalid data with too many separators" do
1645
- @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_separators, :stderr => @stderr)
1646
- @yc.stub!(:shell_out!).and_return(@status)
1652
+ @yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_separators, @stderr).and_return(@status)
1647
1653
  Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
1648
1654
  @yc.refresh
1649
1655
  end
1650
1656
 
1651
1657
  it "should warn about invalid data with an incorrect type" do
1652
- @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_type, :stderr => @stderr)
1653
- @yc.stub!(:shell_out!).and_return(@status)
1658
+ @yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_type, @stderr).and_return(@status)
1654
1659
  Chef::Log.should_receive(:warn).exactly(2).times.with(%r{Problem parsing})
1655
1660
  @yc.refresh
1656
1661
  end
1657
1662
 
1658
1663
  it "should warn about no output from yum-dump.py" do
1659
- @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr)
1660
- @yc.stub!(:shell_out!).and_return(@status)
1664
+ @yc.stub!(:popen4).and_yield(@pid, @stdin, [], @stderr).and_return(@status)
1661
1665
  Chef::Log.should_receive(:warn).exactly(1).times.with(%r{no output from yum-dump.py})
1662
1666
  @yc.refresh
1663
1667
  end
1664
1668
 
1665
1669
  it "should raise exception yum-dump.py exits with a non zero status" do
1666
- @status = mock("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr)
1667
- @yc.stub!(:shell_out!).and_return(@status)
1670
+ @yc.stub!(:popen4).and_yield(@pid, @stdin, [], @stderr).and_return(@status_bad)
1668
1671
  lambda { @yc.refresh}.should raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12})
1669
1672
  end
1670
1673
 
@@ -1789,7 +1792,7 @@ EOF
1789
1792
  end
1790
1793
 
1791
1794
  it "should return nil when no match for package-version, no arch" do
1792
- @yc.package_repository("zisofs-tools", "pretend", nil).should be == nil
1795
+ @yc.package_repository("zisofs-tools", "pretend", nil).should be == nil
1793
1796
  @yc.package_repository("zisofs-tools", "pretend").should be == nil
1794
1797
  @yc.package_repository("pretend", "1.0.6-3.2.2").should be == nil
1795
1798
  end
@@ -346,11 +346,13 @@ describe Chef::Provider::Package do
346
346
  Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, @cookbook_repo) }
347
347
 
348
348
  @node = Chef::Node.new
349
- @cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
349
+ cl = Chef::CookbookLoader.new(@cookbook_repo)
350
+ cl.load_cookbooks
351
+ @cookbook_collection = Chef::CookbookCollection.new(cl)
350
352
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
351
353
 
352
- @node[:platform] = 'PLATFORM: just testing'
353
- @node[:platform_version] = 'PLATFORM VERSION: just testing'
354
+ @node.automatic_attrs[:platform] = 'PLATFORM: just testing'
355
+ @node.automatic_attrs[:platform_version] = 'PLATFORM VERSION: just testing'
354
356
 
355
357
  @new_resource.response_file('java.response')
356
358
  @new_resource.cookbook_name = 'java'
@@ -386,8 +388,8 @@ describe Chef::Provider::Package do
386
388
 
387
389
  describe "when installing the preseed file to the cache location" do
388
390
  before do
389
- @node[:platform] = :just_testing
390
- @node[:platform_version] = :just_testing
391
+ @node.automatic_attrs[:platform] = :just_testing
392
+ @node.automatic_attrs[:platform_version] = :just_testing
391
393
 
392
394
  @response_file_destination = Dir.tmpdir + '/preseed--java--java-6.seed'
393
395
 
@@ -0,0 +1,269 @@
1
+ #
2
+ # Author:: Lamont Granquist (lamont@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(:testval1) { { :name => "one", :type => :string, :data => "1" } }
24
+ let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
25
+ let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
26
+ let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
27
+ let(:testkey1) { 'HKLM\Software\Opscode\Testing' }
28
+
29
+ before(:each) do
30
+ @node = Chef::Node.new
31
+ @events = Chef::EventDispatch::Dispatcher.new
32
+ @run_context = Chef::RunContext.new(@node, {}, @events)
33
+
34
+ @new_resource = Chef::Resource::RegistryKey.new("windows is fun", @run_context)
35
+ @new_resource.key testkey1
36
+ @new_resource.values( testval1 )
37
+ @new_resource.recursive false
38
+
39
+ @provider = Chef::Provider::RegistryKey.new(@new_resource, @run_context)
40
+
41
+ @provider.stub!(:running_on_windows!).and_return(true)
42
+ @double_registry = double(Chef::Win32::Registry)
43
+ @provider.stub!(:registry).and_return(@double_registry)
44
+ end
45
+
46
+ describe "when first created" do
47
+ end
48
+
49
+ describe "executing load_current_resource" do
50
+ describe "when the key exists" do
51
+ before(:each) do
52
+ @double_registry.should_receive(:key_exists?).with(testkey1).and_return(true)
53
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
54
+ @provider.load_current_resource
55
+ end
56
+
57
+ it "should set the key of the current resource to the key of the new resource" do
58
+ @provider.current_resource.key.should == @new_resource.key
59
+ end
60
+
61
+ it "should set the architecture of the current resource to the architecture of the new resource" do
62
+ @provider.current_resource.architecture.should == @new_resource.architecture
63
+ end
64
+
65
+ it "should set the recursive flag of the current resource to the recursive flag of the new resource" do
66
+ @provider.current_resource.recursive.should == @new_resource.recursive
67
+ end
68
+
69
+ it "should set the values of the current resource to the values it got from the registry" do
70
+ @provider.current_resource.values.should == [ testval2 ]
71
+ end
72
+ end
73
+
74
+ describe "when the key does not exist" do
75
+ before(:each) do
76
+ @double_registry.should_receive(:key_exists?).with(testkey1).and_return(false)
77
+ @provider.load_current_resource
78
+ end
79
+
80
+ it "should set the values in the current resource to empty array" do
81
+ @provider.current_resource.values.should == []
82
+ end
83
+ end
84
+ end
85
+
86
+ describe "action_create" do
87
+ context "when the key exists" do
88
+ before(:each) do
89
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
90
+ end
91
+ it "should do nothing if the key and the value both exist" do
92
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
93
+ @double_registry.should_not_receive(:set_value)
94
+ @provider.load_current_resource
95
+ @provider.action_create
96
+ end
97
+ it "should create the value if the key exists but the value does not" do
98
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
99
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
100
+ @provider.load_current_resource
101
+ @provider.action_create
102
+ end
103
+ it "should set the value if the key exists but the data does not match" do
104
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
105
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
106
+ @provider.load_current_resource
107
+ @provider.action_create
108
+ end
109
+ it "should set the value if the key exists but the type does not match" do
110
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
111
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
112
+ @provider.load_current_resource
113
+ @provider.action_create
114
+ end
115
+ end
116
+ context "when the key exists and the values in the new resource are empty" do
117
+ it "when a value is in the key, it should do nothing" do
118
+ @provider.new_resource.values([])
119
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
120
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
121
+ @double_registry.should_not_receive(:create_key)
122
+ @double_registry.should_not_receive(:set_value)
123
+ @provider.load_current_resource
124
+ @provider.action_create
125
+ end
126
+ it "when no value is in the key, it should do nothing" do
127
+ @provider.new_resource.values([])
128
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
129
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( nil )
130
+ @double_registry.should_not_receive(:create_key)
131
+ @double_registry.should_not_receive(:set_value)
132
+ @provider.load_current_resource
133
+ @provider.action_create
134
+ end
135
+ end
136
+ context "when the key does not exist" do
137
+ before(:each) do
138
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
139
+ end
140
+ it "should create the key and the value" do
141
+ @double_registry.should_receive(:create_key).with(testkey1, false)
142
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
143
+ @provider.load_current_resource
144
+ @provider.action_create
145
+ end
146
+ end
147
+ context "when the key does not exist and the values in the new resource are empty" do
148
+ it "should create the key" do
149
+ @new_resource.values([])
150
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
151
+ @double_registry.should_receive(:create_key).with(testkey1, false)
152
+ @double_registry.should_not_receive(:set_value)
153
+ @provider.load_current_resource
154
+ @provider.action_create
155
+ end
156
+ end
157
+ end
158
+
159
+ describe "action_create_if_missing" do
160
+ context "when the key exists" do
161
+ before(:each) do
162
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
163
+ end
164
+ it "should do nothing if the key and the value both exist" do
165
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
166
+ @double_registry.should_not_receive(:set_value)
167
+ @provider.load_current_resource
168
+ @provider.action_create_if_missing
169
+ end
170
+ it "should create the value if the key exists but the value does not" do
171
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
172
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
173
+ @provider.load_current_resource
174
+ @provider.action_create_if_missing
175
+ end
176
+ it "should not set the value if the key exists but the data does not match" do
177
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
178
+ @double_registry.should_not_receive(:set_value)
179
+ @provider.load_current_resource
180
+ @provider.action_create_if_missing
181
+ end
182
+ it "should not set the value if the key exists but the type does not match" do
183
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
184
+ @double_registry.should_not_receive(:set_value)
185
+ @provider.load_current_resource
186
+ @provider.action_create_if_missing
187
+ end
188
+ end
189
+ context "when the key does not exist" do
190
+ before(:each) do
191
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
192
+ end
193
+ it "should create the key and the value" do
194
+ @double_registry.should_receive(:create_key).with(testkey1, false)
195
+ @double_registry.should_receive(:set_value).with(testkey1, testval1)
196
+ @provider.load_current_resource
197
+ @provider.action_create_if_missing
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "action_delete" do
203
+ context "when the key exists" do
204
+ before(:each) do
205
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
206
+ end
207
+ it "deletes the value when the value exists" do
208
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
209
+ @double_registry.should_receive(:delete_value).with(testkey1, testval1)
210
+ @provider.load_current_resource
211
+ @provider.action_delete
212
+ end
213
+ it "deletes the value when the value exists, but the type is wrong" do
214
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
215
+ @double_registry.should_receive(:delete_value).with(testkey1, testval1)
216
+ @provider.load_current_resource
217
+ @provider.action_delete
218
+ end
219
+ it "deletes the value when the value exists, but the data is wrong" do
220
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
221
+ @double_registry.should_receive(:delete_value).with(testkey1, testval1)
222
+ @provider.load_current_resource
223
+ @provider.action_delete
224
+ end
225
+ it "does not delete the value when the value does not exist" do
226
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
227
+ @double_registry.should_not_receive(:delete_value)
228
+ @provider.load_current_resource
229
+ @provider.action_delete
230
+ end
231
+ end
232
+ context "when the key does not exist" do
233
+ before(:each) do
234
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
235
+ end
236
+ it "does nothing" do
237
+ @double_registry.should_not_receive(:delete_value)
238
+ @provider.load_current_resource
239
+ @provider.action_delete
240
+ end
241
+ end
242
+ end
243
+
244
+ describe "action_delete_key" do
245
+ context "when the key exists" do
246
+ before(:each) do
247
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
248
+ end
249
+ it "deletes the key" do
250
+ @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
251
+ @double_registry.should_receive(:delete_key).with(testkey1, false)
252
+ @provider.load_current_resource
253
+ @provider.action_delete_key
254
+ end
255
+ end
256
+ context "when the key does not exist" do
257
+ before(:each) do
258
+ @double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
259
+ end
260
+ it "does nothing" do
261
+ @double_registry.should_not_receive(:delete_key)
262
+ @provider.load_current_resource
263
+ @provider.action_delete_key
264
+ end
265
+ end
266
+ end
267
+
268
+ end
269
+