chef 12.0.3 → 12.1.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (655) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +4 -1
  3. data/README.md +42 -18
  4. data/distro/common/html/_sources/ctl_chef_client.txt +1 -1
  5. data/distro/common/html/_sources/ctl_chef_server.txt +53 -35
  6. data/distro/common/html/_sources/ctl_chef_solo.txt +1 -1
  7. data/distro/common/html/_sources/knife_bootstrap.txt +1 -1
  8. data/distro/common/html/_sources/knife_cookbook_site.txt +1 -1
  9. data/distro/common/html/_sources/knife_data_bag.txt +4 -4
  10. data/distro/common/html/_sources/knife_status.txt +1 -1
  11. data/distro/common/html/_static/searchtools.js +1 -1
  12. data/distro/common/html/ctl_chef_client.html +55 -7
  13. data/distro/common/html/ctl_chef_server.html +84 -41
  14. data/distro/common/html/ctl_chef_shell.html +45 -1
  15. data/distro/common/html/ctl_chef_solo.html +51 -5
  16. data/distro/common/html/index.html +2 -2
  17. data/distro/common/html/knife.html +1 -1
  18. data/distro/common/html/knife_bootstrap.html +30 -10
  19. data/distro/common/html/knife_cookbook_site.html +2 -0
  20. data/distro/common/html/knife_data_bag.html +4 -4
  21. data/distro/common/html/knife_node.html +2 -2
  22. data/distro/common/html/knife_raw.html +1 -1
  23. data/distro/common/html/knife_role.html +1 -1
  24. data/distro/common/html/knife_search.html +3 -3
  25. data/distro/common/html/knife_status.html +4 -0
  26. data/distro/common/html/searchindex.js +1 -1
  27. data/distro/common/man/man1/chef-shell.1 +72 -1
  28. data/distro/common/man/man1/knife-bootstrap.1 +71 -63
  29. data/distro/common/man/man1/knife-client.1 +1 -1
  30. data/distro/common/man/man1/knife-configure.1 +1 -1
  31. data/distro/common/man/man1/knife-cookbook-site.1 +4 -1
  32. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  33. data/distro/common/man/man1/knife-data-bag.1 +5 -5
  34. data/distro/common/man/man1/knife-delete.1 +1 -1
  35. data/distro/common/man/man1/knife-deps.1 +1 -1
  36. data/distro/common/man/man1/knife-diff.1 +1 -1
  37. data/distro/common/man/man1/knife-download.1 +1 -1
  38. data/distro/common/man/man1/knife-edit.1 +1 -1
  39. data/distro/common/man/man1/knife-environment.1 +1 -1
  40. data/distro/common/man/man1/knife-exec.1 +1 -1
  41. data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
  42. data/distro/common/man/man1/knife-list.1 +1 -1
  43. data/distro/common/man/man1/knife-node.1 +3 -3
  44. data/distro/common/man/man1/knife-raw.1 +2 -2
  45. data/distro/common/man/man1/knife-recipe-list.1 +1 -1
  46. data/distro/common/man/man1/knife-role.1 +2 -2
  47. data/distro/common/man/man1/knife-search.1 +4 -4
  48. data/distro/common/man/man1/knife-serve.1 +1 -1
  49. data/distro/common/man/man1/knife-show.1 +1 -1
  50. data/distro/common/man/man1/knife-ssh.1 +1 -1
  51. data/distro/common/man/man1/knife-ssl-check.1 +1 -1
  52. data/distro/common/man/man1/knife-ssl-fetch.1 +1 -1
  53. data/distro/common/man/man1/knife-status.1 +1 -1
  54. data/distro/common/man/man1/knife-tag.1 +1 -1
  55. data/distro/common/man/man1/knife-upload.1 +1 -1
  56. data/distro/common/man/man1/knife-user.1 +1 -1
  57. data/distro/common/man/man1/knife-xargs.1 +1 -1
  58. data/distro/common/man/man1/knife.1 +1 -1
  59. data/distro/common/man/man8/chef-apply.8 +86 -0
  60. data/distro/common/man/man8/chef-client.8 +76 -5
  61. data/distro/common/man/man8/chef-solo.8 +79 -6
  62. data/distro/common/markdown/man1/knife-bootstrap.mkd +1 -1
  63. data/distro/common/markdown/man1/knife-cookbook-site.mkd +1 -1
  64. data/distro/common/markdown/man1/knife-data-bag.mkd +1 -1
  65. data/distro/common/markdown/man1/knife-environment.mkd +1 -1
  66. data/distro/common/markdown/man1/knife.mkd +1 -1
  67. data/lib/chef.rb +0 -7
  68. data/lib/chef/api_client.rb +10 -2
  69. data/lib/chef/api_client/registration.rb +7 -9
  70. data/lib/chef/application.rb +28 -12
  71. data/lib/chef/application/apply.rb +17 -1
  72. data/lib/chef/application/client.rb +74 -6
  73. data/lib/chef/application/knife.rb +1 -2
  74. data/lib/chef/application/solo.rb +30 -0
  75. data/lib/chef/application/windows_service.rb +1 -0
  76. data/lib/chef/application/windows_service_manager.rb +8 -2
  77. data/lib/chef/applications.rb +0 -1
  78. data/lib/chef/audit/audit_event_proxy.rb +93 -0
  79. data/lib/chef/audit/audit_reporter.rb +169 -0
  80. data/lib/chef/audit/control_group_data.rb +140 -0
  81. data/lib/chef/audit/rspec_formatter.rb +37 -0
  82. data/lib/chef/audit/runner.rb +178 -0
  83. data/lib/chef/chef_fs/chef_fs_data_store.rb +11 -2
  84. data/lib/chef/chef_fs/config.rb +25 -4
  85. data/lib/chef/chef_fs/data_handler/policy_data_handler.rb +15 -0
  86. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -0
  87. data/lib/chef/chef_fs/file_system.rb +1 -1
  88. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +5 -0
  89. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +3 -2
  90. data/lib/chef/{shef/ext.rb → chef_fs/file_system/chef_repository_file_system_policies_dir.rb} +22 -3
  91. data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +4 -0
  92. data/lib/chef/client.rb +81 -52
  93. data/lib/chef/config.rb +35 -3
  94. data/lib/chef/cookbook/metadata.rb +3 -3
  95. data/lib/chef/cookbook_manifest.rb +275 -0
  96. data/lib/chef/cookbook_site_streaming_uploader.rb +24 -23
  97. data/lib/chef/cookbook_uploader.rb +11 -2
  98. data/lib/chef/cookbook_version.rb +71 -194
  99. data/lib/chef/data_bag.rb +5 -2
  100. data/lib/chef/data_bag_item.rb +6 -3
  101. data/lib/chef/deprecation/warnings.rb +5 -4
  102. data/lib/chef/dsl/audit.rb +51 -0
  103. data/lib/chef/dsl/include_recipe.rb +2 -3
  104. data/lib/chef/dsl/reboot_pending.rb +1 -1
  105. data/lib/chef/dsl/recipe.rb +49 -31
  106. data/lib/chef/encrypted_data_bag_item/assertions.rb +0 -3
  107. data/lib/chef/environment.rb +5 -2
  108. data/lib/chef/event_dispatch/base.rb +36 -1
  109. data/lib/chef/event_dispatch/dispatcher.rb +3 -5
  110. data/lib/chef/exceptions.rb +61 -2
  111. data/lib/chef/file_access_control/unix.rb +12 -0
  112. data/lib/chef/file_access_control/windows.rb +14 -0
  113. data/lib/chef/formatters/doc.rb +47 -1
  114. data/{spec/unit/monkey_patches/string_spec.rb → lib/chef/guard_interpreter.rb} +11 -16
  115. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -2
  116. data/lib/chef/http.rb +1 -2
  117. data/lib/chef/knife.rb +5 -3
  118. data/lib/chef/knife/bootstrap.rb +84 -15
  119. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +165 -0
  120. data/lib/chef/knife/bootstrap/client_builder.rb +190 -0
  121. data/lib/chef/knife/bootstrap/{README.md → templates/README.md} +0 -0
  122. data/lib/chef/knife/bootstrap/{archlinux-gems.erb → templates/archlinux-gems.erb} +9 -0
  123. data/lib/chef/knife/bootstrap/{chef-aix.erb → templates/chef-aix.erb} +9 -0
  124. data/lib/chef/knife/bootstrap/{chef-full.erb → templates/chef-full.erb} +10 -1
  125. data/lib/chef/knife/client_create.rb +8 -7
  126. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  127. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  128. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  129. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  130. data/lib/chef/knife/cookbook_site_share.rb +39 -28
  131. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  132. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  133. data/lib/chef/knife/cookbook_test.rb +1 -0
  134. data/lib/chef/knife/cookbook_upload.rb +13 -8
  135. data/lib/chef/knife/core/bootstrap_context.rb +14 -3
  136. data/lib/chef/knife/core/generic_presenter.rb +5 -2
  137. data/lib/chef/knife/core/object_loader.rb +1 -1
  138. data/lib/chef/knife/core/subcommand_loader.rb +24 -0
  139. data/lib/chef/knife/core/ui.rb +9 -1
  140. data/lib/chef/knife/node_run_list_remove.rb +11 -3
  141. data/lib/chef/knife/raw.rb +14 -3
  142. data/lib/chef/knife/role_env_run_list_add.rb +86 -0
  143. data/lib/chef/knife/role_env_run_list_clear.rb +55 -0
  144. data/lib/chef/knife/role_env_run_list_remove.rb +57 -0
  145. data/lib/chef/knife/role_env_run_list_replace.rb +59 -0
  146. data/lib/chef/knife/role_env_run_list_set.rb +70 -0
  147. data/lib/chef/knife/role_run_list_add.rb +86 -0
  148. data/lib/chef/knife/role_run_list_clear.rb +55 -0
  149. data/lib/chef/knife/role_run_list_remove.rb +57 -0
  150. data/lib/chef/knife/role_run_list_replace.rb +59 -0
  151. data/lib/chef/knife/role_run_list_set.rb +70 -0
  152. data/lib/chef/knife/search.rb +4 -4
  153. data/lib/chef/knife/serve.rb +3 -0
  154. data/lib/chef/knife/ssh.rb +1 -1
  155. data/lib/chef/knife/ssl_check.rb +2 -2
  156. data/lib/chef/knife/ssl_fetch.rb +14 -1
  157. data/lib/chef/log.rb +10 -1
  158. data/lib/chef/mixin/command.rb +1 -1
  159. data/lib/chef/mixin/command/windows.rb +1 -5
  160. data/lib/chef/mixin/get_source_from_package.rb +1 -0
  161. data/lib/chef/mixin/params_validate.rb +2 -2
  162. data/lib/chef/mixin/securable.rb +1 -7
  163. data/lib/chef/mixin/shell_out.rb +7 -1
  164. data/lib/chef/mixin/template.rb +2 -14
  165. data/lib/chef/mixin/why_run.rb +1 -1
  166. data/lib/chef/monkey_patches/net_http.rb +4 -0
  167. data/lib/chef/monologger.rb +0 -2
  168. data/lib/chef/node.rb +5 -2
  169. data/lib/chef/node/attribute.rb +11 -9
  170. data/lib/chef/node/attribute_collections.rb +8 -12
  171. data/lib/chef/node/immutable_collections.rb +4 -10
  172. data/lib/chef/org.rb +148 -0
  173. data/lib/chef/platform/provider_mapping.rb +3 -2
  174. data/lib/chef/platform/provider_priority_map.rb +2 -0
  175. data/lib/chef/platform/query_helpers.rb +0 -3
  176. data/lib/chef/policy_builder/policyfile.rb +51 -8
  177. data/lib/chef/provider/deploy.rb +1 -2
  178. data/lib/chef/provider/directory.rb +3 -3
  179. data/lib/chef/provider/dsc_script.rb +13 -7
  180. data/lib/chef/provider/env.rb +8 -8
  181. data/lib/chef/provider/execute.rb +55 -36
  182. data/lib/chef/provider/file.rb +8 -0
  183. data/lib/chef/provider/group.rb +2 -0
  184. data/lib/chef/provider/group/dscl.rb +3 -4
  185. data/lib/chef/provider/ifconfig.rb +25 -25
  186. data/lib/chef/provider/ifconfig/aix.rb +25 -27
  187. data/lib/chef/provider/lwrp_base.rb +1 -1
  188. data/lib/chef/provider/mount.rb +2 -2
  189. data/lib/chef/provider/mount/mount.rb +3 -4
  190. data/lib/chef/provider/mount/solaris.rb +1 -1
  191. data/lib/chef/provider/package.rb +297 -48
  192. data/lib/chef/provider/package/aix.rb +25 -30
  193. data/lib/chef/provider/package/apt.rb +63 -19
  194. data/lib/chef/provider/package/dpkg.rb +15 -16
  195. data/lib/chef/provider/package/macports.rb +7 -7
  196. data/lib/chef/provider/package/openbsd.rb +107 -0
  197. data/lib/chef/provider/package/pacman.rb +13 -15
  198. data/lib/chef/provider/package/portage.rb +3 -4
  199. data/lib/chef/provider/package/rpm.rb +28 -17
  200. data/lib/chef/provider/package/rubygems.rb +9 -9
  201. data/lib/chef/provider/package/solaris.rb +17 -21
  202. data/lib/chef/provider/package/windows/msi.rb +1 -1
  203. data/lib/chef/provider/package/yum-dump.py +2 -2
  204. data/lib/chef/provider/package/yum.rb +117 -51
  205. data/lib/chef/provider/package/zypper.rb +17 -18
  206. data/lib/chef/provider/powershell_script.rb +4 -4
  207. data/lib/chef/provider/registry_key.rb +2 -2
  208. data/lib/chef/provider/remote_directory.rb +1 -1
  209. data/lib/chef/provider/script.rb +25 -16
  210. data/lib/chef/provider/service.rb +1 -1
  211. data/lib/chef/provider/service/freebsd.rb +1 -1
  212. data/lib/chef/provider/service/openbsd.rb +216 -0
  213. data/lib/chef/provider/service/upstart.rb +1 -1
  214. data/lib/chef/provider/service/windows.rb +99 -1
  215. data/lib/chef/provider/user.rb +1 -1
  216. data/lib/chef/provider/user/dscl.rb +19 -4
  217. data/lib/chef/providers.rb +2 -0
  218. data/lib/chef/recipe.rb +11 -5
  219. data/lib/chef/request_id.rb +1 -1
  220. data/lib/chef/resource.rb +839 -444
  221. data/lib/chef/resource/chef_gem.rb +20 -3
  222. data/lib/chef/resource/conditional.rb +3 -14
  223. data/lib/chef/resource/dsc_script.rb +14 -0
  224. data/lib/chef/resource/execute.rb +14 -7
  225. data/lib/chef/resource/file.rb +14 -0
  226. data/lib/chef/resource/file/verification.rb +122 -0
  227. data/lib/chef/resource/ips_package.rb +1 -1
  228. data/lib/chef/resource/lwrp_base.rb +2 -11
  229. data/lib/chef/resource/macports_package.rb +2 -1
  230. data/lib/chef/resource/openbsd_package.rb +51 -0
  231. data/lib/chef/resource/package.rb +2 -2
  232. data/lib/chef/resource/paludis_package.rb +1 -1
  233. data/lib/chef/resource/reboot.rb +1 -1
  234. data/lib/chef/resource/remote_file.rb +1 -0
  235. data/lib/chef/resource/rpm_package.rb +9 -0
  236. data/lib/chef/resource/script.rb +11 -0
  237. data/lib/chef/resource/template.rb +2 -3
  238. data/lib/chef/resource/windows_package.rb +1 -1
  239. data/lib/chef/resource/windows_service.rb +18 -0
  240. data/lib/chef/resource_builder.rb +137 -0
  241. data/lib/chef/resource_definition.rb +1 -1
  242. data/lib/chef/resource_reporter.rb +1 -1
  243. data/lib/chef/resources.rb +1 -0
  244. data/lib/chef/role.rb +17 -4
  245. data/lib/chef/run_context.rb +10 -6
  246. data/lib/chef/search/query.rb +66 -87
  247. data/lib/chef/shell/ext.rb +2 -2
  248. data/lib/chef/util/diff.rb +1 -4
  249. data/lib/chef/util/dsc/configuration_generator.rb +30 -6
  250. data/lib/chef/util/dsc/lcm_output_parser.rb +7 -3
  251. data/lib/chef/util/dsc/local_configuration_manager.rb +8 -8
  252. data/lib/chef/util/file_edit.rb +2 -2
  253. data/lib/chef/util/path_helper.rb +1 -4
  254. data/lib/chef/util/windows/net_use.rb +3 -3
  255. data/lib/chef/version.rb +1 -1
  256. data/lib/chef/win32/api.rb +1 -0
  257. data/lib/chef/win32/api/security.rb +26 -0
  258. data/lib/chef/win32/file.rb +21 -0
  259. data/lib/chef/win32/security.rb +46 -0
  260. data/lib/chef/win32/security/token.rb +8 -0
  261. data/lib/chef/win32/version.rb +0 -4
  262. data/spec/data/recipes.tgz +0 -0
  263. data/spec/functional/application_spec.rb +1 -1
  264. data/spec/functional/audit/rspec_formatter_spec.rb +54 -0
  265. data/spec/functional/audit/runner_spec.rb +137 -0
  266. data/spec/functional/dsl/reboot_pending_spec.rb +10 -10
  267. data/spec/functional/dsl/registry_helper_spec.rb +6 -6
  268. data/spec/functional/event_loggers/windows_eventlog_spec.rb +5 -5
  269. data/spec/functional/file_content_management/deploy_strategies_spec.rb +12 -21
  270. data/spec/functional/http/simple_spec.rb +1 -1
  271. data/spec/functional/knife/cookbook_delete_spec.rb +24 -24
  272. data/spec/functional/knife/exec_spec.rb +2 -4
  273. data/spec/functional/knife/smoke_test.rb +1 -1
  274. data/spec/functional/knife/ssh_spec.rb +23 -23
  275. data/spec/functional/provider/remote_file/cache_control_data_spec.rb +8 -8
  276. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  277. data/spec/functional/rebooter_spec.rb +1 -1
  278. data/spec/functional/resource/aix_service_spec.rb +3 -0
  279. data/spec/functional/resource/aixinit_service_spec.rb +3 -3
  280. data/spec/functional/resource/bash_spec.rb +88 -0
  281. data/spec/functional/resource/deploy_revision_spec.rb +99 -100
  282. data/spec/functional/resource/env_spec.rb +3 -3
  283. data/spec/functional/resource/execute_spec.rb +97 -63
  284. data/spec/functional/resource/file_spec.rb +7 -7
  285. data/spec/functional/resource/git_spec.rb +13 -13
  286. data/spec/functional/resource/group_spec.rb +28 -25
  287. data/spec/functional/resource/ifconfig_spec.rb +2 -2
  288. data/spec/functional/resource/link_spec.rb +77 -78
  289. data/spec/functional/resource/mount_spec.rb +5 -5
  290. data/spec/functional/resource/ohai_spec.rb +1 -1
  291. data/spec/functional/resource/package_spec.rb +22 -22
  292. data/spec/functional/resource/powershell_spec.rb +57 -42
  293. data/spec/functional/resource/reboot_spec.rb +2 -2
  294. data/spec/functional/resource/registry_spec.rb +91 -91
  295. data/spec/functional/resource/remote_directory_spec.rb +19 -19
  296. data/spec/functional/resource/remote_file_spec.rb +18 -18
  297. data/spec/functional/resource/template_spec.rb +4 -4
  298. data/spec/functional/resource/user/dscl_spec.rb +4 -4
  299. data/spec/functional/resource/user/useradd_spec.rb +64 -51
  300. data/spec/functional/resource/windows_service_spec.rb +98 -0
  301. data/spec/functional/run_lock_spec.rb +9 -9
  302. data/spec/functional/shell_spec.rb +3 -3
  303. data/spec/functional/tiny_server_spec.rb +12 -12
  304. data/spec/functional/util/path_helper_spec.rb +1 -1
  305. data/spec/functional/version_spec.rb +1 -1
  306. data/spec/functional/win32/registry_helper_spec.rb +125 -125
  307. data/spec/functional/win32/security_spec.rb +65 -2
  308. data/spec/functional/win32/service_manager_spec.rb +30 -84
  309. data/spec/functional/win32/versions_spec.rb +6 -6
  310. data/spec/integration/client/client_spec.rb +102 -9
  311. data/spec/integration/knife/chef_fs_data_store_spec.rb +12 -8
  312. data/spec/integration/knife/common_options_spec.rb +3 -3
  313. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
  314. data/spec/integration/knife/deps_spec.rb +4 -4
  315. data/spec/integration/knife/diff_spec.rb +6 -6
  316. data/spec/integration/knife/download_spec.rb +6 -6
  317. data/spec/integration/knife/list_spec.rb +2 -2
  318. data/spec/integration/knife/raw_spec.rb +5 -5
  319. data/spec/integration/knife/serve_spec.rb +3 -3
  320. data/spec/integration/knife/show_spec.rb +3 -3
  321. data/spec/integration/knife/upload_spec.rb +18 -18
  322. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  323. data/spec/integration/solo/solo_spec.rb +11 -12
  324. data/spec/spec_helper.rb +27 -15
  325. data/spec/stress/win32/file_spec.rb +4 -4
  326. data/spec/stress/win32/security_spec.rb +4 -4
  327. data/spec/support/chef_helpers.rb +3 -3
  328. data/spec/support/matchers/leak.rb +2 -2
  329. data/spec/support/mock/platform.rb +1 -1
  330. data/spec/support/pedant/Gemfile +3 -0
  331. data/spec/support/pedant/pedant_config.rb +9 -2
  332. data/spec/support/pedant/run_pedant.rb +15 -16
  333. data/spec/support/platform_helpers.rb +8 -12
  334. data/spec/support/shared/functional/directory_resource.rb +13 -13
  335. data/spec/support/shared/functional/file_resource.rb +83 -83
  336. data/spec/support/shared/functional/http.rb +1 -1
  337. data/spec/support/shared/functional/securable_resource.rb +64 -64
  338. data/spec/support/shared/functional/securable_resource_with_reporting.rb +43 -41
  339. data/spec/support/shared/functional/win32_service.rb +60 -0
  340. data/spec/support/shared/functional/windows_script.rb +8 -8
  341. data/spec/support/shared/integration/knife_support.rb +8 -5
  342. data/spec/support/shared/matchers/exit_with_code.rb +6 -2
  343. data/spec/support/shared/unit/api_error_inspector.rb +8 -8
  344. data/spec/support/shared/unit/execute_resource.rb +24 -20
  345. data/spec/support/shared/unit/file_system_support.rb +2 -2
  346. data/spec/support/shared/unit/platform_introspector.rb +21 -21
  347. data/spec/support/shared/unit/provider/file.rb +239 -210
  348. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +69 -69
  349. data/spec/support/shared/unit/script_resource.rb +40 -32
  350. data/spec/support/shared/unit/windows_script_resource.rb +8 -8
  351. data/spec/unit/api_client/registration_spec.rb +47 -47
  352. data/spec/unit/api_client_spec.rb +107 -69
  353. data/spec/unit/application/apply_spec.rb +31 -15
  354. data/spec/unit/application/client_spec.rb +146 -45
  355. data/spec/unit/application/knife_spec.rb +31 -31
  356. data/spec/unit/application/solo_spec.rb +59 -43
  357. data/spec/unit/application_spec.rb +109 -74
  358. data/spec/unit/audit/audit_event_proxy_spec.rb +311 -0
  359. data/spec/unit/audit/audit_reporter_spec.rb +393 -0
  360. data/spec/unit/audit/control_group_data_spec.rb +478 -0
  361. data/{lib/chef/monkey_patches/file.rb → spec/unit/audit/rspec_formatter_spec.rb} +11 -8
  362. data/spec/unit/audit/runner_spec.rb +135 -0
  363. data/spec/unit/chef_fs/config_spec.rb +52 -0
  364. data/spec/unit/chef_fs/diff_spec.rb +12 -12
  365. data/spec/unit/chef_fs/file_pattern_spec.rb +276 -277
  366. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +6 -6
  367. data/spec/unit/chef_fs/file_system_spec.rb +26 -13
  368. data/spec/unit/chef_fs/parallelizer.rb +87 -87
  369. data/spec/unit/chef_spec.rb +1 -1
  370. data/spec/unit/client_spec.rb +263 -97
  371. data/spec/unit/config_fetcher_spec.rb +13 -13
  372. data/spec/unit/config_spec.rb +105 -66
  373. data/spec/unit/cookbook/chefignore_spec.rb +6 -6
  374. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +3 -3
  375. data/spec/unit/cookbook/metadata_spec.rb +149 -149
  376. data/spec/unit/cookbook/syntax_check_spec.rb +36 -31
  377. data/spec/unit/cookbook_loader_spec.rb +62 -58
  378. data/spec/unit/cookbook_manifest_spec.rb +141 -468
  379. data/spec/unit/cookbook_site_streaming_uploader_spec.rb +27 -27
  380. data/spec/unit/cookbook_spec.rb +15 -15
  381. data/spec/unit/cookbook_uploader_spec.rb +37 -3
  382. data/spec/unit/cookbook_version_file_specificity_spec.rb +554 -0
  383. data/spec/unit/cookbook_version_spec.rb +98 -240
  384. data/spec/unit/daemon_spec.rb +31 -31
  385. data/spec/unit/data_bag_item_spec.rb +121 -89
  386. data/spec/unit/data_bag_spec.rb +35 -35
  387. data/spec/unit/deprecation_spec.rb +27 -14
  388. data/spec/unit/digester_spec.rb +3 -3
  389. data/spec/unit/dsl/audit_spec.rb +43 -0
  390. data/spec/unit/dsl/data_query_spec.rb +1 -1
  391. data/spec/unit/dsl/platform_introspection_spec.rb +14 -14
  392. data/spec/unit/dsl/reboot_pending_spec.rb +18 -18
  393. data/spec/unit/dsl/regsitry_helper_spec.rb +6 -6
  394. data/spec/unit/encrypted_data_bag_item_spec.rb +58 -82
  395. data/spec/unit/environment_spec.rb +105 -105
  396. data/spec/unit/exceptions_spec.rb +47 -1
  397. data/spec/unit/file_access_control_spec.rb +62 -56
  398. data/spec/unit/file_cache_spec.rb +11 -11
  399. data/spec/unit/file_content_management/deploy/cp_spec.rb +2 -2
  400. data/spec/unit/file_content_management/deploy/mv_unix_spec.rb +10 -10
  401. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +23 -23
  402. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +14 -14
  403. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +12 -12
  404. data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +1 -1
  405. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +16 -16
  406. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +4 -4
  407. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +103 -13
  408. data/spec/unit/guard_interpreter_spec.rb +41 -0
  409. data/spec/unit/handler/json_file_spec.rb +10 -10
  410. data/spec/unit/handler_spec.rb +39 -39
  411. data/spec/unit/http/basic_client_spec.rb +3 -3
  412. data/spec/unit/http/http_request_spec.rb +10 -10
  413. data/spec/unit/http/simple_spec.rb +3 -3
  414. data/spec/unit/http/ssl_policies_spec.rb +15 -15
  415. data/spec/unit/http/validate_content_length_spec.rb +18 -13
  416. data/spec/unit/http_spec.rb +16 -9
  417. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +153 -0
  418. data/spec/unit/knife/bootstrap/client_builder_spec.rb +178 -0
  419. data/spec/unit/knife/bootstrap_spec.rb +144 -91
  420. data/spec/unit/knife/client_bulk_delete_spec.rb +24 -24
  421. data/spec/unit/knife/client_create_spec.rb +57 -43
  422. data/spec/unit/knife/client_delete_spec.rb +15 -15
  423. data/spec/unit/knife/client_edit_spec.rb +4 -4
  424. data/spec/unit/knife/client_list_spec.rb +2 -2
  425. data/spec/unit/knife/client_reregister_spec.rb +9 -9
  426. data/spec/unit/knife/configure_client_spec.rb +20 -20
  427. data/spec/unit/knife/configure_spec.rb +85 -85
  428. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +15 -15
  429. data/spec/unit/knife/cookbook_create_spec.rb +59 -59
  430. data/spec/unit/knife/cookbook_delete_spec.rb +49 -49
  431. data/spec/unit/knife/cookbook_download_spec.rb +56 -56
  432. data/spec/unit/knife/cookbook_list_spec.rb +9 -9
  433. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +8 -8
  434. data/spec/unit/knife/cookbook_metadata_spec.rb +44 -44
  435. data/spec/unit/knife/cookbook_show_spec.rb +29 -29
  436. data/spec/unit/knife/cookbook_site_download_spec.rb +26 -26
  437. data/spec/unit/knife/cookbook_site_install_spec.rb +5 -1
  438. data/spec/unit/knife/cookbook_site_share_spec.rb +68 -59
  439. data/spec/unit/knife/cookbook_site_unshare_spec.rb +15 -15
  440. data/spec/unit/knife/cookbook_test_spec.rb +16 -16
  441. data/spec/unit/knife/cookbook_upload_spec.rb +105 -71
  442. data/spec/unit/knife/core/bootstrap_context_spec.rb +37 -22
  443. data/spec/unit/knife/core/cookbook_scm_repo_spec.rb +36 -36
  444. data/spec/unit/knife/core/object_loader_spec.rb +3 -3
  445. data/spec/unit/knife/core/subcommand_loader_spec.rb +107 -33
  446. data/spec/unit/knife/core/ui_spec.rb +84 -72
  447. data/spec/unit/knife/data_bag_from_file_spec.rb +1 -1
  448. data/spec/unit/knife/environment_compare_spec.rb +12 -12
  449. data/spec/unit/knife/environment_create_spec.rb +16 -16
  450. data/spec/unit/knife/environment_delete_spec.rb +14 -14
  451. data/spec/unit/knife/environment_edit_spec.rb +15 -15
  452. data/spec/unit/knife/environment_from_file_spec.rb +17 -17
  453. data/spec/unit/knife/environment_list_spec.rb +7 -7
  454. data/spec/unit/knife/environment_show_spec.rb +10 -10
  455. data/spec/unit/knife/index_rebuild_spec.rb +17 -17
  456. data/spec/unit/knife/knife_help.rb +24 -24
  457. data/spec/unit/knife/node_bulk_delete_spec.rb +14 -14
  458. data/spec/unit/knife/node_delete_spec.rb +11 -11
  459. data/spec/unit/knife/node_edit_spec.rb +17 -17
  460. data/spec/unit/knife/node_environment_set_spec.rb +12 -12
  461. data/spec/unit/knife/node_from_file_spec.rb +8 -8
  462. data/spec/unit/knife/node_list_spec.rb +9 -9
  463. data/spec/unit/knife/node_run_list_add_spec.rb +29 -29
  464. data/spec/unit/knife/node_run_list_remove_spec.rb +28 -13
  465. data/spec/unit/knife/node_run_list_set_spec.rb +27 -27
  466. data/spec/unit/knife/raw_spec.rb +43 -0
  467. data/spec/unit/knife/role_bulk_delete_spec.rb +12 -12
  468. data/spec/unit/knife/role_create_spec.rb +12 -12
  469. data/spec/unit/knife/role_delete_spec.rb +10 -10
  470. data/spec/unit/knife/role_edit_spec.rb +13 -13
  471. data/spec/unit/knife/role_env_run_list_add_spec.rb +217 -0
  472. data/spec/unit/knife/role_env_run_list_clear_spec.rb +100 -0
  473. data/spec/unit/knife/role_env_run_list_remove_spec.rb +108 -0
  474. data/spec/unit/knife/role_env_run_list_replace_spec.rb +108 -0
  475. data/spec/unit/knife/role_env_run_list_set_spec.rb +102 -0
  476. data/spec/unit/knife/role_from_file_spec.rb +10 -10
  477. data/spec/unit/knife/role_list_spec.rb +7 -7
  478. data/spec/unit/knife/role_run_list_add_spec.rb +179 -0
  479. data/spec/unit/knife/role_run_list_clear_spec.rb +90 -0
  480. data/spec/unit/knife/role_run_list_remove_spec.rb +98 -0
  481. data/spec/unit/knife/role_run_list_replace_spec.rb +101 -0
  482. data/spec/unit/knife/role_run_list_set_spec.rb +92 -0
  483. data/spec/unit/knife/ssh_spec.rb +66 -66
  484. data/spec/unit/knife/ssl_check_spec.rb +27 -27
  485. data/spec/unit/knife/ssl_fetch_spec.rb +45 -12
  486. data/spec/unit/knife/status_spec.rb +5 -5
  487. data/spec/unit/knife/tag_create_spec.rb +5 -5
  488. data/spec/unit/knife/tag_delete_spec.rb +6 -6
  489. data/spec/unit/knife/tag_list_spec.rb +4 -4
  490. data/spec/unit/knife/user_create_spec.rb +18 -18
  491. data/spec/unit/knife/user_delete_spec.rb +4 -4
  492. data/spec/unit/knife/user_edit_spec.rb +7 -7
  493. data/spec/unit/knife/user_list_spec.rb +2 -2
  494. data/spec/unit/knife/user_reregister_spec.rb +10 -10
  495. data/spec/unit/knife/user_show_spec.rb +5 -5
  496. data/spec/unit/knife_spec.rb +36 -36
  497. data/spec/unit/lwrp_spec.rb +63 -39
  498. data/spec/unit/mash_spec.rb +6 -6
  499. data/spec/unit/mixin/checksum_spec.rb +2 -2
  500. data/spec/unit/mixin/command_spec.rb +13 -13
  501. data/spec/unit/mixin/convert_to_class_name_spec.rb +6 -6
  502. data/spec/unit/mixin/deep_merge_spec.rb +49 -49
  503. data/spec/unit/mixin/deprecation_spec.rb +5 -5
  504. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +14 -14
  505. data/spec/unit/mixin/homebrew_user_spec.rb +3 -3
  506. data/spec/unit/mixin/params_validate_spec.rb +71 -71
  507. data/spec/unit/mixin/path_sanity_spec.rb +14 -14
  508. data/spec/unit/mixin/securable_spec.rb +177 -177
  509. data/spec/unit/mixin/shell_out_spec.rb +56 -27
  510. data/spec/unit/mixin/template_spec.rb +31 -31
  511. data/spec/unit/mixin/windows_architecture_helper_spec.rb +5 -5
  512. data/spec/unit/mixin/xml_escape_spec.rb +7 -7
  513. data/spec/unit/monkey_patches/uri_spec.rb +1 -1
  514. data/spec/unit/monologger_spec.rb +3 -3
  515. data/spec/unit/node/attribute_spec.rb +185 -136
  516. data/spec/unit/node/immutable_collections_spec.rb +22 -22
  517. data/spec/unit/node_spec.rb +210 -179
  518. data/spec/unit/org_spec.rb +196 -0
  519. data/spec/unit/platform/query_helpers_spec.rb +5 -5
  520. data/spec/unit/platform_spec.rb +46 -46
  521. data/spec/unit/policy_builder/expand_node_object_spec.rb +17 -18
  522. data/spec/unit/policy_builder/policyfile_spec.rb +159 -71
  523. data/spec/unit/provider/directory_spec.rb +5 -5
  524. data/spec/unit/provider/dsc_script_spec.rb +6 -6
  525. data/spec/unit/provider/env_spec.rb +27 -14
  526. data/spec/unit/provider/execute_spec.rb +139 -68
  527. data/spec/unit/provider/file/content_spec.rb +8 -8
  528. data/spec/unit/provider/git_spec.rb +10 -5
  529. data/spec/unit/provider/group/dscl_spec.rb +8 -11
  530. data/spec/unit/provider/group_spec.rb +13 -13
  531. data/spec/unit/provider/ifconfig/aix_spec.rb +3 -2
  532. data/spec/unit/provider/ifconfig/debian_spec.rb +19 -19
  533. data/spec/unit/provider/ifconfig_spec.rb +2 -2
  534. data/spec/unit/provider/mdadm_spec.rb +2 -2
  535. data/spec/unit/provider/mount/aix_spec.rb +5 -5
  536. data/spec/unit/provider/mount/mount_spec.rb +22 -22
  537. data/spec/unit/provider/mount/solaris_spec.rb +20 -20
  538. data/spec/unit/provider/package/aix_spec.rb +23 -22
  539. data/spec/unit/provider/package/apt_spec.rb +23 -4
  540. data/spec/unit/provider/package/dpkg_spec.rb +14 -15
  541. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  542. data/spec/unit/provider/package/freebsd/port_spec.rb +1 -1
  543. data/spec/unit/provider/package/ips_spec.rb +1 -2
  544. data/spec/unit/provider/package/macports_spec.rb +14 -14
  545. data/spec/unit/provider/package/openbsd_spec.rb +66 -0
  546. data/spec/unit/provider/package/pacman_spec.rb +15 -14
  547. data/spec/unit/provider/package/portage_spec.rb +11 -11
  548. data/spec/unit/provider/package/rpm_spec.rb +132 -84
  549. data/spec/unit/provider/package/rubygems_spec.rb +54 -25
  550. data/spec/unit/provider/package/solaris_spec.rb +22 -25
  551. data/spec/unit/provider/package/yum_spec.rb +237 -36
  552. data/spec/unit/provider/package/zypper_spec.rb +9 -12
  553. data/spec/unit/provider/package_spec.rb +276 -2
  554. data/spec/unit/provider/package_spec.rbe +0 -0
  555. data/spec/unit/provider/remote_directory_spec.rb +25 -25
  556. data/spec/unit/provider/remote_file/ftp_spec.rb +3 -3
  557. data/spec/unit/provider/route_spec.rb +3 -3
  558. data/spec/unit/provider/script_spec.rb +61 -43
  559. data/spec/unit/provider/service/aix_service_spec.rb +5 -5
  560. data/spec/unit/provider/service/arch_service_spec.rb +5 -5
  561. data/spec/unit/provider/service/debian_service_spec.rb +8 -8
  562. data/spec/unit/provider/service/freebsd_service_spec.rb +16 -2
  563. data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
  564. data/spec/unit/provider/service/init_service_spec.rb +5 -5
  565. data/spec/unit/provider/service/insserv_service_spec.rb +2 -2
  566. data/spec/unit/provider/service/invokercd_service_spec.rb +5 -5
  567. data/spec/unit/provider/service/macosx_spec.rb +7 -7
  568. data/spec/unit/provider/service/openbsd_service_spec.rb +543 -0
  569. data/spec/unit/provider/service/redhat_spec.rb +4 -4
  570. data/spec/unit/provider/service/simple_service_spec.rb +2 -2
  571. data/spec/unit/provider/service/solaris_smf_service_spec.rb +14 -14
  572. data/spec/unit/provider/service/systemd_service_spec.rb +15 -7
  573. data/spec/unit/provider/service/upstart_service_spec.rb +4 -4
  574. data/spec/unit/provider/service/windows_spec.rb +119 -25
  575. data/spec/unit/provider/service_spec.rb +1 -1
  576. data/spec/unit/provider/user/dscl_spec.rb +38 -30
  577. data/spec/unit/provider/user_spec.rb +1 -1
  578. data/spec/unit/provider_resolver_spec.rb +7 -7
  579. data/spec/unit/provider_spec.rb +23 -23
  580. data/spec/unit/recipe_spec.rb +194 -83
  581. data/spec/unit/registry_helper_spec.rb +143 -143
  582. data/spec/unit/resource/chef_gem_spec.rb +117 -3
  583. data/spec/unit/resource/conditional_action_not_nothing_spec.rb +2 -2
  584. data/spec/unit/resource/conditional_spec.rb +56 -15
  585. data/spec/unit/resource/deploy_spec.rb +2 -2
  586. data/spec/unit/resource/dsc_script_spec.rb +32 -0
  587. data/spec/unit/resource/execute_spec.rb +4 -0
  588. data/spec/unit/resource/file/verification_spec.rb +111 -0
  589. data/spec/unit/resource/file_spec.rb +14 -0
  590. data/spec/unit/resource/openbsd_package_spec.rb +49 -0
  591. data/spec/unit/resource/remote_file_spec.rb +12 -12
  592. data/spec/unit/resource/resource_notification_spec.rb +18 -18
  593. data/spec/unit/resource/rpm_package_spec.rb +12 -0
  594. data/spec/unit/resource/scm_spec.rb +4 -4
  595. data/spec/unit/resource/script_spec.rb +3 -5
  596. data/spec/unit/resource/subversion_spec.rb +1 -1
  597. data/spec/unit/resource_builder_spec.rb +1 -0
  598. data/spec/unit/resource_collection/resource_list_spec.rb +2 -2
  599. data/spec/unit/resource_collection/resource_set_spec.rb +3 -3
  600. data/spec/unit/resource_collection/stepable_iterator_spec.rb +24 -24
  601. data/spec/unit/resource_collection_spec.rb +52 -52
  602. data/spec/unit/resource_definition_spec.rb +1 -1
  603. data/spec/unit/resource_reporter_spec.rb +118 -118
  604. data/spec/unit/resource_spec.rb +131 -125
  605. data/spec/unit/rest/auth_credentials_spec.rb +73 -73
  606. data/spec/unit/rest_spec.rb +12 -12
  607. data/spec/unit/role_spec.rb +85 -84
  608. data/spec/unit/run_context/cookbook_compiler_spec.rb +18 -18
  609. data/spec/unit/run_context_spec.rb +39 -68
  610. data/spec/unit/run_list/run_list_expansion_spec.rb +21 -21
  611. data/spec/unit/run_list/run_list_item_spec.rb +28 -28
  612. data/spec/unit/run_list/versioned_recipe_list_spec.rb +14 -14
  613. data/spec/unit/run_list_spec.rb +55 -55
  614. data/spec/unit/run_lock_spec.rb +14 -14
  615. data/spec/unit/run_status_spec.rb +24 -24
  616. data/spec/unit/scan_access_control_spec.rb +23 -23
  617. data/spec/unit/search/query_spec.rb +54 -66
  618. data/spec/unit/shell/model_wrapper_spec.rb +13 -13
  619. data/spec/unit/shell/shell_ext_spec.rb +32 -32
  620. data/spec/unit/shell/shell_session_spec.rb +24 -24
  621. data/spec/unit/shell_out_spec.rb +4 -4
  622. data/spec/unit/shell_spec.rb +27 -27
  623. data/spec/unit/user_spec.rb +50 -50
  624. data/spec/unit/util/backup_spec.rb +32 -32
  625. data/spec/unit/util/diff_spec.rb +31 -31
  626. data/spec/unit/util/dsc/configuration_generator_spec.rb +38 -16
  627. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +21 -26
  628. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +10 -10
  629. data/spec/unit/util/editor_spec.rb +10 -10
  630. data/spec/unit/util/file_edit_spec.rb +10 -10
  631. data/spec/unit/util/path_helper_spec.rb +38 -46
  632. data/spec/unit/util/powershell/cmdlet_spec.rb +9 -9
  633. data/spec/unit/util/selinux_spec.rb +30 -30
  634. data/spec/unit/util/threaded_job_queue_spec.rb +6 -6
  635. data/spec/unit/version/platform_spec.rb +5 -5
  636. data/spec/unit/version_class_spec.rb +15 -15
  637. data/spec/unit/version_constraint/platform_spec.rb +7 -7
  638. data/spec/unit/version_constraint_spec.rb +43 -43
  639. data/spec/unit/windows_service_spec.rb +15 -15
  640. data/spec/unit/workstation_config_loader_spec.rb +2 -2
  641. data/tasks/rspec.rb +16 -18
  642. metadata +126 -53
  643. data/bin/chef-service-manager +0 -37
  644. data/bin/chef-windows-service +0 -35
  645. data/bin/shef +0 -35
  646. data/lib/chef/application/agent.rb +0 -18
  647. data/lib/chef/monkey_patches/fileutils.rb +0 -65
  648. data/lib/chef/monkey_patches/numeric.rb +0 -15
  649. data/lib/chef/monkey_patches/object.rb +0 -9
  650. data/lib/chef/monkey_patches/pathname.rb +0 -32
  651. data/lib/chef/monkey_patches/regexp.rb +0 -34
  652. data/lib/chef/monkey_patches/securerandom.rb +0 -44
  653. data/lib/chef/monkey_patches/string.rb +0 -49
  654. data/lib/chef/monkey_patches/tempfile.rb +0 -64
  655. data/lib/chef/monkey_patches/uri.rb +0 -70
@@ -30,28 +30,28 @@ describe Chef::Node::ImmutableMash do
30
30
  end
31
31
 
32
32
  it "element references like regular hash" do
33
- @immutable_mash[:top][:second_level].should == "some value"
33
+ expect(@immutable_mash[:top][:second_level]).to eq("some value")
34
34
  end
35
35
 
36
- it "elelment references like a regular Mash" do
37
- @immutable_mash[:top_level_2].should == %w[array of values]
36
+ it "element references like a regular Mash" do
37
+ expect(@immutable_mash[:top_level_2]).to eq(%w[array of values])
38
38
  end
39
39
 
40
40
  it "converts Hash-like inputs into ImmutableMash's" do
41
- @immutable_mash[:top].should be_a(Chef::Node::ImmutableMash)
41
+ expect(@immutable_mash[:top]).to be_a(Chef::Node::ImmutableMash)
42
42
  end
43
43
 
44
44
  it "converts array inputs into ImmutableArray's" do
45
- @immutable_mash[:top_level_2].should be_a(Chef::Node::ImmutableArray)
45
+ expect(@immutable_mash[:top_level_2]).to be_a(Chef::Node::ImmutableArray)
46
46
  end
47
47
 
48
48
  it "converts arrays of hashes to ImmutableArray's of ImmutableMashes" do
49
- @immutable_mash[:top_level_3].first.should be_a(Chef::Node::ImmutableMash)
49
+ expect(@immutable_mash[:top_level_3].first).to be_a(Chef::Node::ImmutableMash)
50
50
  end
51
51
 
52
52
  it "converts nested hashes to ImmutableMashes" do
53
- @immutable_mash[:top_level_4].should be_a(Chef::Node::ImmutableMash)
54
- @immutable_mash[:top_level_4][:level2].should be_a(Chef::Node::ImmutableMash)
53
+ expect(@immutable_mash[:top_level_4]).to be_a(Chef::Node::ImmutableMash)
54
+ expect(@immutable_mash[:top_level_4][:level2]).to be_a(Chef::Node::ImmutableMash)
55
55
  end
56
56
 
57
57
  describe "to_hash" do
@@ -60,23 +60,23 @@ describe Chef::Node::ImmutableMash do
60
60
  end
61
61
 
62
62
  it "converts an immutable mash to a new mutable hash" do
63
- @copy.should be_instance_of(Hash)
63
+ expect(@copy).to be_instance_of(Hash)
64
64
  end
65
65
 
66
66
  it "converts an immutable nested mash to a new mutable hash" do
67
- @copy['top_level_4']['level2'].should be_instance_of(Hash)
67
+ expect(@copy['top_level_4']['level2']).to be_instance_of(Hash)
68
68
  end
69
69
 
70
70
  it "converts an immutable nested array to a new mutable array" do
71
- @copy['top_level_2'].should be_instance_of(Array)
71
+ expect(@copy['top_level_2']).to be_instance_of(Array)
72
72
  end
73
73
 
74
74
  it "should create a mash with the same content" do
75
- @copy.should == @immutable_mash
75
+ expect(@copy).to eq(@immutable_mash)
76
76
  end
77
77
 
78
78
  it 'should allow mutation' do
79
- lambda { @copy['m'] = 'm' }.should_not raise_error
79
+ expect { @copy['m'] = 'm' }.not_to raise_error
80
80
  end
81
81
 
82
82
  end
@@ -97,14 +97,14 @@ describe Chef::Node::ImmutableMash do
97
97
  :shift
98
98
  ].each do |mutator|
99
99
  it "doesn't allow mutation via `#{mutator}'" do
100
- lambda { @immutable_mash.send(mutator) }.should raise_error
100
+ expect { @immutable_mash.send(mutator) }.to raise_error
101
101
  end
102
102
  end
103
103
 
104
104
  it "returns a mutable version of itself when duped" do
105
105
  mutable = @immutable_mash.dup
106
106
  mutable[:new_key] = :value
107
- mutable[:new_key].should == :value
107
+ expect(mutable[:new_key]).to eq(:value)
108
108
  end
109
109
 
110
110
  end
@@ -154,7 +154,7 @@ describe Chef::Node::ImmutableArray do
154
154
  :unshift
155
155
  ].each do |mutator|
156
156
  it "does not allow mutation via `#{mutator}" do
157
- lambda { @immutable_array.send(mutator)}.should raise_error
157
+ expect { @immutable_array.send(mutator)}.to raise_error
158
158
  end
159
159
  end
160
160
 
@@ -165,7 +165,7 @@ describe Chef::Node::ImmutableArray do
165
165
  it "returns a mutable version of itself when duped" do
166
166
  mutable = @immutable_array.dup
167
167
  mutable[0] = :value
168
- mutable[0].should == :value
168
+ expect(mutable[0]).to eq(:value)
169
169
  end
170
170
 
171
171
  describe "to_a" do
@@ -174,23 +174,23 @@ describe Chef::Node::ImmutableArray do
174
174
  end
175
175
 
176
176
  it "converts an immutable array to a new mutable array" do
177
- @copy.should be_instance_of(Array)
177
+ expect(@copy).to be_instance_of(Array)
178
178
  end
179
179
 
180
180
  it "converts an immutable nested array to a new mutable array" do
181
- @copy[1].should be_instance_of(Array)
181
+ expect(@copy[1]).to be_instance_of(Array)
182
182
  end
183
183
 
184
184
  it "converts an immutable nested mash to a new mutable hash" do
185
- @copy[2].should be_instance_of(Hash)
185
+ expect(@copy[2]).to be_instance_of(Hash)
186
186
  end
187
187
 
188
188
  it "should create an array with the same content" do
189
- @copy.should == @immutable_nested_array
189
+ expect(@copy).to eq(@immutable_nested_array)
190
190
  end
191
191
 
192
192
  it 'should allow mutation' do
193
- lambda { @copy << 'm' }.should_not raise_error
193
+ expect { @copy << 'm' }.not_to raise_error
194
194
  end
195
195
  end
196
196
 
@@ -28,167 +28,167 @@ describe Chef::Node do
28
28
 
29
29
  it "creates a node and assigns it a name" do
30
30
  node = Chef::Node.build('solo-node')
31
- node.name.should == 'solo-node'
31
+ expect(node.name).to eq('solo-node')
32
32
  end
33
33
 
34
34
  it "should validate the name of the node" do
35
- lambda{Chef::Node.build('solo node')}.should raise_error(Chef::Exceptions::ValidationFailed)
35
+ expect{Chef::Node.build('solo node')}.to raise_error(Chef::Exceptions::ValidationFailed)
36
36
  end
37
37
 
38
38
  it "should be sortable" do
39
39
  n1 = Chef::Node.build('alpha')
40
40
  n2 = Chef::Node.build('beta')
41
41
  n3 = Chef::Node.build('omega')
42
- [n3, n1, n2].sort.should == [n1, n2, n3]
42
+ expect([n3, n1, n2].sort).to eq([n1, n2, n3])
43
43
  end
44
44
 
45
45
  describe "when the node does not exist on the server" do
46
46
  before do
47
47
  response = OpenStruct.new(:code => '404')
48
48
  exception = Net::HTTPServerException.new("404 not found", response)
49
- Chef::Node.stub(:load).and_raise(exception)
49
+ allow(Chef::Node).to receive(:load).and_raise(exception)
50
50
  node.name("created-node")
51
51
  end
52
52
 
53
53
  it "creates a new node for find_or_create" do
54
- Chef::Node.stub(:new).and_return(node)
55
- node.should_receive(:create).and_return(node)
54
+ allow(Chef::Node).to receive(:new).and_return(node)
55
+ expect(node).to receive(:create).and_return(node)
56
56
  node = Chef::Node.find_or_create("created-node")
57
- node.name.should == 'created-node'
58
- node.should equal(node)
57
+ expect(node.name).to eq('created-node')
58
+ expect(node).to equal(node)
59
59
  end
60
60
  end
61
61
 
62
62
  describe "when the node exists on the server" do
63
63
  before do
64
64
  node.name('existing-node')
65
- Chef::Node.stub(:load).and_return(node)
65
+ allow(Chef::Node).to receive(:load).and_return(node)
66
66
  end
67
67
 
68
68
  it "loads the node via the REST API for find_or_create" do
69
- Chef::Node.find_or_create('existing-node').should equal(node)
69
+ expect(Chef::Node.find_or_create('existing-node')).to equal(node)
70
70
  end
71
71
  end
72
72
 
73
73
  describe "run_state" do
74
74
  it "is an empty hash" do
75
- node.run_state.should respond_to(:keys)
76
- node.run_state.should be_empty
75
+ expect(node.run_state).to respond_to(:keys)
76
+ expect(node.run_state).to be_empty
77
77
  end
78
78
  end
79
79
 
80
80
  describe "initialize" do
81
81
  it "should default to the '_default' chef_environment" do
82
82
  n = Chef::Node.new
83
- n.chef_environment.should == '_default'
83
+ expect(n.chef_environment).to eq('_default')
84
84
  end
85
85
  end
86
86
 
87
87
  describe "name" do
88
88
  it "should allow you to set a name with name(something)" do
89
- lambda { node.name("latte") }.should_not raise_error
89
+ expect { node.name("latte") }.not_to raise_error
90
90
  end
91
91
 
92
92
  it "should return the name with name()" do
93
93
  node.name("latte")
94
- node.name.should eql("latte")
94
+ expect(node.name).to eql("latte")
95
95
  end
96
96
 
97
97
  it "should always have a string for name" do
98
- lambda { node.name(Hash.new) }.should raise_error(ArgumentError)
98
+ expect { node.name(Hash.new) }.to raise_error(ArgumentError)
99
99
  end
100
100
 
101
101
  it "cannot be blank" do
102
- lambda { node.name("")}.should raise_error(Chef::Exceptions::ValidationFailed)
102
+ expect { node.name("")}.to raise_error(Chef::Exceptions::ValidationFailed)
103
103
  end
104
104
 
105
105
  it "should not accept name doesn't match /^[\-[:alnum:]_:.]+$/" do
106
- lambda { node.name("space in it")}.should raise_error(Chef::Exceptions::ValidationFailed)
106
+ expect { node.name("space in it")}.to raise_error(Chef::Exceptions::ValidationFailed)
107
107
  end
108
108
  end
109
109
 
110
110
  describe "chef_environment" do
111
111
  it "should set an environment with chef_environment(something)" do
112
- lambda { node.chef_environment("latte") }.should_not raise_error
112
+ expect { node.chef_environment("latte") }.not_to raise_error
113
113
  end
114
114
 
115
115
  it "should return the chef_environment with chef_environment()" do
116
116
  node.chef_environment("latte")
117
- node.chef_environment.should == "latte"
117
+ expect(node.chef_environment).to eq("latte")
118
118
  end
119
119
 
120
120
  it "should disallow non-strings" do
121
- lambda { node.chef_environment(Hash.new) }.should raise_error(ArgumentError)
122
- lambda { node.chef_environment(42) }.should raise_error(ArgumentError)
121
+ expect { node.chef_environment(Hash.new) }.to raise_error(ArgumentError)
122
+ expect { node.chef_environment(42) }.to raise_error(ArgumentError)
123
123
  end
124
124
 
125
125
  it "cannot be blank" do
126
- lambda { node.chef_environment("")}.should raise_error(Chef::Exceptions::ValidationFailed)
126
+ expect { node.chef_environment("")}.to raise_error(Chef::Exceptions::ValidationFailed)
127
127
  end
128
128
  end
129
129
 
130
130
  describe "attributes" do
131
131
  it "should have attributes" do
132
- node.attribute.should be_a_kind_of(Hash)
132
+ expect(node.attribute).to be_a_kind_of(Hash)
133
133
  end
134
134
 
135
135
  it "should allow attributes to be accessed by name or symbol directly on node[]" do
136
136
  node.default["locust"] = "something"
137
- node[:locust].should eql("something")
138
- node["locust"].should eql("something")
137
+ expect(node[:locust]).to eql("something")
138
+ expect(node["locust"]).to eql("something")
139
139
  end
140
140
 
141
141
  it "should return nil if it cannot find an attribute with node[]" do
142
- node["secret"].should eql(nil)
142
+ expect(node["secret"]).to eql(nil)
143
143
  end
144
144
 
145
145
  it "does not allow you to set an attribute via node[]=" do
146
- lambda { node["secret"] = "shush" }.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
146
+ expect { node["secret"] = "shush" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
147
147
  end
148
148
 
149
149
  it "should allow you to query whether an attribute exists with attribute?" do
150
150
  node.default["locust"] = "something"
151
- node.attribute?("locust").should eql(true)
152
- node.attribute?("no dice").should eql(false)
151
+ expect(node.attribute?("locust")).to eql(true)
152
+ expect(node.attribute?("no dice")).to eql(false)
153
153
  end
154
154
 
155
155
  it "should let you go deep with attribute?" do
156
156
  node.set["battles"]["people"]["wonkey"] = true
157
- node["battles"]["people"].attribute?("wonkey").should == true
158
- node["battles"]["people"].attribute?("snozzberry").should == false
157
+ expect(node["battles"]["people"].attribute?("wonkey")).to eq(true)
158
+ expect(node["battles"]["people"].attribute?("snozzberry")).to eq(false)
159
159
  end
160
160
 
161
161
  it "does not allow you to set an attribute via method_missing" do
162
- lambda { node.sunshine = "is bright"}.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
162
+ expect { node.sunshine = "is bright"}.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
163
163
  end
164
164
 
165
165
  it "should allow you get get an attribute via method_missing" do
166
166
  node.default.sunshine = "is bright"
167
- node.sunshine.should eql("is bright")
167
+ expect(node.sunshine).to eql("is bright")
168
168
  end
169
169
 
170
170
  describe "normal attributes" do
171
171
  it "should allow you to set an attribute with set, without pre-declaring a hash" do
172
172
  node.set[:snoopy][:is_a_puppy] = true
173
- node[:snoopy][:is_a_puppy].should == true
173
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
174
174
  end
175
175
 
176
176
  it "should allow you to set an attribute with set_unless" do
177
177
  node.set_unless[:snoopy][:is_a_puppy] = false
178
- node[:snoopy][:is_a_puppy].should == false
178
+ expect(node[:snoopy][:is_a_puppy]).to eq(false)
179
179
  end
180
180
 
181
181
  it "should not allow you to set an attribute with set_unless if it already exists" do
182
182
  node.set[:snoopy][:is_a_puppy] = true
183
183
  node.set_unless[:snoopy][:is_a_puppy] = false
184
- node[:snoopy][:is_a_puppy].should == true
184
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
185
185
  end
186
186
 
187
187
  it "should allow you to set a value after a set_unless" do
188
188
  # this tests for set_unless_present state bleeding between statements CHEF-3806
189
189
  node.set_unless[:snoopy][:is_a_puppy] = false
190
190
  node.set[:snoopy][:is_a_puppy] = true
191
- node[:snoopy][:is_a_puppy].should == true
191
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
192
192
  end
193
193
 
194
194
  it "should let you set a value after a 'dangling' set_unless" do
@@ -196,43 +196,43 @@ describe Chef::Node do
196
196
  node.set[:snoopy][:is_a_puppy] = "what"
197
197
  node.set_unless[:snoopy][:is_a_puppy]
198
198
  node.set[:snoopy][:is_a_puppy] = true
199
- node[:snoopy][:is_a_puppy].should == true
199
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
200
200
  end
201
201
 
202
202
  it "auto-vivifies attributes created via method syntax" do
203
203
  node.set.fuu.bahrr.baz = "qux"
204
- node.fuu.bahrr.baz.should == "qux"
204
+ expect(node.fuu.bahrr.baz).to eq("qux")
205
205
  end
206
206
 
207
207
  it "should let you use tag as a convience method for the tags attribute" do
208
208
  node.normal['tags'] = ['one', 'two']
209
209
  node.tag('three', 'four')
210
- node['tags'].should == ['one', 'two', 'three', 'four']
210
+ expect(node['tags']).to eq(['one', 'two', 'three', 'four'])
211
211
  end
212
212
  end
213
213
 
214
214
  describe "default attributes" do
215
215
  it "should be set with default, without pre-declaring a hash" do
216
216
  node.default[:snoopy][:is_a_puppy] = true
217
- node[:snoopy][:is_a_puppy].should == true
217
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
218
218
  end
219
219
 
220
220
  it "should allow you to set with default_unless without pre-declaring a hash" do
221
221
  node.default_unless[:snoopy][:is_a_puppy] = false
222
- node[:snoopy][:is_a_puppy].should == false
222
+ expect(node[:snoopy][:is_a_puppy]).to eq(false)
223
223
  end
224
224
 
225
225
  it "should not allow you to set an attribute with default_unless if it already exists" do
226
226
  node.default[:snoopy][:is_a_puppy] = true
227
227
  node.default_unless[:snoopy][:is_a_puppy] = false
228
- node[:snoopy][:is_a_puppy].should == true
228
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
229
229
  end
230
230
 
231
231
  it "should allow you to set a value after a default_unless" do
232
232
  # this tests for set_unless_present state bleeding between statements CHEF-3806
233
233
  node.default_unless[:snoopy][:is_a_puppy] = false
234
234
  node.default[:snoopy][:is_a_puppy] = true
235
- node[:snoopy][:is_a_puppy].should == true
235
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
236
236
  end
237
237
 
238
238
  it "should allow you to set a value after a 'dangling' default_unless" do
@@ -240,37 +240,37 @@ describe Chef::Node do
240
240
  node.default[:snoopy][:is_a_puppy] = "what"
241
241
  node.default_unless[:snoopy][:is_a_puppy]
242
242
  node.default[:snoopy][:is_a_puppy] = true
243
- node[:snoopy][:is_a_puppy].should == true
243
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
244
244
  end
245
245
 
246
246
  it "auto-vivifies attributes created via method syntax" do
247
247
  node.default.fuu.bahrr.baz = "qux"
248
- node.fuu.bahrr.baz.should == "qux"
248
+ expect(node.fuu.bahrr.baz).to eq("qux")
249
249
  end
250
250
  end
251
251
 
252
252
  describe "override attributes" do
253
253
  it "should be set with override, without pre-declaring a hash" do
254
254
  node.override[:snoopy][:is_a_puppy] = true
255
- node[:snoopy][:is_a_puppy].should == true
255
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
256
256
  end
257
257
 
258
258
  it "should allow you to set with override_unless without pre-declaring a hash" do
259
259
  node.override_unless[:snoopy][:is_a_puppy] = false
260
- node[:snoopy][:is_a_puppy].should == false
260
+ expect(node[:snoopy][:is_a_puppy]).to eq(false)
261
261
  end
262
262
 
263
263
  it "should not allow you to set an attribute with override_unless if it already exists" do
264
264
  node.override[:snoopy][:is_a_puppy] = true
265
265
  node.override_unless[:snoopy][:is_a_puppy] = false
266
- node[:snoopy][:is_a_puppy].should == true
266
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
267
267
  end
268
268
 
269
269
  it "should allow you to set a value after an override_unless" do
270
270
  # this tests for set_unless_present state bleeding between statements CHEF-3806
271
271
  node.override_unless[:snoopy][:is_a_puppy] = false
272
272
  node.override[:snoopy][:is_a_puppy] = true
273
- node[:snoopy][:is_a_puppy].should == true
273
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
274
274
  end
275
275
 
276
276
  it "should allow you to set a value after a 'dangling' override_unless" do
@@ -278,12 +278,12 @@ describe Chef::Node do
278
278
  node.override_unless[:snoopy][:is_a_puppy] = "what"
279
279
  node.override_unless[:snoopy][:is_a_puppy]
280
280
  node.override[:snoopy][:is_a_puppy] = true
281
- node[:snoopy][:is_a_puppy].should == true
281
+ expect(node[:snoopy][:is_a_puppy]).to eq(true)
282
282
  end
283
283
 
284
284
  it "auto-vivifies attributes created via method syntax" do
285
285
  node.override.fuu.bahrr.baz = "qux"
286
- node.fuu.bahrr.baz.should == "qux"
286
+ expect(node.fuu.bahrr.baz).to eq("qux")
287
287
  end
288
288
  end
289
289
 
@@ -611,8 +611,39 @@ describe Chef::Node do
611
611
  end
612
612
  end
613
613
 
614
+ # In Chef-12.0 there is a deep_merge cache on the top level attribute which had a bug
615
+ # where it cached node[:foo] separate from node['foo']. These tests exercise those edge conditions.
616
+ #
617
+ # https://github.com/opscode/chef/issues/2700
618
+ # https://github.com/opscode/chef/issues/2712
619
+ # https://github.com/opscode/chef/issues/2745
620
+ #
621
+ describe "deep merge attribute cache edge conditions" do
622
+ it "does not error with complicated attribute substitution" do
623
+ node.default['chef_attribute_hell']['attr1'] = "attribute1"
624
+ node.default['chef_attribute_hell']['attr2'] = "#{node.chef_attribute_hell.attr1}/attr2"
625
+ expect { node.default['chef_attribute_hell']['attr3'] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error
626
+ end
627
+
628
+ it "caches both strings and symbols correctly" do
629
+ node.force_default[:solr][:version] = '4.10.2'
630
+ node.force_default[:solr][:data_dir] = "/opt/solr-#{node['solr'][:version]}/example/solr"
631
+ node.force_default[:solr][:xms] = "512M"
632
+ expect(node[:solr][:xms]).to eql("512M")
633
+ expect(node['solr'][:xms]).to eql("512M")
634
+ end
635
+
636
+ it "method interpolation syntax also works" do
637
+ node.default['passenger']['version'] = '4.0.57'
638
+ node.default['passenger']['root_path'] = "passenger-#{node['passenger']['version']}"
639
+ node.default['passenger']['root_path_2'] = "passenger-#{node.passenger['version']}"
640
+ expect(node['passenger']['root_path_2']).to eql("passenger-4.0.57")
641
+ expect(node[:passenger]['root_path_2']).to eql("passenger-4.0.57")
642
+ end
643
+ end
644
+
614
645
  it "should raise an ArgumentError if you ask for an attribute that doesn't exist via method_missing" do
615
- lambda { node.sunshine }.should raise_error(NoMethodError)
646
+ expect { node.sunshine }.to raise_error(NoMethodError)
616
647
  end
617
648
 
618
649
  it "should allow you to iterate over attributes with each_attribute" do
@@ -622,10 +653,10 @@ describe Chef::Node do
622
653
  node.each_attribute do |a,v|
623
654
  seen_attributes[a] = v
624
655
  end
625
- seen_attributes.should have_key("sunshine")
626
- seen_attributes.should have_key("canada")
627
- seen_attributes["sunshine"].should == "is bright"
628
- seen_attributes["canada"].should == "is a nice place"
656
+ expect(seen_attributes).to have_key("sunshine")
657
+ expect(seen_attributes).to have_key("canada")
658
+ expect(seen_attributes["sunshine"]).to eq("is bright")
659
+ expect(seen_attributes["canada"]).to eq("is a nice place")
629
660
  end
630
661
  end
631
662
 
@@ -637,62 +668,62 @@ describe Chef::Node do
637
668
 
638
669
  it "consumes the run list portion of a collection of attributes and returns the remainder" do
639
670
  attrs = {"run_list" => [ "role[base]", "recipe[chef::server]" ], "foo" => "bar"}
640
- node.consume_run_list(attrs).should == {"foo" => "bar"}
641
- node.run_list.should == [ "role[base]", "recipe[chef::server]" ]
671
+ expect(node.consume_run_list(attrs)).to eq({"foo" => "bar"})
672
+ expect(node.run_list).to eq([ "role[base]", "recipe[chef::server]" ])
642
673
  end
643
674
 
644
675
  it "should overwrites the run list with the run list it consumes" do
645
676
  node.consume_run_list "recipes" => [ "one", "two" ]
646
677
  node.consume_run_list "recipes" => [ "three" ]
647
- node.run_list.should == [ "three" ]
678
+ expect(node.run_list).to eq([ "three" ])
648
679
  end
649
680
 
650
681
  it "should not add duplicate recipes from the json attributes" do
651
682
  node.run_list << "one"
652
683
  node.consume_run_list "recipes" => [ "one", "two", "three" ]
653
- node.run_list.should == [ "one", "two", "three" ]
684
+ expect(node.run_list).to eq([ "one", "two", "three" ])
654
685
  end
655
686
 
656
687
  it "doesn't change the run list if no run_list is specified in the json" do
657
688
  node.run_list << "role[database]"
658
689
  node.consume_run_list "foo" => "bar"
659
- node.run_list.should == ["role[database]"]
690
+ expect(node.run_list).to eq(["role[database]"])
660
691
  end
661
692
 
662
693
  it "raises an exception if you provide both recipe and run_list attributes, since this is ambiguous" do
663
- lambda { node.consume_run_list "recipes" => "stuff", "run_list" => "other_stuff" }.should raise_error(Chef::Exceptions::AmbiguousRunlistSpecification)
694
+ expect { node.consume_run_list "recipes" => "stuff", "run_list" => "other_stuff" }.to raise_error(Chef::Exceptions::AmbiguousRunlistSpecification)
664
695
  end
665
696
 
666
697
  it "should add json attributes to the node" do
667
698
  node.consume_external_attrs(@ohai_data, {"one" => "two", "three" => "four"})
668
- node.one.should eql("two")
669
- node.three.should eql("four")
699
+ expect(node.one).to eql("two")
700
+ expect(node.three).to eql("four")
670
701
  end
671
702
 
672
703
  it "should set the tags attribute to an empty array if it is not already defined" do
673
704
  node.consume_external_attrs(@ohai_data, {})
674
- node.tags.should eql([])
705
+ expect(node.tags).to eql([])
675
706
  end
676
707
 
677
708
  it "should not set the tags attribute to an empty array if it is already defined" do
678
709
  node.normal[:tags] = [ "radiohead" ]
679
710
  node.consume_external_attrs(@ohai_data, {})
680
- node.tags.should eql([ "radiohead" ])
711
+ expect(node.tags).to eql([ "radiohead" ])
681
712
  end
682
713
 
683
714
  it "deep merges attributes instead of overwriting them" do
684
715
  node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
685
- node.one.to_hash.should == {"two" => {"three" => "four"}}
716
+ expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})
686
717
  node.consume_external_attrs(@ohai_data, "one" => {"abc" => "123"})
687
718
  node.consume_external_attrs(@ohai_data, "one" => {"two" => {"foo" => "bar"}})
688
- node.one.to_hash.should == {"two" => {"three" => "four", "foo" => "bar"}, "abc" => "123"}
719
+ expect(node.one.to_hash).to eq({"two" => {"three" => "four", "foo" => "bar"}, "abc" => "123"})
689
720
  end
690
721
 
691
722
  it "gives attributes from JSON priority when deep merging" do
692
723
  node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
693
- node.one.to_hash.should == {"two" => {"three" => "four"}}
724
+ expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})
694
725
  node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "forty-two"}})
695
- node.one.to_hash.should == {"two" => {"three" => "forty-two"}}
726
+ expect(node.one.to_hash).to eq({"two" => {"three" => "forty-two"}})
696
727
  end
697
728
 
698
729
  end
@@ -704,21 +735,21 @@ describe Chef::Node do
704
735
 
705
736
  it "sets its platform according to platform detection" do
706
737
  node.consume_external_attrs(@ohai_data, {})
707
- node.automatic_attrs[:platform].should == 'foobuntu'
708
- node.automatic_attrs[:platform_version].should == '23.42'
738
+ expect(node.automatic_attrs[:platform]).to eq('foobuntu')
739
+ expect(node.automatic_attrs[:platform_version]).to eq('23.42')
709
740
  end
710
741
 
711
742
  it "consumes the run list from provided json attributes" do
712
743
  node.consume_external_attrs(@ohai_data, {"run_list" => ['recipe[unicorn]']})
713
- node.run_list.should == ['recipe[unicorn]']
744
+ expect(node.run_list).to eq(['recipe[unicorn]'])
714
745
  end
715
746
 
716
747
  it "saves non-runlist json attrs for later" do
717
748
  expansion = Chef::RunList::RunListExpansion.new('_default', [])
718
- node.run_list.stub(:expand).and_return(expansion)
749
+ allow(node.run_list).to receive(:expand).and_return(expansion)
719
750
  node.consume_external_attrs(@ohai_data, {"foo" => "bar"})
720
751
  node.expand!
721
- node.normal_attrs.should == {"foo" => "bar", "tags" => []}
752
+ expect(node.normal_attrs).to eq({"foo" => "bar", "tags" => []})
722
753
  end
723
754
 
724
755
  end
@@ -730,44 +761,44 @@ describe Chef::Node do
730
761
  e.default_attributes("env default key" => "env default value")
731
762
  e.override_attributes("env override key" => "env override value")
732
763
  end
733
- Chef::Environment.should_receive(:load).with("rspec_env").and_return(@environment)
764
+ expect(Chef::Environment).to receive(:load).with("rspec_env").and_return(@environment)
734
765
  @expansion = Chef::RunList::RunListExpansion.new("rspec_env", [])
735
766
  node.chef_environment("rspec_env")
736
- node.run_list.stub(:expand).and_return(@expansion)
767
+ allow(node.run_list).to receive(:expand).and_return(@expansion)
737
768
  end
738
769
 
739
770
  it "sets the 'recipes' automatic attribute to the recipes in the expanded run_list" do
740
771
  @expansion.recipes << 'recipe[chef::client]' << 'recipe[nginx::default]'
741
772
  node.expand!
742
- node.automatic_attrs[:recipes].should == ['recipe[chef::client]', 'recipe[nginx::default]']
773
+ expect(node.automatic_attrs[:recipes]).to eq(['recipe[chef::client]', 'recipe[nginx::default]'])
743
774
  end
744
775
 
745
776
  it "sets the 'roles' automatic attribute to the expanded role list" do
746
777
  @expansion.instance_variable_set(:@applied_roles, {'arf' => nil, 'countersnark' => nil})
747
778
  node.expand!
748
- node.automatic_attrs[:roles].sort.should == ['arf', 'countersnark']
779
+ expect(node.automatic_attrs[:roles].sort).to eq(['arf', 'countersnark'])
749
780
  end
750
781
 
751
782
  it "applies default attributes from the environment as environment defaults" do
752
783
  node.expand!
753
- node.attributes.env_default["env default key"].should == "env default value"
784
+ expect(node.attributes.env_default["env default key"]).to eq("env default value")
754
785
  end
755
786
 
756
787
  it "applies override attributes from the environment as env overrides" do
757
788
  node.expand!
758
- node.attributes.env_override["env override key"].should == "env override value"
789
+ expect(node.attributes.env_override["env override key"]).to eq("env override value")
759
790
  end
760
791
 
761
792
  it "applies default attributes from roles as role defaults" do
762
793
  @expansion.default_attrs["role default key"] = "role default value"
763
794
  node.expand!
764
- node.attributes.role_default["role default key"].should == "role default value"
795
+ expect(node.attributes.role_default["role default key"]).to eq("role default value")
765
796
  end
766
797
 
767
798
  it "applies override attributes from roles as role overrides" do
768
799
  @expansion.override_attrs["role override key"] = "role override value"
769
800
  node.expand!
770
- node.attributes.role_override["role override key"].should == "role override value"
801
+ expect(node.attributes.role_override["role override key"]).to eq("role override value")
771
802
  end
772
803
  end
773
804
 
@@ -782,8 +813,8 @@ describe Chef::Node do
782
813
  node.automatic_attrs[:recipes] = [ "nginx::other_module" ]
783
814
  node.loaded_recipe(:nginx, "module")
784
815
  expect(node.automatic_attrs[:recipes].length).to eq(2)
785
- expect(node.recipe?("nginx::module")).to be_true
786
- expect(node.recipe?("nginx::other_module")).to be_true
816
+ expect(node.recipe?("nginx::module")).to be true
817
+ expect(node.recipe?("nginx::other_module")).to be true
787
818
  end
788
819
  end
789
820
 
@@ -794,11 +825,11 @@ describe Chef::Node do
794
825
  end
795
826
 
796
827
  it "finds the recipe" do
797
- node.recipe?("nginx::module").should be_true
828
+ expect(node.recipe?("nginx::module")).to be true
798
829
  end
799
830
 
800
831
  it "does not find a recipe not in the run list" do
801
- node.recipe?("nginx::other_module").should be_false
832
+ expect(node.recipe?("nginx::other_module")).to be false
802
833
  end
803
834
  end
804
835
  context "when a recipe is in the expanded run list only" do
@@ -808,11 +839,11 @@ describe Chef::Node do
808
839
  end
809
840
 
810
841
  it "finds a recipe in the expanded run list" do
811
- node.recipe?("nginx::module").should be_true
842
+ expect(node.recipe?("nginx::module")).to be true
812
843
  end
813
844
 
814
845
  it "does not find a recipe that's not in the run list" do
815
- node.recipe?("nginx::other_module").should be_false
846
+ expect(node.recipe?("nginx::other_module")).to be false
816
847
  end
817
848
  end
818
849
  end
@@ -826,15 +857,15 @@ describe Chef::Node do
826
857
  end
827
858
 
828
859
  it "removes default attributes" do
829
- node.default.should be_empty
860
+ expect(node.default).to be_empty
830
861
  end
831
862
 
832
863
  it "removes override attributes" do
833
- node.override.should be_empty
864
+ expect(node.override).to be_empty
834
865
  end
835
866
 
836
867
  it "leaves normal level attributes untouched" do
837
- node[:foo].should == "normal"
868
+ expect(node[:foo]).to eq("normal")
838
869
  end
839
870
 
840
871
  end
@@ -849,32 +880,32 @@ describe Chef::Node do
849
880
  @environment = Chef::Environment.new
850
881
  @environment.default_attributes = {:default => "from env", :d_env => "env only" }
851
882
  @environment.override_attributes = {:override => "from env", :o_env => "env only"}
852
- Chef::Environment.stub(:load).and_return(@environment)
883
+ allow(Chef::Environment).to receive(:load).and_return(@environment)
853
884
  node.apply_expansion_attributes(@expansion)
854
885
  end
855
886
 
856
887
  it "does not nuke role-only default attrs" do
857
- node[:d_role].should == "role only"
888
+ expect(node[:d_role]).to eq("role only")
858
889
  end
859
890
 
860
891
  it "does not nuke role-only override attrs" do
861
- node[:o_role].should == "role only"
892
+ expect(node[:o_role]).to eq("role only")
862
893
  end
863
894
 
864
895
  it "does not nuke env-only default attrs" do
865
- node[:o_env].should == "env only"
896
+ expect(node[:o_env]).to eq("env only")
866
897
  end
867
898
 
868
899
  it "does not nuke role-only override attrs" do
869
- node[:o_env].should == "env only"
900
+ expect(node[:o_env]).to eq("env only")
870
901
  end
871
902
 
872
903
  it "gives role defaults precedence over env defaults" do
873
- node[:default].should == "from role"
904
+ expect(node[:default]).to eq("from role")
874
905
  end
875
906
 
876
907
  it "gives env overrides precedence over role overrides" do
877
- node[:override].should == "from env"
908
+ expect(node[:override]).to eq("from env")
878
909
  end
879
910
  end
880
911
 
@@ -894,60 +925,60 @@ describe Chef::Node do
894
925
  end
895
926
 
896
927
  it "sets attributes from the files" do
897
- node.ldap_server.should eql("ops1prod")
898
- node.ldap_basedn.should eql("dc=hjksolutions,dc=com")
899
- node.ldap_replication_password.should eql("forsure")
900
- node.smokey.should eql("robinson")
928
+ expect(node.ldap_server).to eql("ops1prod")
929
+ expect(node.ldap_basedn).to eql("dc=hjksolutions,dc=com")
930
+ expect(node.ldap_replication_password).to eql("forsure")
931
+ expect(node.smokey).to eql("robinson")
901
932
  end
902
933
 
903
934
  it "gives a sensible error when attempting to load a missing attributes file" do
904
- lambda { node.include_attribute("nope-this::doesnt-exist") }.should raise_error(Chef::Exceptions::CookbookNotFound)
935
+ expect { node.include_attribute("nope-this::doesnt-exist") }.to raise_error(Chef::Exceptions::CookbookNotFound)
905
936
  end
906
937
  end
907
938
 
908
939
  describe "roles" do
909
940
  it "should allow you to query whether or not it has a recipe applied with role?" do
910
941
  node.run_list << "role[sunrise]"
911
- node.role?("sunrise").should eql(true)
912
- node.role?("not at home").should eql(false)
942
+ expect(node.role?("sunrise")).to eql(true)
943
+ expect(node.role?("not at home")).to eql(false)
913
944
  end
914
945
 
915
946
  it "should allow you to set roles with arguments" do
916
947
  node.run_list << "role[one]"
917
948
  node.run_list << "role[two]"
918
- node.role?("one").should eql(true)
919
- node.role?("two").should eql(true)
949
+ expect(node.role?("one")).to eql(true)
950
+ expect(node.role?("two")).to eql(true)
920
951
  end
921
952
  end
922
953
 
923
954
  describe "run_list" do
924
955
  it "should have a Chef::RunList of recipes and roles that should be applied" do
925
- node.run_list.should be_a_kind_of(Chef::RunList)
956
+ expect(node.run_list).to be_a_kind_of(Chef::RunList)
926
957
  end
927
958
 
928
959
  it "should allow you to query the run list with arguments" do
929
960
  node.run_list "recipe[baz]"
930
- node.run_list?("recipe[baz]").should eql(true)
961
+ expect(node.run_list?("recipe[baz]")).to eql(true)
931
962
  end
932
963
 
933
964
  it "should allow you to set the run list with arguments" do
934
965
  node.run_list "recipe[baz]", "role[foo]"
935
- node.run_list?("recipe[baz]").should eql(true)
936
- node.run_list?("role[foo]").should eql(true)
966
+ expect(node.run_list?("recipe[baz]")).to eql(true)
967
+ expect(node.run_list?("role[foo]")).to eql(true)
937
968
  end
938
969
  end
939
970
 
940
971
  describe "from file" do
941
972
  it "should load a node from a ruby file" do
942
973
  node.from_file(File.expand_path(File.join(CHEF_SPEC_DATA, "nodes", "test.rb")))
943
- node.name.should eql("test.example.com-short")
944
- node.sunshine.should eql("in")
945
- node.something.should eql("else")
946
- node.run_list.should == ["operations-master", "operations-monitoring"]
974
+ expect(node.name).to eql("test.example.com-short")
975
+ expect(node.sunshine).to eql("in")
976
+ expect(node.something).to eql("else")
977
+ expect(node.run_list).to eq(["operations-master", "operations-monitoring"])
947
978
  end
948
979
 
949
980
  it "should raise an exception if the file cannot be found or read" do
950
- lambda { node.from_file("/tmp/monkeydiving") }.should raise_error(IOError)
981
+ expect { node.from_file("/tmp/monkeydiving") }.to raise_error(IOError)
951
982
  end
952
983
  end
953
984
 
@@ -975,16 +1006,16 @@ describe Chef::Node do
975
1006
 
976
1007
  it "allows update of everything except name" do
977
1008
  node.update_from!(@example)
978
- node.name.should == "orig"
979
- node.chef_environment.should == @example.chef_environment
980
- node.default_attrs.should == @example.default_attrs
981
- node.override_attrs.should == @example.override_attrs
982
- node.normal_attrs.should == @example.normal_attrs
983
- node.run_list.should == @example.run_list
1009
+ expect(node.name).to eq("orig")
1010
+ expect(node.chef_environment).to eq(@example.chef_environment)
1011
+ expect(node.default_attrs).to eq(@example.default_attrs)
1012
+ expect(node.override_attrs).to eq(@example.override_attrs)
1013
+ expect(node.normal_attrs).to eq(@example.normal_attrs)
1014
+ expect(node.run_list).to eq(@example.run_list)
984
1015
  end
985
1016
 
986
1017
  it "should not update the name of the node" do
987
- node.should_not_receive(:name).with(@example.name)
1018
+ expect(node).not_to receive(:name).with(@example.name)
988
1019
  node.update_from!(@example)
989
1020
  end
990
1021
  end
@@ -999,19 +1030,19 @@ describe Chef::Node do
999
1030
  node.run_list << "role[leninist]"
1000
1031
  node.run_list << "recipe[stalinist]"
1001
1032
  h = node.to_hash
1002
- h["one"]["two"].should == "three"
1003
- h["one"]["four"].should == "six"
1004
- h["one"]["eight"].should == "nine"
1005
- h["role"].should be_include("marxist")
1006
- h["role"].should be_include("leninist")
1007
- h["run_list"].should be_include("role[marxist]")
1008
- h["run_list"].should be_include("role[leninist]")
1009
- h["run_list"].should be_include("recipe[stalinist]")
1010
- h["chef_environment"].should == "dev"
1033
+ expect(h["one"]["two"]).to eq("three")
1034
+ expect(h["one"]["four"]).to eq("six")
1035
+ expect(h["one"]["eight"]).to eq("nine")
1036
+ expect(h["role"]).to be_include("marxist")
1037
+ expect(h["role"]).to be_include("leninist")
1038
+ expect(h["run_list"]).to be_include("role[marxist]")
1039
+ expect(h["run_list"]).to be_include("role[leninist]")
1040
+ expect(h["run_list"]).to be_include("recipe[stalinist]")
1041
+ expect(h["chef_environment"]).to eq("dev")
1011
1042
  end
1012
1043
 
1013
1044
  it 'should return an empty array for empty run_list' do
1014
- node.to_hash["run_list"].should == []
1045
+ expect(node.to_hash["run_list"]).to eq([])
1015
1046
  end
1016
1047
  end
1017
1048
 
@@ -1019,13 +1050,13 @@ describe Chef::Node do
1019
1050
  it "should serialize itself as json", :json => true do
1020
1051
  node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
1021
1052
  json = Chef::JSONCompat.to_json(node)
1022
- json.should =~ /json_class/
1023
- json.should =~ /name/
1024
- json.should =~ /chef_environment/
1025
- json.should =~ /normal/
1026
- json.should =~ /default/
1027
- json.should =~ /override/
1028
- json.should =~ /run_list/
1053
+ expect(json).to match(/json_class/)
1054
+ expect(json).to match(/name/)
1055
+ expect(json).to match(/chef_environment/)
1056
+ expect(json).to match(/normal/)
1057
+ expect(json).to match(/default/)
1058
+ expect(json).to match(/override/)
1059
+ expect(json).to match(/run_list/)
1029
1060
  end
1030
1061
 
1031
1062
  it 'should serialize valid json with a run list', :json => true do
@@ -1034,45 +1065,45 @@ describe Chef::Node do
1034
1065
  node.run_list << {"type" => "role", "name" => 'Cthulu'}
1035
1066
  node.run_list << {"type" => "role", "name" => 'Hastur'}
1036
1067
  json = Chef::JSONCompat.to_json(node)
1037
- json.should =~ /\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/
1068
+ expect(json).to match(/\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/)
1038
1069
  end
1039
1070
 
1040
1071
  it "should serialize the correct run list", :json => true do
1041
1072
  node.run_list << "role[marxist]"
1042
1073
  node.run_list << "role[leninist]"
1043
1074
  node.override_runlist << "role[stalinist]"
1044
- node.run_list.should be_include("role[stalinist]")
1075
+ expect(node.run_list).to be_include("role[stalinist]")
1045
1076
  json = Chef::JSONCompat.to_json(node)
1046
- json.should =~ /\"run_list\":\[\"role\[marxist\]\",\"role\[leninist\]\"\]/
1077
+ expect(json).to match(/\"run_list\":\[\"role\[marxist\]\",\"role\[leninist\]\"\]/)
1047
1078
  end
1048
1079
 
1049
1080
  it "merges the override components into a combined override object" do
1050
1081
  node.attributes.role_override["role override"] = "role override"
1051
1082
  node.attributes.env_override["env override"] = "env override"
1052
1083
  node_for_json = node.for_json
1053
- node_for_json["override"]["role override"].should == "role override"
1054
- node_for_json["override"]["env override"].should == "env override"
1084
+ expect(node_for_json["override"]["role override"]).to eq("role override")
1085
+ expect(node_for_json["override"]["env override"]).to eq("env override")
1055
1086
  end
1056
1087
 
1057
1088
  it "merges the default components into a combined default object" do
1058
1089
  node.attributes.role_default["role default"] = "role default"
1059
1090
  node.attributes.env_default["env default"] = "env default"
1060
1091
  node_for_json = node.for_json
1061
- node_for_json["default"]["role default"].should == "role default"
1062
- node_for_json["default"]["env default"].should == "env default"
1092
+ expect(node_for_json["default"]["role default"]).to eq("role default")
1093
+ expect(node_for_json["default"]["env default"]).to eq("env default")
1063
1094
  end
1064
1095
 
1065
1096
  it "should deserialize itself from json", :json => true do
1066
1097
  node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
1067
1098
  json = Chef::JSONCompat.to_json(node)
1068
1099
  serialized_node = Chef::JSONCompat.from_json(json)
1069
- serialized_node.should be_a_kind_of(Chef::Node)
1070
- serialized_node.name.should eql(node.name)
1071
- serialized_node.chef_environment.should eql(node.chef_environment)
1100
+ expect(serialized_node).to be_a_kind_of(Chef::Node)
1101
+ expect(serialized_node.name).to eql(node.name)
1102
+ expect(serialized_node.chef_environment).to eql(node.chef_environment)
1072
1103
  node.each_attribute do |k,v|
1073
- serialized_node[k].should eql(v)
1104
+ expect(serialized_node[k]).to eql(v)
1074
1105
  end
1075
- serialized_node.run_list.should == node.run_list
1106
+ expect(serialized_node.run_list).to eq(node.run_list)
1076
1107
  end
1077
1108
 
1078
1109
  include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
@@ -1086,45 +1117,45 @@ describe Chef::Node do
1086
1117
  describe "to_s" do
1087
1118
  it "should turn into a string like node[name]" do
1088
1119
  node.name("airplane")
1089
- node.to_s.should eql("node[airplane]")
1120
+ expect(node.to_s).to eql("node[airplane]")
1090
1121
  end
1091
1122
  end
1092
1123
 
1093
1124
  describe "api model" do
1094
1125
  before(:each) do
1095
1126
  @rest = double("Chef::REST")
1096
- Chef::REST.stub(:new).and_return(@rest)
1127
+ allow(Chef::REST).to receive(:new).and_return(@rest)
1097
1128
  @query = double("Chef::Search::Query")
1098
- Chef::Search::Query.stub(:new).and_return(@query)
1129
+ allow(Chef::Search::Query).to receive(:new).and_return(@query)
1099
1130
  end
1100
1131
 
1101
1132
  describe "list" do
1102
1133
  describe "inflated" do
1103
1134
  it "should return a hash of node names and objects" do
1104
1135
  n1 = double("Chef::Node", :name => "one")
1105
- @query.should_receive(:search).with(:node).and_yield(n1)
1136
+ expect(@query).to receive(:search).with(:node).and_yield(n1)
1106
1137
  r = Chef::Node.list(true)
1107
- r["one"].should == n1
1138
+ expect(r["one"]).to eq(n1)
1108
1139
  end
1109
1140
  end
1110
1141
 
1111
1142
  it "should return a hash of node names and urls" do
1112
- @rest.should_receive(:get_rest).and_return({ "one" => "http://foo" })
1143
+ expect(@rest).to receive(:get_rest).and_return({ "one" => "http://foo" })
1113
1144
  r = Chef::Node.list
1114
- r["one"].should == "http://foo"
1145
+ expect(r["one"]).to eq("http://foo")
1115
1146
  end
1116
1147
  end
1117
1148
 
1118
1149
  describe "load" do
1119
1150
  it "should load a node by name" do
1120
- @rest.should_receive(:get_rest).with("nodes/monkey").and_return("foo")
1121
- Chef::Node.load("monkey").should == "foo"
1151
+ expect(@rest).to receive(:get_rest).with("nodes/monkey").and_return("foo")
1152
+ expect(Chef::Node.load("monkey")).to eq("foo")
1122
1153
  end
1123
1154
  end
1124
1155
 
1125
1156
  describe "destroy" do
1126
1157
  it "should destroy a node" do
1127
- @rest.should_receive(:delete_rest).with("nodes/monkey").and_return("foo")
1158
+ expect(@rest).to receive(:delete_rest).with("nodes/monkey").and_return("foo")
1128
1159
  node.name("monkey")
1129
1160
  node.destroy
1130
1161
  end
@@ -1133,25 +1164,25 @@ describe Chef::Node do
1133
1164
  describe "save" do
1134
1165
  it "should update a node if it already exists" do
1135
1166
  node.name("monkey")
1136
- node.stub(:data_for_save).and_return({})
1137
- @rest.should_receive(:put_rest).with("nodes/monkey", {}).and_return("foo")
1167
+ allow(node).to receive(:data_for_save).and_return({})
1168
+ expect(@rest).to receive(:put_rest).with("nodes/monkey", {}).and_return("foo")
1138
1169
  node.save
1139
1170
  end
1140
1171
 
1141
1172
  it "should not try and create if it can update" do
1142
1173
  node.name("monkey")
1143
- node.stub(:data_for_save).and_return({})
1144
- @rest.should_receive(:put_rest).with("nodes/monkey", {}).and_return("foo")
1145
- @rest.should_not_receive(:post_rest)
1174
+ allow(node).to receive(:data_for_save).and_return({})
1175
+ expect(@rest).to receive(:put_rest).with("nodes/monkey", {}).and_return("foo")
1176
+ expect(@rest).not_to receive(:post_rest)
1146
1177
  node.save
1147
1178
  end
1148
1179
 
1149
1180
  it "should create if it cannot update" do
1150
1181
  node.name("monkey")
1151
- node.stub(:data_for_save).and_return({})
1182
+ allow(node).to receive(:data_for_save).and_return({})
1152
1183
  exception = double("404 error", :code => "404")
1153
- @rest.should_receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception))
1154
- @rest.should_receive(:post_rest).with("nodes", {})
1184
+ expect(@rest).to receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception))
1185
+ expect(@rest).to receive(:post_rest).with("nodes", {})
1155
1186
  node.save
1156
1187
  end
1157
1188
 
@@ -1164,8 +1195,8 @@ describe Chef::Node do
1164
1195
  end
1165
1196
  it "should not save" do
1166
1197
  node.name("monkey")
1167
- @rest.should_not_receive(:put_rest)
1168
- @rest.should_not_receive(:post_rest)
1198
+ expect(@rest).not_to receive(:put_rest)
1199
+ expect(@rest).not_to receive(:post_rest)
1169
1200
  node.save
1170
1201
  end
1171
1202
  end
@@ -1208,8 +1239,8 @@ describe Chef::Node do
1208
1239
  }
1209
1240
 
1210
1241
  node.name("picky-monkey")
1211
- node.stub(:for_json).and_return(data)
1212
- @rest.should_receive(:put_rest).with("nodes/picky-monkey", selected_data).and_return("foo")
1242
+ allow(node).to receive(:for_json).and_return(data)
1243
+ expect(@rest).to receive(:put_rest).with("nodes/picky-monkey", selected_data).and_return("foo")
1213
1244
  node.save
1214
1245
  end
1215
1246
 
@@ -1265,8 +1296,8 @@ describe Chef::Node do
1265
1296
  }
1266
1297
 
1267
1298
  node.name("picky-monkey")
1268
- node.stub(:for_json).and_return(data)
1269
- @rest.should_receive(:put_rest).with("nodes/picky-monkey", selected_data).and_return("foo")
1299
+ allow(node).to receive(:for_json).and_return(data)
1300
+ expect(@rest).to receive(:put_rest).with("nodes/picky-monkey", selected_data).and_return("foo")
1270
1301
  node.save
1271
1302
  end
1272
1303
  end