chef 12.0.0.alpha.2-x86-mingw32 → 12.0.0.rc.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (628) hide show
  1. data/CONTRIBUTING.md +9 -0
  2. data/README.md +1 -1
  3. data/Rakefile +12 -0
  4. data/bin/chef-service-manager +1 -1
  5. data/bin/chef-windows-service +35 -0
  6. data/distro/common/html/_sources/ctl_chef_server.txt +307 -10
  7. data/distro/common/html/ctl_chef_client.html +3 -7
  8. data/distro/common/html/ctl_chef_server.html +609 -41
  9. data/distro/common/html/ctl_chef_shell.html +2 -2
  10. data/distro/common/html/ctl_chef_solo.html +1 -1
  11. data/distro/common/html/index.html +13 -13
  12. data/distro/common/html/knife.html +10 -10
  13. data/distro/common/html/knife_bootstrap.html +8 -8
  14. data/distro/common/html/knife_client.html +12 -12
  15. data/distro/common/html/knife_common_options.html +7 -7
  16. data/distro/common/html/knife_configure.html +3 -3
  17. data/distro/common/html/knife_cookbook.html +19 -19
  18. data/distro/common/html/knife_cookbook_site.html +28 -28
  19. data/distro/common/html/knife_data_bag.html +28 -13
  20. data/distro/common/html/knife_delete.html +2 -2
  21. data/distro/common/html/knife_deps.html +3 -3
  22. data/distro/common/html/knife_diff.html +4 -4
  23. data/distro/common/html/knife_download.html +3 -3
  24. data/distro/common/html/knife_edit.html +2 -2
  25. data/distro/common/html/knife_environment.html +14 -14
  26. data/distro/common/html/knife_exec.html +11 -11
  27. data/distro/common/html/knife_index_rebuild.html +2 -2
  28. data/distro/common/html/knife_list.html +3 -3
  29. data/distro/common/html/knife_node.html +23 -23
  30. data/distro/common/html/knife_raw.html +4 -4
  31. data/distro/common/html/knife_recipe_list.html +3 -3
  32. data/distro/common/html/knife_role.html +11 -11
  33. data/distro/common/html/knife_search.html +4 -4
  34. data/distro/common/html/knife_serve.html +3 -3
  35. data/distro/common/html/knife_show.html +3 -3
  36. data/distro/common/html/knife_ssh.html +7 -7
  37. data/distro/common/html/knife_ssl_check.html +7 -7
  38. data/distro/common/html/knife_ssl_fetch.html +9 -9
  39. data/distro/common/html/knife_status.html +3 -3
  40. data/distro/common/html/knife_tag.html +9 -9
  41. data/distro/common/html/knife_upload.html +3 -3
  42. data/distro/common/html/knife_user.html +9 -9
  43. data/distro/common/html/knife_using.html +11 -11
  44. data/distro/common/html/knife_xargs.html +14 -5
  45. data/distro/common/html/search.html +2 -2
  46. data/distro/common/html/searchindex.js +1 -1
  47. data/distro/common/man/man1/chef-shell.1 +2 -2
  48. data/distro/common/man/man1/knife-bootstrap.1 +7 -7
  49. data/distro/common/man/man1/knife-client.1 +10 -10
  50. data/distro/common/man/man1/knife-configure.1 +5 -5
  51. data/distro/common/man/man1/knife-cookbook-site.1 +24 -24
  52. data/distro/common/man/man1/knife-cookbook.1 +12 -12
  53. data/distro/common/man/man1/knife-data-bag.1 +34 -10
  54. data/distro/common/man/man1/knife-delete.1 +5 -5
  55. data/distro/common/man/man1/knife-deps.1 +5 -5
  56. data/distro/common/man/man1/knife-diff.1 +7 -7
  57. data/distro/common/man/man1/knife-download.1 +5 -5
  58. data/distro/common/man/man1/knife-edit.1 +5 -5
  59. data/distro/common/man/man1/knife-environment.1 +11 -11
  60. data/distro/common/man/man1/knife-exec.1 +11 -11
  61. data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
  62. data/distro/common/man/man1/knife-list.1 +5 -5
  63. data/distro/common/man/man1/knife-node.1 +16 -16
  64. data/distro/common/man/man1/knife-raw.1 +6 -6
  65. data/distro/common/man/man1/knife-recipe-list.1 +1 -1
  66. data/distro/common/man/man1/knife-role.1 +7 -7
  67. data/distro/common/man/man1/knife-search.1 +6 -6
  68. data/distro/common/man/man1/knife-serve.1 +6 -6
  69. data/distro/common/man/man1/knife-show.1 +5 -5
  70. data/distro/common/man/man1/knife-ssh.1 +9 -9
  71. data/distro/common/man/man1/knife-ssl-check.1 +7 -7
  72. data/distro/common/man/man1/knife-ssl-fetch.1 +9 -9
  73. data/distro/common/man/man1/knife-status.1 +5 -5
  74. data/distro/common/man/man1/knife-tag.1 +8 -8
  75. data/distro/common/man/man1/knife-upload.1 +5 -5
  76. data/distro/common/man/man1/knife-user.1 +8 -8
  77. data/distro/common/man/man1/knife-xargs.1 +36 -10
  78. data/distro/common/man/man1/knife.1 +14 -14
  79. data/distro/common/man/man8/chef-client.8 +3 -10
  80. data/distro/common/man/man8/chef-solo.8 +1 -1
  81. data/ext/win32-eventlog/Rakefile +50 -0
  82. data/ext/win32-eventlog/chef-log.man +26 -0
  83. data/lib/chef/application.rb +313 -241
  84. data/lib/chef/application/apply.rb +10 -8
  85. data/lib/chef/application/client.rb +58 -33
  86. data/lib/chef/application/solo.rb +33 -12
  87. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  88. data/lib/chef/chef_fs/command_line.rb +1 -1
  89. data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +2 -1
  90. data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -1
  91. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +2 -1
  92. data/lib/chef/client.rb +18 -48
  93. data/lib/chef/config.rb +43 -11
  94. data/lib/chef/cookbook/cookbook_version_loader.rb +14 -7
  95. data/lib/chef/cookbook/metadata.rb +81 -38
  96. data/lib/chef/cookbook/syntax_check.rb +18 -52
  97. data/lib/chef/cookbook_loader.rb +1 -1
  98. data/lib/chef/cookbook_version.rb +58 -39
  99. data/lib/chef/data_bag.rb +2 -2
  100. data/lib/chef/deprecation/provider/file.rb +2 -1
  101. data/lib/chef/dsl/data_query.rb +2 -29
  102. data/lib/chef/dsl/recipe.rb +8 -22
  103. data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
  104. data/lib/chef/encrypted_data_bag_item/check_encrypted.rb +56 -0
  105. data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +1 -1
  106. data/lib/chef/event_loggers/base.rb +62 -0
  107. data/lib/chef/event_loggers/windows_eventlog.rb +104 -0
  108. data/lib/chef/exceptions.rb +18 -1
  109. data/lib/chef/file_cache.rb +3 -2
  110. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +15 -6
  111. data/lib/chef/http.rb +20 -13
  112. data/lib/chef/http/ssl_policies.rb +2 -1
  113. data/lib/chef/json_compat.rb +9 -3
  114. data/lib/chef/knife.rb +2 -1
  115. data/lib/chef/knife/bootstrap.rb +12 -18
  116. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  117. data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
  118. data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
  119. data/lib/chef/knife/cookbook_create.rb +1 -1
  120. data/lib/chef/knife/cookbook_site_share.rb +43 -8
  121. data/lib/chef/knife/core/bootstrap_context.rb +6 -11
  122. data/lib/chef/knife/core/object_loader.rb +5 -5
  123. data/lib/chef/knife/core/status_presenter.rb +156 -0
  124. data/lib/chef/knife/core/subcommand_loader.rb +6 -5
  125. data/lib/chef/knife/core/ui.rb +4 -4
  126. data/lib/chef/knife/data_bag_create.rb +7 -32
  127. data/lib/chef/knife/data_bag_edit.rb +24 -43
  128. data/lib/chef/knife/data_bag_from_file.rb +6 -31
  129. data/lib/chef/knife/data_bag_secret_options.rb +142 -0
  130. data/lib/chef/knife/data_bag_show.rb +19 -33
  131. data/lib/chef/knife/node_from_file.rb +9 -8
  132. data/lib/chef/knife/ssh.rb +0 -7
  133. data/lib/chef/knife/ssl_check.rb +70 -6
  134. data/lib/chef/knife/status.rb +11 -58
  135. data/lib/chef/mixin/command/unix.rb +2 -2
  136. data/lib/chef/mixin/convert_to_class_name.rb +54 -0
  137. data/lib/chef/mixin/descendants_tracker.rb +82 -0
  138. data/lib/chef/mixin/homebrew_user.rb +68 -0
  139. data/lib/chef/mixin/shell_out.rb +0 -4
  140. data/lib/chef/mixin/windows_architecture_helper.rb +16 -0
  141. data/lib/chef/mixin/windows_env_helper.rb +56 -0
  142. data/lib/chef/node.rb +2 -2
  143. data/lib/chef/node_map.rb +146 -0
  144. data/lib/chef/platform/provider_mapping.rb +11 -39
  145. data/lib/chef/platform/provider_priority_map.rb +80 -0
  146. data/lib/chef/platform/query_helpers.rb +5 -1
  147. data/lib/chef/platform/service_helpers.rb +113 -0
  148. data/lib/chef/provider.rb +24 -0
  149. data/lib/chef/provider/breakpoint.rb +2 -0
  150. data/lib/chef/provider/cookbook_file.rb +2 -0
  151. data/lib/chef/provider/cron.rb +1 -1
  152. data/lib/chef/provider/cron/unix.rb +13 -9
  153. data/lib/chef/provider/deploy.rb +3 -2
  154. data/lib/chef/provider/deploy/revision.rb +4 -2
  155. data/lib/chef/provider/deploy/timestamped.rb +2 -0
  156. data/lib/chef/provider/directory.rb +2 -0
  157. data/lib/chef/provider/dsc_script.rb +179 -0
  158. data/lib/chef/provider/env.rb +25 -10
  159. data/lib/chef/provider/env/windows.rb +9 -16
  160. data/lib/chef/provider/erl_call.rb +2 -0
  161. data/lib/chef/provider/execute.rb +5 -2
  162. data/lib/chef/provider/file.rb +2 -0
  163. data/lib/chef/provider/git.rb +51 -23
  164. data/lib/chef/provider/group/dscl.rb +2 -2
  165. data/lib/chef/provider/group/pw.rb +9 -13
  166. data/lib/chef/provider/http_request.rb +2 -0
  167. data/lib/chef/provider/link.rb +3 -0
  168. data/lib/chef/provider/log.rb +2 -0
  169. data/lib/chef/provider/lwrp_base.rb +11 -9
  170. data/lib/chef/provider/mount/mount.rb +1 -1
  171. data/lib/chef/provider/package/aix.rb +2 -0
  172. data/lib/chef/provider/package/apt.rb +2 -0
  173. data/lib/chef/provider/package/dpkg.rb +2 -0
  174. data/lib/chef/provider/package/easy_install.rb +2 -0
  175. data/lib/chef/provider/package/freebsd/pkg.rb +2 -1
  176. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  177. data/lib/chef/provider/package/freebsd/port.rb +1 -9
  178. data/lib/chef/provider/package/homebrew.rb +127 -0
  179. data/lib/chef/provider/package/ips.rb +2 -0
  180. data/lib/chef/provider/package/macports.rb +3 -0
  181. data/lib/chef/provider/package/pacman.rb +5 -4
  182. data/lib/chef/provider/package/paludis.rb +4 -2
  183. data/lib/chef/provider/package/portage.rb +4 -1
  184. data/lib/chef/provider/package/rpm.rb +2 -0
  185. data/lib/chef/provider/package/rubygems.rb +4 -0
  186. data/lib/chef/provider/package/smartos.rb +2 -0
  187. data/lib/chef/provider/package/solaris.rb +2 -0
  188. data/lib/chef/provider/package/windows.rb +5 -2
  189. data/lib/chef/provider/package/yum.rb +2 -0
  190. data/lib/chef/provider/powershell_script.rb +3 -1
  191. data/lib/chef/provider/remote_directory.rb +25 -10
  192. data/lib/chef/provider/route.rb +2 -0
  193. data/lib/chef/provider/ruby_block.rb +2 -0
  194. data/lib/chef/provider/script.rb +6 -0
  195. data/lib/chef/provider/service/aix.rb +128 -0
  196. data/lib/chef/provider/service/aixinit.rb +117 -0
  197. data/lib/chef/provider/service/arch.rb +6 -0
  198. data/lib/chef/provider/service/debian.rb +35 -29
  199. data/lib/chef/provider/service/freebsd.rb +7 -1
  200. data/lib/chef/provider/service/gentoo.rb +5 -1
  201. data/lib/chef/provider/service/init.rb +2 -0
  202. data/lib/chef/provider/service/insserv.rb +15 -8
  203. data/lib/chef/provider/service/invokercd.rb +6 -0
  204. data/lib/chef/provider/service/macosx.rb +4 -1
  205. data/lib/chef/provider/service/redhat.rb +9 -3
  206. data/lib/chef/provider/service/simple.rb +2 -0
  207. data/lib/chef/provider/service/solaris.rb +2 -0
  208. data/lib/chef/provider/service/systemd.rb +7 -0
  209. data/lib/chef/provider/service/upstart.rb +7 -0
  210. data/lib/chef/provider/service/windows.rb +5 -0
  211. data/lib/chef/provider/subversion.rb +2 -0
  212. data/lib/chef/provider/template.rb +1 -0
  213. data/lib/chef/provider/user/dscl.rb +3 -2
  214. data/lib/chef/provider/whyrun_safe_ruby_block.rb +2 -0
  215. data/lib/chef/provider_resolver.rb +103 -0
  216. data/lib/chef/providers.rb +6 -2
  217. data/lib/chef/recipe.rb +2 -0
  218. data/lib/chef/resource.rb +69 -78
  219. data/lib/chef/resource/apt_package.rb +3 -1
  220. data/lib/chef/resource/bash.rb +1 -0
  221. data/lib/chef/resource/bff_package.rb +0 -1
  222. data/lib/chef/resource/breakpoint.rb +1 -1
  223. data/lib/chef/resource/chef_gem.rb +1 -2
  224. data/lib/chef/resource/conditional.rb +26 -6
  225. data/lib/chef/resource/cookbook_file.rb +2 -3
  226. data/lib/chef/resource/csh.rb +1 -0
  227. data/lib/chef/resource/deploy.rb +0 -1
  228. data/lib/chef/resource/deploy_revision.rb +6 -1
  229. data/lib/chef/resource/directory.rb +1 -2
  230. data/lib/chef/resource/dpkg_package.rb +2 -1
  231. data/lib/chef/resource/dsc_script.rb +125 -0
  232. data/lib/chef/resource/easy_install_package.rb +2 -1
  233. data/lib/chef/resource/erl_call.rb +1 -0
  234. data/lib/chef/resource/execute.rb +26 -9
  235. data/lib/chef/resource/file.rb +1 -3
  236. data/lib/chef/resource/freebsd_package.rb +10 -23
  237. data/lib/chef/resource/gem_package.rb +2 -1
  238. data/lib/chef/resource/git.rb +2 -1
  239. data/lib/chef/resource/homebrew_package.rb +46 -0
  240. data/lib/chef/resource/http_request.rb +1 -0
  241. data/lib/chef/resource/ips_package.rb +3 -1
  242. data/lib/chef/resource/link.rb +1 -2
  243. data/lib/chef/resource/log.rb +4 -0
  244. data/lib/chef/resource/lwrp_base.rb +24 -15
  245. data/lib/chef/resource/macports_package.rb +3 -1
  246. data/lib/chef/resource/pacman_package.rb +2 -1
  247. data/lib/chef/resource/paludis_package.rb +3 -1
  248. data/lib/chef/resource/perl.rb +1 -0
  249. data/lib/chef/resource/powershell_script.rb +0 -2
  250. data/lib/chef/resource/python.rb +1 -1
  251. data/lib/chef/resource/remote_directory.rb +1 -2
  252. data/lib/chef/resource/remote_file.rb +1 -1
  253. data/lib/chef/resource/rpm_package.rb +2 -1
  254. data/lib/chef/resource/ruby.rb +1 -0
  255. data/lib/chef/resource/ruby_block.rb +3 -0
  256. data/lib/chef/resource/script.rb +2 -25
  257. data/lib/chef/resource/service.rb +0 -4
  258. data/lib/chef/resource/smartos_package.rb +3 -4
  259. data/lib/chef/resource/solaris_package.rb +7 -1
  260. data/lib/chef/resource/subversion.rb +0 -1
  261. data/lib/chef/resource/template.rb +2 -3
  262. data/lib/chef/resource/timestamped_deploy.rb +1 -2
  263. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  264. data/lib/chef/resource/windows_package.rb +3 -4
  265. data/lib/chef/resource/windows_script.rb +3 -0
  266. data/lib/chef/resource/windows_service.rb +2 -2
  267. data/lib/chef/resource/yum_package.rb +3 -1
  268. data/lib/chef/resource_collection.rb +50 -227
  269. data/lib/chef/resource_collection/resource_collection_serialization.rb +59 -0
  270. data/lib/chef/resource_collection/resource_list.rb +89 -0
  271. data/lib/chef/resource_collection/resource_set.rb +170 -0
  272. data/lib/chef/resources.rb +2 -0
  273. data/lib/chef/role.rb +1 -1
  274. data/lib/chef/run_context.rb +5 -1
  275. data/lib/chef/shell/ext.rb +1 -1
  276. data/lib/chef/util/backup.rb +3 -2
  277. data/lib/chef/util/dsc/configuration_generator.rb +115 -0
  278. data/lib/chef/util/dsc/lcm_output_parser.rb +133 -0
  279. data/lib/chef/util/dsc/local_configuration_manager.rb +141 -0
  280. data/lib/chef/util/dsc/resource_info.rb +26 -0
  281. data/lib/chef/util/path_helper.rb +12 -0
  282. data/lib/chef/util/powershell/cmdlet.rb +136 -0
  283. data/lib/chef/util/powershell/cmdlet_result.rb +46 -0
  284. data/lib/chef/version.rb +1 -1
  285. data/lib/chef/win32/api/system.rb +9 -0
  286. data/lib/chef/win32/version.rb +2 -0
  287. data/spec/.DS_Store +0 -0
  288. data/spec/data/.DS_Store +0 -0
  289. data/spec/data/bootstrap/test-hints.erb +1 -1
  290. data/spec/data/bootstrap/test.erb +1 -1
  291. data/spec/data/cb_version_cookbooks/cookbook2/files/test.txt +0 -0
  292. data/spec/data/cb_version_cookbooks/cookbook2/templates/test.erb +0 -0
  293. data/spec/data/cookbooks/ignorken/files/default/not_me.rb +2 -0
  294. data/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb +2 -0
  295. data/spec/data/cookbooks/openldap/libraries/openldap.rb +4 -0
  296. data/spec/data/cookbooks/openldap/libraries/openldap/version.rb +3 -0
  297. data/spec/data/lwrp/.DS_Store +0 -0
  298. data/spec/data/lwrp/providers/.DS_Store +0 -0
  299. data/spec/data/lwrp/providers/buck_passer.rb +9 -2
  300. data/spec/data/lwrp/resources/.DS_Store +0 -0
  301. data/spec/data/lwrp/resources/foo.rb +3 -2
  302. data/spec/data/lwrp_override/.DS_Store +0 -0
  303. data/spec/data/lwrp_override/providers/.DS_Store +0 -0
  304. data/spec/data/lwrp_override/providers/buck_passer.rb +5 -10
  305. data/spec/data/lwrp_override/resources/.DS_Store +0 -0
  306. data/spec/data/lwrp_override/resources/foo.rb +4 -3
  307. data/spec/functional/assets/chefinittest +34 -0
  308. data/spec/functional/assets/testchefsubsys +11 -0
  309. data/spec/functional/dsl/reboot_pending_spec.rb +19 -16
  310. data/spec/functional/event_loggers/windows_eventlog_spec.rb +82 -0
  311. data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
  312. data/spec/functional/knife/exec_spec.rb +1 -1
  313. data/spec/functional/resource/aix_service_spec.rb +136 -0
  314. data/spec/functional/resource/aixinit_service_spec.rb +211 -0
  315. data/spec/functional/resource/base.rb +1 -0
  316. data/spec/functional/resource/batch_spec.rb +4 -11
  317. data/spec/functional/resource/cron_spec.rb +7 -1
  318. data/spec/functional/resource/dsc_script_spec.rb +382 -0
  319. data/spec/functional/resource/env_spec.rb +54 -0
  320. data/spec/functional/resource/execute_spec.rb +113 -0
  321. data/spec/functional/resource/file_spec.rb +2 -0
  322. data/spec/functional/resource/group_spec.rb +7 -4
  323. data/spec/functional/resource/powershell_spec.rb +198 -185
  324. data/spec/functional/resource/rpm_spec.rb +5 -4
  325. data/spec/functional/resource/user/dscl_spec.rb +2 -1
  326. data/spec/functional/util/path_helper_spec.rb +37 -0
  327. data/spec/functional/util/powershell/cmdlet_spec.rb +114 -0
  328. data/spec/integration/client/client_spec.rb +1 -1
  329. data/spec/integration/client/ipv6_spec.rb +1 -1
  330. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
  331. data/spec/integration/knife/chef_repo_path_spec.rb +1 -1
  332. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
  333. data/spec/integration/knife/chefignore_spec.rb +1 -1
  334. data/spec/integration/knife/common_options_spec.rb +1 -1
  335. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
  336. data/spec/integration/knife/delete_spec.rb +1 -1
  337. data/spec/integration/knife/deps_spec.rb +1 -1
  338. data/spec/integration/knife/diff_spec.rb +1 -1
  339. data/spec/integration/knife/download_spec.rb +1 -1
  340. data/spec/integration/knife/list_spec.rb +1 -1
  341. data/spec/integration/knife/raw_spec.rb +1 -1
  342. data/spec/integration/knife/redirection_spec.rb +1 -1
  343. data/spec/integration/knife/serve_spec.rb +1 -1
  344. data/spec/integration/knife/show_spec.rb +1 -1
  345. data/spec/integration/knife/upload_spec.rb +4 -3
  346. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  347. data/spec/spec_helper.rb +15 -0
  348. data/spec/support/chef_helpers.rb +1 -0
  349. data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
  350. data/spec/support/lib/chef/resource/zen_follower.rb +1 -7
  351. data/spec/support/platform_helpers.rb +28 -0
  352. data/spec/support/shared/functional/file_resource.rb +6 -0
  353. data/spec/support/shared/functional/windows_script.rb +118 -0
  354. data/spec/support/shared/integration/integration_helper.rb +5 -2
  355. data/spec/support/shared/matchers/exit_with_code.rb +28 -0
  356. data/spec/support/shared/matchers/match_environment_variable.rb +17 -0
  357. data/spec/support/shared/shared_examples.rb +14 -0
  358. data/spec/support/shared/unit/execute_resource.rb +0 -7
  359. data/spec/support/shared/unit/resource/static_provider_resolution.rb +71 -0
  360. data/spec/support/shared/unit/script_resource.rb +1 -1
  361. data/spec/support/shared/unit/windows_script_resource.rb +35 -2
  362. data/spec/tiny_server.rb +1 -2
  363. data/spec/unit/api_client_spec.rb +5 -1
  364. data/spec/unit/application/{apply.rb → apply_spec.rb} +13 -5
  365. data/spec/unit/application/client_spec.rb +106 -13
  366. data/spec/unit/application/solo_spec.rb +25 -1
  367. data/spec/unit/client_spec.rb +1 -26
  368. data/spec/unit/config_fetcher_spec.rb +2 -1
  369. data/spec/unit/config_spec.rb +91 -2
  370. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +8 -0
  371. data/spec/unit/cookbook/metadata_spec.rb +43 -6
  372. data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
  373. data/spec/unit/cookbook_loader_spec.rb +4 -2
  374. data/spec/unit/cookbook_version_spec.rb +83 -2
  375. data/spec/unit/data_bag_item_spec.rb +5 -1
  376. data/spec/unit/data_bag_spec.rb +6 -1
  377. data/spec/unit/dsl/data_query_spec.rb +8 -110
  378. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +95 -0
  379. data/spec/unit/encrypted_data_bag_item_spec.rb +16 -23
  380. data/spec/unit/environment_spec.rb +6 -2
  381. data/spec/unit/exceptions_spec.rb +6 -0
  382. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +16 -15
  383. data/spec/unit/json_compat_spec.rb +12 -2
  384. data/spec/unit/knife/bootstrap_spec.rb +16 -63
  385. data/spec/unit/knife/cookbook_site_share_spec.rb +59 -6
  386. data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -37
  387. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
  388. data/spec/unit/knife/core/ui_spec.rb +28 -0
  389. data/spec/unit/knife/data_bag_create_spec.rb +63 -71
  390. data/spec/unit/knife/data_bag_edit_spec.rb +83 -49
  391. data/spec/unit/knife/data_bag_from_file_spec.rb +104 -126
  392. data/spec/unit/knife/data_bag_secret_options_spec.rb +165 -0
  393. data/spec/unit/knife/data_bag_show_spec.rb +74 -72
  394. data/spec/unit/knife/environment_from_file_spec.rb +3 -2
  395. data/spec/unit/knife/ssl_check_spec.rb +46 -1
  396. data/spec/unit/knife/status_spec.rb +1 -2
  397. data/spec/unit/knife_spec.rb +18 -1
  398. data/spec/unit/lwrp_spec.rb +29 -8
  399. data/spec/unit/mixin/homebrew_user_spec.rb +100 -0
  400. data/spec/unit/node_map_spec.rb +155 -0
  401. data/spec/unit/node_spec.rb +11 -0
  402. data/spec/unit/platform/query_helpers_spec.rb +23 -0
  403. data/spec/unit/platform_spec.rb +23 -0
  404. data/spec/unit/provider/breakpoint_spec.rb +9 -9
  405. data/spec/unit/provider/cookbook_file/content_spec.rb +3 -3
  406. data/spec/unit/provider/cookbook_file_spec.rb +1 -1
  407. data/spec/unit/provider/cron/unix_spec.rb +78 -60
  408. data/spec/unit/provider/cron_spec.rb +175 -175
  409. data/spec/unit/provider/deploy/revision_spec.rb +22 -21
  410. data/spec/unit/provider/deploy/timestamped_spec.rb +3 -3
  411. data/spec/unit/provider/deploy_spec.rb +231 -230
  412. data/spec/unit/provider/directory_spec.rb +55 -55
  413. data/spec/unit/provider/dsc_script_spec.rb +174 -0
  414. data/spec/unit/provider/env/windows_spec.rb +70 -34
  415. data/spec/unit/provider/env_spec.rb +95 -49
  416. data/spec/unit/provider/erl_call_spec.rb +9 -9
  417. data/spec/unit/provider/execute_spec.rb +43 -27
  418. data/spec/unit/provider/file/content_spec.rb +9 -9
  419. data/spec/unit/provider/file_spec.rb +1 -1
  420. data/spec/unit/provider/git_spec.rb +221 -159
  421. data/spec/unit/provider/group/dscl_spec.rb +64 -63
  422. data/spec/unit/provider/group/gpasswd_spec.rb +14 -14
  423. data/spec/unit/provider/group/groupadd_spec.rb +33 -33
  424. data/spec/unit/provider/group/groupmod_spec.rb +23 -23
  425. data/spec/unit/provider/group/pw_spec.rb +21 -21
  426. data/spec/unit/provider/group/usermod_spec.rb +20 -20
  427. data/spec/unit/provider/group/windows_spec.rb +15 -15
  428. data/spec/unit/provider/group_spec.rb +76 -76
  429. data/spec/unit/provider/http_request_spec.rb +30 -30
  430. data/spec/unit/provider/ifconfig/aix_spec.rb +20 -20
  431. data/spec/unit/provider/ifconfig/debian_spec.rb +25 -9
  432. data/spec/unit/provider/ifconfig/redhat_spec.rb +13 -13
  433. data/spec/unit/provider/ifconfig_spec.rb +43 -43
  434. data/spec/unit/provider/link_spec.rb +60 -60
  435. data/spec/unit/provider/log_spec.rb +0 -4
  436. data/spec/unit/provider/mdadm_spec.rb +23 -23
  437. data/spec/unit/provider/mount/aix_spec.rb +17 -17
  438. data/spec/unit/provider/mount/mount_spec.rb +115 -119
  439. data/spec/unit/provider/mount/solaris_spec.rb +72 -72
  440. data/spec/unit/provider/mount/windows_spec.rb +24 -24
  441. data/spec/unit/provider/ohai_spec.rb +11 -11
  442. data/spec/unit/provider/package/aix_spec.rb +34 -34
  443. data/spec/unit/provider/package/apt_spec.rb +36 -36
  444. data/spec/unit/provider/package/dpkg_spec.rb +27 -27
  445. data/spec/unit/provider/package/easy_install_spec.rb +16 -16
  446. data/spec/unit/provider/package/freebsd/pkg_spec.rb +53 -53
  447. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +24 -24
  448. data/spec/unit/provider/package/freebsd/port_spec.rb +45 -35
  449. data/spec/unit/provider/package/homebrew_spec.rb +266 -0
  450. data/spec/unit/provider/package/ips_spec.rb +34 -34
  451. data/spec/unit/provider/package/macports_spec.rb +49 -49
  452. data/spec/unit/provider/package/pacman_spec.rb +35 -39
  453. data/spec/unit/provider/package/paludis_spec.rb +20 -20
  454. data/spec/unit/provider/package/portage_spec.rb +38 -38
  455. data/spec/unit/provider/package/rpm_spec.rb +29 -29
  456. data/spec/unit/provider/package/rubygems_spec.rb +284 -270
  457. data/spec/unit/provider/package/smartos_spec.rb +15 -15
  458. data/spec/unit/provider/package/solaris_spec.rb +35 -35
  459. data/spec/unit/provider/package/windows/msi_spec.rb +3 -3
  460. data/spec/unit/provider/package/windows_spec.rb +6 -6
  461. data/spec/unit/provider/package/yum_spec.rb +416 -416
  462. data/spec/unit/provider/package/zypper_spec.rb +47 -47
  463. data/spec/unit/provider/package_spec.rb +107 -107
  464. data/spec/unit/provider/powershell_spec.rb +1 -1
  465. data/spec/unit/provider/registry_key_spec.rb +61 -61
  466. data/spec/unit/provider/remote_directory_spec.rb +36 -36
  467. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +24 -24
  468. data/spec/unit/provider/remote_file/content_spec.rb +45 -45
  469. data/spec/unit/provider/remote_file/fetcher_spec.rb +9 -9
  470. data/spec/unit/provider/remote_file/ftp_spec.rb +32 -32
  471. data/spec/unit/provider/remote_file/http_spec.rb +44 -44
  472. data/spec/unit/provider/remote_file/local_file_spec.rb +9 -9
  473. data/spec/unit/provider/remote_file_spec.rb +3 -3
  474. data/spec/unit/provider/route_spec.rb +63 -63
  475. data/spec/unit/provider/ruby_block_spec.rb +4 -4
  476. data/spec/unit/provider/script_spec.rb +12 -12
  477. data/spec/unit/provider/service/aix_service_spec.rb +181 -0
  478. data/spec/unit/provider/service/aixinit_service_spec.rb +269 -0
  479. data/spec/unit/provider/service/arch_service_spec.rb +48 -48
  480. data/spec/unit/provider/service/debian_service_spec.rb +40 -40
  481. data/spec/unit/provider/service/gentoo_service_spec.rb +28 -28
  482. data/spec/unit/provider/service/init_service_spec.rb +39 -39
  483. data/spec/unit/provider/service/insserv_service_spec.rb +8 -8
  484. data/spec/unit/provider/service/invokercd_service_spec.rb +35 -35
  485. data/spec/unit/provider/service/macosx_spec.rb +49 -49
  486. data/spec/unit/provider/service/redhat_spec.rb +27 -27
  487. data/spec/unit/provider/service/simple_service_spec.rb +28 -28
  488. data/spec/unit/provider/service/solaris_smf_service_spec.rb +43 -46
  489. data/spec/unit/provider/service/systemd_service_spec.rb +63 -63
  490. data/spec/unit/provider/service/upstart_service_spec.rb +78 -78
  491. data/spec/unit/provider/service/windows_spec.rb +92 -92
  492. data/spec/unit/provider/service_spec.rb +40 -40
  493. data/spec/unit/provider/subversion_spec.rb +80 -80
  494. data/spec/unit/provider/template/content_spec.rb +9 -9
  495. data/spec/unit/provider/template_spec.rb +6 -6
  496. data/spec/unit/provider/user/dscl_spec.rb +170 -167
  497. data/spec/unit/provider/user/pw_spec.rb +48 -48
  498. data/spec/unit/provider/user/solaris_spec.rb +8 -8
  499. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  500. data/spec/unit/provider/user/windows_spec.rb +26 -26
  501. data/spec/unit/provider/user_spec.rb +72 -72
  502. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +4 -4
  503. data/spec/unit/provider_resolver_spec.rb +387 -0
  504. data/spec/unit/recipe_spec.rb +33 -12
  505. data/spec/unit/resource/apt_package_spec.rb +10 -13
  506. data/spec/unit/resource/bash_spec.rb +4 -4
  507. data/spec/unit/resource/batch_spec.rb +1 -1
  508. data/spec/unit/resource/breakpoint_spec.rb +11 -7
  509. data/spec/unit/resource/chef_gem_spec.rb +8 -15
  510. data/spec/unit/resource/conditional_action_not_nothing_spec.rb +2 -2
  511. data/spec/unit/resource/conditional_spec.rb +35 -16
  512. data/spec/unit/resource/cookbook_file_spec.rb +13 -13
  513. data/spec/unit/resource/cron_spec.rb +37 -37
  514. data/spec/unit/resource/csh_spec.rb +4 -4
  515. data/spec/unit/resource/deploy_revision_spec.rb +13 -18
  516. data/spec/unit/resource/deploy_spec.rb +60 -55
  517. data/spec/unit/resource/directory_spec.rb +18 -18
  518. data/spec/unit/resource/dpkg_package_spec.rb +8 -14
  519. data/spec/unit/resource/dsc_script_spec.rb +98 -0
  520. data/spec/unit/resource/easy_install_package_spec.rb +9 -18
  521. data/spec/unit/resource/env_spec.rb +12 -12
  522. data/spec/unit/resource/erl_call_spec.rb +11 -11
  523. data/spec/unit/resource/execute_spec.rb +5 -0
  524. data/spec/unit/resource/file_spec.rb +29 -29
  525. data/spec/unit/resource/freebsd_package_spec.rb +11 -12
  526. data/spec/unit/resource/gem_package_spec.rb +8 -15
  527. data/spec/unit/resource/git_spec.rb +12 -8
  528. data/spec/unit/resource/group_spec.rb +27 -27
  529. data/spec/unit/resource/homebrew_package_spec.rb +50 -0
  530. data/spec/unit/resource/http_request_spec.rb +6 -6
  531. data/spec/unit/resource/ifconfig_spec.rb +8 -8
  532. data/spec/unit/resource/ips_package_spec.rb +10 -13
  533. data/spec/unit/resource/link_spec.rb +25 -25
  534. data/spec/unit/resource/log_spec.rb +9 -9
  535. data/spec/unit/resource/macports_package_spec.rb +8 -13
  536. data/spec/unit/resource/mdadm_spec.rb +18 -18
  537. data/spec/unit/resource/mount_spec.rb +45 -45
  538. data/spec/unit/resource/ohai_spec.rb +7 -7
  539. data/spec/unit/resource/package_spec.rb +12 -12
  540. data/spec/unit/resource/pacman_package_spec.rb +8 -14
  541. data/spec/unit/resource/perl_spec.rb +4 -4
  542. data/spec/unit/resource/portage_package_spec.rb +3 -3
  543. data/spec/unit/resource/powershell_spec.rb +7 -7
  544. data/spec/unit/resource/python_spec.rb +4 -4
  545. data/spec/unit/resource/registry_key_spec.rb +32 -32
  546. data/spec/unit/resource/remote_directory_spec.rb +17 -17
  547. data/spec/unit/resource/remote_file_spec.rb +41 -41
  548. data/spec/unit/resource/route_spec.rb +19 -19
  549. data/spec/unit/resource/rpm_package_spec.rb +9 -13
  550. data/spec/unit/resource/ruby_block_spec.rb +8 -8
  551. data/spec/unit/resource/ruby_spec.rb +4 -4
  552. data/spec/unit/resource/scm_spec.rb +40 -40
  553. data/spec/unit/resource/script_spec.rb +2 -2
  554. data/spec/unit/resource/service_spec.rb +37 -47
  555. data/spec/unit/resource/smartos_package_spec.rb +10 -15
  556. data/spec/unit/resource/solaris_package_spec.rb +13 -28
  557. data/spec/unit/resource/subversion_spec.rb +16 -12
  558. data/spec/unit/resource/template_spec.rb +35 -35
  559. data/spec/unit/resource/timestamped_deploy_spec.rb +30 -4
  560. data/spec/unit/resource/user_spec.rb +23 -23
  561. data/spec/unit/resource/windows_package_spec.rb +17 -10
  562. data/spec/unit/resource/windows_service_spec.rb +9 -6
  563. data/spec/unit/resource/yum_package_spec.rb +16 -21
  564. data/spec/unit/resource_collection/resource_list_spec.rb +137 -0
  565. data/spec/unit/resource_collection/resource_set_spec.rb +199 -0
  566. data/spec/unit/resource_collection_spec.rb +73 -92
  567. data/spec/unit/resource_definition_spec.rb +38 -40
  568. data/spec/unit/resource_reporter_spec.rb +3 -3
  569. data/spec/unit/resource_spec.rb +68 -33
  570. data/spec/unit/rest_spec.rb +83 -76
  571. data/spec/unit/role_spec.rb +5 -0
  572. data/spec/unit/run_list_spec.rb +5 -1
  573. data/spec/unit/runner_spec.rb +245 -238
  574. data/spec/unit/shell/shell_ext_spec.rb +1 -1
  575. data/spec/unit/user_spec.rb +5 -1
  576. data/spec/unit/util/dsc/configuration_generator_spec.rb +171 -0
  577. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +169 -0
  578. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +139 -0
  579. data/spec/unit/util/path_helper_spec.rb +23 -1
  580. data/spec/unit/util/powershell/cmdlet_spec.rb +106 -0
  581. data/spec/unit/workstation_config_loader_spec.rb +1 -1
  582. metadata +303 -196
  583. checksums.yaml +0 -7
  584. data/distro/README +0 -2
  585. data/distro/arch/etc/conf.d/chef-client.conf +0 -5
  586. data/distro/arch/etc/conf.d/chef-expander.conf +0 -8
  587. data/distro/arch/etc/conf.d/chef-server-webui.conf +0 -10
  588. data/distro/arch/etc/conf.d/chef-server.conf +0 -10
  589. data/distro/arch/etc/conf.d/chef-solr.conf +0 -8
  590. data/distro/arch/etc/rc.d/chef-client +0 -90
  591. data/distro/arch/etc/rc.d/chef-expander +0 -78
  592. data/distro/arch/etc/rc.d/chef-server +0 -78
  593. data/distro/arch/etc/rc.d/chef-server-webui +0 -78
  594. data/distro/arch/etc/rc.d/chef-solr +0 -78
  595. data/distro/debian/etc/default/chef-client +0 -4
  596. data/distro/debian/etc/default/chef-expander +0 -8
  597. data/distro/debian/etc/default/chef-server +0 -9
  598. data/distro/debian/etc/default/chef-server-webui +0 -9
  599. data/distro/debian/etc/default/chef-solr +0 -8
  600. data/distro/debian/etc/init.d/chef-client +0 -212
  601. data/distro/debian/etc/init.d/chef-expander +0 -176
  602. data/distro/debian/etc/init.d/chef-server +0 -122
  603. data/distro/debian/etc/init.d/chef-server-webui +0 -123
  604. data/distro/debian/etc/init.d/chef-solr +0 -176
  605. data/distro/debian/etc/init/chef-client.conf +0 -17
  606. data/distro/debian/etc/init/chef-expander.conf +0 -17
  607. data/distro/debian/etc/init/chef-server-webui.conf +0 -17
  608. data/distro/debian/etc/init/chef-server.conf +0 -17
  609. data/distro/debian/etc/init/chef-solr.conf +0 -17
  610. data/distro/redhat/etc/init.d/chef-client +0 -121
  611. data/distro/redhat/etc/init.d/chef-expander +0 -104
  612. data/distro/redhat/etc/init.d/chef-server +0 -112
  613. data/distro/redhat/etc/init.d/chef-server-webui +0 -112
  614. data/distro/redhat/etc/init.d/chef-solr +0 -104
  615. data/distro/redhat/etc/logrotate.d/chef-client +0 -8
  616. data/distro/redhat/etc/logrotate.d/chef-expander +0 -8
  617. data/distro/redhat/etc/logrotate.d/chef-server +0 -8
  618. data/distro/redhat/etc/logrotate.d/chef-server-webui +0 -8
  619. data/distro/redhat/etc/logrotate.d/chef-solr +0 -8
  620. data/distro/redhat/etc/sysconfig/chef-client +0 -15
  621. data/distro/redhat/etc/sysconfig/chef-expander +0 -7
  622. data/distro/redhat/etc/sysconfig/chef-server +0 -14
  623. data/distro/redhat/etc/sysconfig/chef-server-webui +0 -14
  624. data/distro/redhat/etc/sysconfig/chef-solr +0 -8
  625. data/distro/windows/service_manager.rb +0 -20
  626. data/lib/chef/resource_platform_map.rb +0 -151
  627. data/spec/support/shared/matchers.rb +0 -17
  628. data/spec/unit/resource_platform_map_spec.rb +0 -164
@@ -28,12 +28,12 @@ describe Chef::Provider::CookbookFile::Content do
28
28
  end
29
29
 
30
30
  it "prefers the explicit cookbook name on the resource to the implicit one" do
31
- new_resource.stub(:cookbook).and_return('nginx')
32
- content.send(:resource_cookbook).should == 'nginx'
31
+ allow(new_resource).to receive(:cookbook).and_return('nginx')
32
+ expect(content.send(:resource_cookbook)).to eq('nginx')
33
33
  end
34
34
 
35
35
  it "falls back to the implicit cookbook name on the resource" do
36
- content.send(:resource_cookbook).should == 'apache2'
36
+ expect(content.send(:resource_cookbook)).to eq('apache2')
37
37
  end
38
38
 
39
39
  end
@@ -37,7 +37,7 @@ describe Chef::Provider::CookbookFile do
37
37
 
38
38
  let(:provider) do
39
39
  provider = described_class.new(resource, run_context)
40
- provider.stub(:content).and_return(content)
40
+ allow(provider).to receive(:content).and_return(content)
41
41
  provider
42
42
  end
43
43
 
@@ -21,26 +21,34 @@
21
21
  require 'spec_helper'
22
22
 
23
23
  describe Chef::Provider::Cron::Unix do
24
- before do
25
- @node = Chef::Node.new
26
- @events = Chef::EventDispatch::Dispatcher.new
27
- @run_context = Chef::RunContext.new(@node, {}, @events)
28
- @new_resource = Chef::Resource::Cron.new("cronhole some stuff")
29
- @new_resource.user "root"
30
- @new_resource.minute "30"
31
- @new_resource.command "/bin/true"
32
-
33
- @provider = Chef::Provider::Cron::Unix.new(@new_resource, @run_context)
24
+
25
+ subject(:provider) { Chef::Provider::Cron::Unix.new(new_resource, run_context) }
26
+
27
+ let(:username) { "root" }
28
+
29
+ let(:node) { Chef::Node.new }
30
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
31
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
32
+ let(:new_resource) do
33
+ Chef::Resource::Cron.new("cronhole some stuff").tap do |resource|
34
+ resource.user username
35
+ resource.minute "30"
36
+ resource.command "/bin/true"
37
+ end
34
38
  end
35
39
 
36
- it "should inherit from Chef::Provider:Cron" do
37
- @provider.should be_a(Chef::Provider::Cron)
40
+ let(:status) { double('Process::Status', :exitstatus => exitstatus) }
41
+ let(:exitstatus) { 0 }
42
+ let(:shell_out) { double('Mixlib::ShellOut', :status => status, :stdout => stdout, :stderr => stderr) }
43
+
44
+ it "is a Chef::Provider:Cron" do
45
+ expect(provider).to be_a(Chef::Provider::Cron)
38
46
  end
39
47
 
40
48
  describe "read_crontab" do
41
- before :each do
42
- @status = double("Status", :exitstatus => 0)
43
- @stdout = StringIO.new(<<-CRONTAB)
49
+ let(:stderr) { "" }
50
+ let(:stdout) do
51
+ String.new(<<-CRONTAB)
44
52
  0 2 * * * /some/other/command
45
53
 
46
54
  # Chef Name: something else
@@ -48,74 +56,84 @@ describe Chef::Provider::Cron::Unix do
48
56
 
49
57
  # Another comment
50
58
  CRONTAB
51
- @provider.stub(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
59
+ end
60
+
61
+ before do
62
+ allow(Chef::Log).to receive(:debug)
63
+ allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
64
+ allow(provider).to receive(:shell_out).with('/usr/bin/crontab -l', :user => username).and_return(shell_out)
52
65
  end
53
66
 
54
67
  it "should call crontab -l with the user" do
55
- @provider.should_receive(:popen4).with("crontab -l #{@new_resource.user}").and_return(@status)
56
- @provider.send(:read_crontab)
68
+ provider.send(:read_crontab)
69
+ expect(provider).to have_received(:shell_out).with('/usr/bin/crontab -l', :user => username)
57
70
  end
58
71
 
59
72
  it "should return the contents of the crontab" do
60
- crontab = @provider.send(:read_crontab)
61
- crontab.should == <<-CRONTAB
62
- 0 2 * * * /some/other/command
73
+ crontab = provider.send(:read_crontab)
74
+ expect(crontab).to eq(stdout)
75
+ end
63
76
 
64
- # Chef Name: something else
65
- * 5 * * * /bin/true
77
+ context "when the user has no crontab" do
78
+ let(:exitstatus) { 1 }
66
79
 
67
- # Another comment
68
- CRONTAB
69
- end
80
+ it "should return nil if the user has no crontab" do
81
+ expect(provider.send(:read_crontab)).to be_nil
82
+ end
70
83
 
71
- it "should return nil if the user has no crontab" do
72
- status = double("Status", :exitstatus => 1)
73
- @provider.stub(:popen4).and_return(status)
74
- @provider.send(:read_crontab).should == nil
84
+ it "logs the crontab output to debug" do
85
+ provider.send(:read_crontab)
86
+ expect(Chef::Log).to have_received(:debug).with("formatted command output")
87
+ end
75
88
  end
76
89
 
77
- it "should raise an exception if another error occurs" do
78
- status = double("Status", :exitstatus => 2)
79
- @provider.stub(:popen4).and_return(status)
80
- lambda do
81
- @provider.send(:read_crontab)
82
- end.should raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
90
+ context "when any other error occurs" do
91
+ let (:exitstatus) { 2 }
92
+
93
+ it "should raise an exception if another error occurs" do
94
+ expect {
95
+ provider.send(:read_crontab)
96
+ }.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
97
+ end
98
+
99
+ it "logs the crontab output to debug" do
100
+ provider.send(:read_crontab) rescue nil
101
+ expect(Chef::Log).to have_received(:debug).with("formatted command output")
102
+ end
83
103
  end
84
104
  end
85
105
 
86
106
  describe "write_crontab" do
87
- before :each do
88
- @status = double("Status", :exitstatus => 0)
89
- @provider.stub(:run_command_and_return_stdout_stderr).and_return(@status, String.new, String.new)
90
- @tempfile = double("foo", :path => "/tmp/foo", :close => true)
91
- Tempfile.stub(:new).and_return(@tempfile)
92
- @tempfile.should_receive(:flush)
93
- @tempfile.should_receive(:chmod).with(420)
94
- @tempfile.should_receive(:close!)
107
+ let(:stdout) { "" }
108
+ let(:stderr) { "" }
109
+ let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) }
110
+
111
+ before do
112
+ expect(Tempfile).to receive(:new).and_return(tempfile)
113
+ expect(tempfile).to receive(:flush)
114
+ expect(tempfile).to receive(:chmod).with(420)
115
+ expect(tempfile).to receive(:close!)
116
+ allow(tempfile).to receive(:<<)
117
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out)
95
118
  end
96
119
 
97
120
  it "should call crontab for the user" do
98
- @provider.should_receive(:run_command_and_return_stdout_stderr).with(hash_including(:user => @new_resource.user))
99
- @tempfile.should_receive(:<<).with("Foo")
100
- @provider.send(:write_crontab, "Foo")
121
+ provider.send(:write_crontab, "Foo")
122
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username)
101
123
  end
102
124
 
103
125
  it "should call crontab with a file containing the crontab" do
104
- @provider.should_receive(:run_command_and_return_stdout_stderr) do |args|
105
- (args[:command] =~ %r{\A/usr/bin/crontab (/\S+)\z}).should be_true
106
- $1.should == "/tmp/foo"
107
- @status
108
- end
109
- @tempfile.should_receive(:<<).with("Foo\n# wibble\n wah!!")
110
- @provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
126
+ provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
127
+ expect(tempfile).to have_received(:<<).with("Foo\n# wibble\n wah!!")
111
128
  end
112
129
 
113
- it "should raise an exception if the command returns non-zero" do
114
- @tempfile.should_receive(:<<).with("Foo")
115
- @status.stub(:exitstatus).and_return(1)
116
- lambda do
117
- @provider.send(:write_crontab, "Foo")
118
- end.should raise_error(Chef::Exceptions::Cron, /Error updating state of #{@new_resource.name}, exit: 1/)
130
+ context "when writing the crontab fails" do
131
+ let(:exitstatus) { 1 }
132
+ it "should raise an exception if the command returns non-zero" do
133
+ expect {
134
+ provider.send(:write_crontab, "Foo")
135
+ }.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
136
+ end
119
137
  end
120
138
  end
121
139
  end
@@ -35,7 +35,7 @@ describe Chef::Provider::Cron do
35
35
 
36
36
  context "with a matching entry in the user's crontab" do
37
37
  before :each do
38
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
38
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
39
39
  0 2 * * * /some/other/command
40
40
 
41
41
  # Chef Name: cronhole some stuff
@@ -49,18 +49,18 @@ CRONTAB
49
49
 
50
50
  it "should set cron_exists" do
51
51
  @provider.load_current_resource
52
- @provider.cron_exists.should == true
53
- @provider.cron_empty.should == false
52
+ expect(@provider.cron_exists).to eq(true)
53
+ expect(@provider.cron_empty).to eq(false)
54
54
  end
55
55
 
56
56
  it "should pull the details out of the cron line" do
57
57
  cron = @provider.load_current_resource
58
- cron.time.should == :reboot
59
- cron.command.should == '/bin/true param1 param2'
58
+ expect(cron.time).to eq(:reboot)
59
+ expect(cron.command).to eq('/bin/true param1 param2')
60
60
  end
61
61
 
62
62
  it "should pull env vars out" do
63
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
63
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
64
64
  0 2 * * * /some/other/command
65
65
 
66
66
  # Chef Name: cronhole some stuff
@@ -75,16 +75,16 @@ HOME=/home/foo
75
75
  # Another comment
76
76
  CRONTAB
77
77
  cron = @provider.load_current_resource
78
- cron.mailto.should == 'foo@example.com'
79
- cron.shell.should == '/bin/foosh'
80
- cron.path.should == '/bin:/foo'
81
- cron.home.should == '/home/foo'
82
- cron.time.should == :reboot
83
- cron.command.should == '/bin/true param1 param2'
78
+ expect(cron.mailto).to eq('foo@example.com')
79
+ expect(cron.shell).to eq('/bin/foosh')
80
+ expect(cron.path).to eq('/bin:/foo')
81
+ expect(cron.home).to eq('/home/foo')
82
+ expect(cron.time).to eq(:reboot)
83
+ expect(cron.command).to eq('/bin/true param1 param2')
84
84
  end
85
85
 
86
86
  it "should parse and load generic and standard environment variables from cron entry" do
87
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
87
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
88
88
  # Chef Name: cronhole some stuff
89
89
  MAILTO=warn@example.com
90
90
  TEST=lol
@@ -93,12 +93,12 @@ FLAG=1
93
93
  CRONTAB
94
94
  cron = @provider.load_current_resource
95
95
 
96
- cron.mailto.should == "warn@example.com"
97
- cron.environment.should == {"TEST" => "lol", "FLAG" => "1"}
96
+ expect(cron.mailto).to eq("warn@example.com")
97
+ expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
98
98
  end
99
99
 
100
100
  it "should not break with variables that match the cron resource internals" do
101
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
101
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
102
102
  # Chef Name: cronhole some stuff
103
103
  MINUTE=40
104
104
  REBOOT=midnight
@@ -108,19 +108,19 @@ ENVIRONMENT=production
108
108
  CRONTAB
109
109
  cron = @provider.load_current_resource
110
110
 
111
- cron.time.should == :reboot
112
- cron.environment.should == {"MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"}
111
+ expect(cron.time).to eq(:reboot)
112
+ expect(cron.environment).to eq({"MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
113
113
  end
114
114
 
115
115
  it "should report the match" do
116
- Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'")
116
+ expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
117
117
  @provider.load_current_resource
118
118
  end
119
119
 
120
120
  describe "action_create" do
121
121
  before :each do
122
- @provider.stub(:write_crontab)
123
- @provider.stub(:read_crontab).and_return(nil)
122
+ allow(@provider).to receive(:write_crontab)
123
+ allow(@provider).to receive(:read_crontab).and_return(nil)
124
124
  end
125
125
 
126
126
  context "when there is no existing crontab" do
@@ -130,7 +130,7 @@ CRONTAB
130
130
  end
131
131
 
132
132
  it "should create a crontab with the entry" do
133
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
133
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
134
134
  # Chef Name: cronhole some stuff
135
135
  @reboot /bin/true
136
136
  ENDCRON
@@ -156,24 +156,24 @@ CRONTAB
156
156
  describe "when examining the current system state" do
157
157
  context "with no crontab for the user" do
158
158
  before :each do
159
- @provider.stub(:read_crontab).and_return(nil)
159
+ allow(@provider).to receive(:read_crontab).and_return(nil)
160
160
  end
161
161
 
162
162
  it "should set cron_empty" do
163
163
  @provider.load_current_resource
164
- @provider.cron_empty.should == true
165
- @provider.cron_exists.should == false
164
+ expect(@provider.cron_empty).to eq(true)
165
+ expect(@provider.cron_exists).to eq(false)
166
166
  end
167
167
 
168
168
  it "should report an empty crontab" do
169
- Chef::Log.should_receive(:debug).with("Cron empty for '#{@new_resource.user}'")
169
+ expect(Chef::Log).to receive(:debug).with("Cron empty for '#{@new_resource.user}'")
170
170
  @provider.load_current_resource
171
171
  end
172
172
  end
173
173
 
174
174
  context "with no matching entry in the user's crontab" do
175
175
  before :each do
176
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
176
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
177
177
  0 2 * * * /some/other/command
178
178
 
179
179
  # Chef Name: something else
@@ -185,29 +185,29 @@ CRONTAB
185
185
 
186
186
  it "should not set cron_exists or cron_empty" do
187
187
  @provider.load_current_resource
188
- @provider.cron_exists.should == false
189
- @provider.cron_empty.should == false
188
+ expect(@provider.cron_exists).to eq(false)
189
+ expect(@provider.cron_empty).to eq(false)
190
190
  end
191
191
 
192
192
  it "should report no entry found" do
193
- Chef::Log.should_receive(:debug).with("Cron '#{@new_resource.name}' not found")
193
+ expect(Chef::Log).to receive(:debug).with("Cron '#{@new_resource.name}' not found")
194
194
  @provider.load_current_resource
195
195
  end
196
196
 
197
197
  it "should not fail if there's an existing cron with a numerical argument" do
198
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
198
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
199
199
  # Chef Name: foo[bar] (baz)
200
200
  21 */4 * * * some_prog 1234567
201
201
  CRONTAB
202
- lambda {
202
+ expect {
203
203
  @provider.load_current_resource
204
- }.should_not raise_error
204
+ }.not_to raise_error
205
205
  end
206
206
  end
207
207
 
208
208
  context "with a matching entry in the user's crontab" do
209
209
  before :each do
210
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
210
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
211
211
  0 2 * * * /some/other/command
212
212
 
213
213
  # Chef Name: cronhole some stuff
@@ -221,23 +221,23 @@ CRONTAB
221
221
 
222
222
  it "should set cron_exists" do
223
223
  @provider.load_current_resource
224
- @provider.cron_exists.should == true
225
- @provider.cron_empty.should == false
224
+ expect(@provider.cron_exists).to eq(true)
225
+ expect(@provider.cron_empty).to eq(false)
226
226
  end
227
227
 
228
228
  it "should pull the details out of the cron line" do
229
229
  cron = @provider.load_current_resource
230
- cron.minute.should == '*'
231
- cron.hour.should == '5'
232
- cron.day.should == '*'
233
- cron.month.should == '1'
234
- cron.weekday.should == '*'
235
- cron.time.should == nil
236
- cron.command.should == '/bin/true param1 param2'
230
+ expect(cron.minute).to eq('*')
231
+ expect(cron.hour).to eq('5')
232
+ expect(cron.day).to eq('*')
233
+ expect(cron.month).to eq('1')
234
+ expect(cron.weekday).to eq('*')
235
+ expect(cron.time).to eq(nil)
236
+ expect(cron.command).to eq('/bin/true param1 param2')
237
237
  end
238
238
 
239
239
  it "should pull env vars out" do
240
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
240
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
241
241
  0 2 * * * /some/other/command
242
242
 
243
243
  # Chef Name: cronhole some stuff
@@ -252,21 +252,21 @@ HOME=/home/foo
252
252
  # Another comment
253
253
  CRONTAB
254
254
  cron = @provider.load_current_resource
255
- cron.mailto.should == 'foo@example.com'
256
- cron.shell.should == '/bin/foosh'
257
- cron.path.should == '/bin:/foo'
258
- cron.home.should == '/home/foo'
259
- cron.minute.should == '*'
260
- cron.hour.should == '5'
261
- cron.day.should == '*'
262
- cron.month.should == '1'
263
- cron.weekday.should == '*'
264
- cron.time.should == nil
265
- cron.command.should == '/bin/true param1 param2'
255
+ expect(cron.mailto).to eq('foo@example.com')
256
+ expect(cron.shell).to eq('/bin/foosh')
257
+ expect(cron.path).to eq('/bin:/foo')
258
+ expect(cron.home).to eq('/home/foo')
259
+ expect(cron.minute).to eq('*')
260
+ expect(cron.hour).to eq('5')
261
+ expect(cron.day).to eq('*')
262
+ expect(cron.month).to eq('1')
263
+ expect(cron.weekday).to eq('*')
264
+ expect(cron.time).to eq(nil)
265
+ expect(cron.command).to eq('/bin/true param1 param2')
266
266
  end
267
267
 
268
268
  it "should parse and load generic and standard environment variables from cron entry" do
269
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
269
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
270
270
  # Chef Name: cronhole some stuff
271
271
  MAILTO=warn@example.com
272
272
  TEST=lol
@@ -275,12 +275,12 @@ FLAG=1
275
275
  CRONTAB
276
276
  cron = @provider.load_current_resource
277
277
 
278
- cron.mailto.should == "warn@example.com"
279
- cron.environment.should == {"TEST" => "lol", "FLAG" => "1"}
278
+ expect(cron.mailto).to eq("warn@example.com")
279
+ expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
280
280
  end
281
281
 
282
282
  it "should not break with variabels that match the cron resource internals" do
283
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
283
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
284
284
  # Chef Name: cronhole some stuff
285
285
  MINUTE=40
286
286
  HOUR=midnight
@@ -290,20 +290,20 @@ ENVIRONMENT=production
290
290
  CRONTAB
291
291
  cron = @provider.load_current_resource
292
292
 
293
- cron.minute.should == '*'
294
- cron.hour.should == '5'
295
- cron.environment.should == {"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"}
293
+ expect(cron.minute).to eq('*')
294
+ expect(cron.hour).to eq('5')
295
+ expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
296
296
  end
297
297
 
298
298
  it "should report the match" do
299
- Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'")
299
+ expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
300
300
  @provider.load_current_resource
301
301
  end
302
302
  end
303
303
 
304
304
  context "with a matching entry in the user's crontab using month names and weekday names (#CHEF-3178)" do
305
305
  before :each do
306
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
306
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
307
307
  0 2 * * * /some/other/command
308
308
 
309
309
  # Chef Name: cronhole some stuff
@@ -317,64 +317,64 @@ CRONTAB
317
317
 
318
318
  it "should set cron_exists" do
319
319
  @provider.load_current_resource
320
- @provider.cron_exists.should == true
321
- @provider.cron_empty.should == false
320
+ expect(@provider.cron_exists).to eq(true)
321
+ expect(@provider.cron_empty).to eq(false)
322
322
  end
323
323
 
324
324
  it "should pull the details out of the cron line" do
325
325
  cron = @provider.load_current_resource
326
- cron.minute.should == '*'
327
- cron.hour.should == '5'
328
- cron.day.should == '*'
329
- cron.month.should == 'Jan'
330
- cron.weekday.should == 'Mon'
331
- cron.command.should == '/bin/true param1 param2'
326
+ expect(cron.minute).to eq('*')
327
+ expect(cron.hour).to eq('5')
328
+ expect(cron.day).to eq('*')
329
+ expect(cron.month).to eq('Jan')
330
+ expect(cron.weekday).to eq('Mon')
331
+ expect(cron.command).to eq('/bin/true param1 param2')
332
332
  end
333
333
 
334
334
  it "should report the match" do
335
- Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'")
335
+ expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
336
336
  @provider.load_current_resource
337
337
  end
338
338
  end
339
339
 
340
340
  context "with a matching entry without a crontab line" do
341
341
  it "should set cron_exists and leave current_resource values at defaults" do
342
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
342
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
343
343
  0 2 * * * /some/other/command
344
344
 
345
345
  # Chef Name: cronhole some stuff
346
346
  CRONTAB
347
347
  cron = @provider.load_current_resource
348
- @provider.cron_exists.should == true
349
- cron.minute.should == '*'
350
- cron.hour.should == '*'
351
- cron.day.should == '*'
352
- cron.month.should == '*'
353
- cron.weekday.should == '*'
354
- cron.time.should == nil
355
- cron.command.should == nil
348
+ expect(@provider.cron_exists).to eq(true)
349
+ expect(cron.minute).to eq('*')
350
+ expect(cron.hour).to eq('*')
351
+ expect(cron.day).to eq('*')
352
+ expect(cron.month).to eq('*')
353
+ expect(cron.weekday).to eq('*')
354
+ expect(cron.time).to eq(nil)
355
+ expect(cron.command).to eq(nil)
356
356
  end
357
357
 
358
358
  it "should not pick up a commented out crontab line" do
359
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
359
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
360
360
  0 2 * * * /some/other/command
361
361
 
362
362
  # Chef Name: cronhole some stuff
363
363
  #* 5 * 1 * /bin/true param1 param2
364
364
  CRONTAB
365
365
  cron = @provider.load_current_resource
366
- @provider.cron_exists.should == true
367
- cron.minute.should == '*'
368
- cron.hour.should == '*'
369
- cron.day.should == '*'
370
- cron.month.should == '*'
371
- cron.weekday.should == '*'
372
- cron.time.should == nil
373
- cron.command.should == nil
366
+ expect(@provider.cron_exists).to eq(true)
367
+ expect(cron.minute).to eq('*')
368
+ expect(cron.hour).to eq('*')
369
+ expect(cron.day).to eq('*')
370
+ expect(cron.month).to eq('*')
371
+ expect(cron.weekday).to eq('*')
372
+ expect(cron.time).to eq(nil)
373
+ expect(cron.command).to eq(nil)
374
374
  end
375
375
 
376
376
  it "should not pick up a later crontab entry" do
377
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
377
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
378
378
  0 2 * * * /some/other/command
379
379
 
380
380
  # Chef Name: cronhole some stuff
@@ -385,14 +385,14 @@ CRONTAB
385
385
  # Another comment
386
386
  CRONTAB
387
387
  cron = @provider.load_current_resource
388
- @provider.cron_exists.should == true
389
- cron.minute.should == '*'
390
- cron.hour.should == '*'
391
- cron.day.should == '*'
392
- cron.month.should == '*'
393
- cron.weekday.should == '*'
394
- cron.time.should == nil
395
- cron.command.should == nil
388
+ expect(@provider.cron_exists).to eq(true)
389
+ expect(cron.minute).to eq('*')
390
+ expect(cron.hour).to eq('*')
391
+ expect(cron.day).to eq('*')
392
+ expect(cron.month).to eq('*')
393
+ expect(cron.weekday).to eq('*')
394
+ expect(cron.time).to eq(nil)
395
+ expect(cron.command).to eq(nil)
396
396
  end
397
397
  end
398
398
  end
@@ -409,35 +409,35 @@ CRONTAB
409
409
  [:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home].each do |attribute|
410
410
  it "should return true if #{attribute} doesn't match" do
411
411
  @new_resource.send(attribute, "something_else")
412
- @provider.cron_different?.should eql(true)
412
+ expect(@provider.cron_different?).to eql(true)
413
413
  end
414
414
  end
415
415
 
416
416
  it "should return true if special time string doesn't match" do
417
417
  @new_resource.send(:time, :reboot)
418
- @provider.cron_different?.should eql(true)
418
+ expect(@provider.cron_different?).to eql(true)
419
419
  end
420
420
 
421
421
  it "should return true if environment doesn't match" do
422
422
  @new_resource.environment "FOO" => "something_else"
423
- @provider.cron_different?.should eql(true)
423
+ expect(@provider.cron_different?).to eql(true)
424
424
  end
425
425
 
426
426
  it "should return true if mailto doesn't match" do
427
427
  @current_resource.mailto "foo@bar.com"
428
428
  @new_resource.mailto(nil)
429
- @provider.cron_different?.should eql(true)
429
+ expect(@provider.cron_different?).to eql(true)
430
430
  end
431
431
 
432
432
  it "should return false if the objects are identical" do
433
- @provider.cron_different?.should == false
433
+ expect(@provider.cron_different?).to eq(false)
434
434
  end
435
435
  end
436
436
 
437
437
  describe "action_create" do
438
438
  before :each do
439
- @provider.stub(:write_crontab)
440
- @provider.stub(:read_crontab).and_return(nil)
439
+ allow(@provider).to receive(:write_crontab)
440
+ allow(@provider).to receive(:read_crontab).and_return(nil)
441
441
  end
442
442
 
443
443
  context "when there is no existing crontab" do
@@ -447,7 +447,7 @@ CRONTAB
447
447
  end
448
448
 
449
449
  it "should create a crontab with the entry" do
450
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
450
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
451
451
  # Chef Name: cronhole some stuff
452
452
  30 * * * * /bin/true
453
453
  ENDCRON
@@ -460,7 +460,7 @@ CRONTAB
460
460
  @new_resource.shell '/bin/foosh'
461
461
  @new_resource.home '/home/foo'
462
462
  @new_resource.environment "TEST" => "LOL"
463
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
463
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
464
464
  # Chef Name: cronhole some stuff
465
465
  MAILTO=foo@example.com
466
466
  PATH=/usr/bin:/my/custom/path
@@ -474,11 +474,11 @@ TEST=LOL
474
474
 
475
475
  it "should mark the resource as updated" do
476
476
  @provider.run_action(:create)
477
- @new_resource.should be_updated_by_last_action
477
+ expect(@new_resource).to be_updated_by_last_action
478
478
  end
479
479
 
480
480
  it "should log the action" do
481
- Chef::Log.should_receive(:info).with("cron[cronhole some stuff] added crontab entry")
481
+ expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] added crontab entry")
482
482
  @provider.run_action(:create)
483
483
  end
484
484
  end
@@ -486,7 +486,7 @@ TEST=LOL
486
486
  context "when there is a crontab with no matching section" do
487
487
  before :each do
488
488
  @provider.cron_exists = false
489
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
489
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
490
490
  0 2 * * * /some/other/command
491
491
 
492
492
  # Chef Name: something else
@@ -497,7 +497,7 @@ TEST=LOL
497
497
  end
498
498
 
499
499
  it "should add the entry to the crontab" do
500
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
500
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
501
501
  0 2 * * * /some/other/command
502
502
 
503
503
  # Chef Name: something else
@@ -516,7 +516,7 @@ TEST=LOL
516
516
  @new_resource.shell '/bin/foosh'
517
517
  @new_resource.home '/home/foo'
518
518
  @new_resource.environment "TEST" => "LOL"
519
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
519
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
520
520
  0 2 * * * /some/other/command
521
521
 
522
522
  # Chef Name: something else
@@ -536,11 +536,11 @@ TEST=LOL
536
536
 
537
537
  it "should mark the resource as updated" do
538
538
  @provider.run_action(:create)
539
- @new_resource.should be_updated_by_last_action
539
+ expect(@new_resource).to be_updated_by_last_action
540
540
  end
541
541
 
542
542
  it "should log the action" do
543
- Chef::Log.should_receive(:info).with("cron[cronhole some stuff] added crontab entry")
543
+ expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] added crontab entry")
544
544
  @provider.run_action(:create)
545
545
  end
546
546
  end
@@ -548,8 +548,8 @@ TEST=LOL
548
548
  context "when there is a crontab with a matching but different section" do
549
549
  before :each do
550
550
  @provider.cron_exists = true
551
- @provider.stub(:cron_different?).and_return(true)
552
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
551
+ allow(@provider).to receive(:cron_different?).and_return(true)
552
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
553
553
  0 2 * * * /some/other/command
554
554
 
555
555
  # Chef Name: cronhole some stuff
@@ -562,7 +562,7 @@ TEST=LOL
562
562
  end
563
563
 
564
564
  it "should update the crontab entry" do
565
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
565
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
566
566
  0 2 * * * /some/other/command
567
567
 
568
568
  # Chef Name: cronhole some stuff
@@ -581,7 +581,7 @@ TEST=LOL
581
581
  @new_resource.shell '/bin/foosh'
582
582
  @new_resource.home '/home/foo'
583
583
  @new_resource.environment "TEST" => "LOL"
584
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
584
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
585
585
  0 2 * * * /some/other/command
586
586
 
587
587
  # Chef Name: cronhole some stuff
@@ -601,11 +601,11 @@ TEST=LOL
601
601
 
602
602
  it "should mark the resource as updated" do
603
603
  @provider.run_action(:create)
604
- @new_resource.should be_updated_by_last_action
604
+ expect(@new_resource).to be_updated_by_last_action
605
605
  end
606
606
 
607
607
  it "should log the action" do
608
- Chef::Log.should_receive(:info).with("cron[cronhole some stuff] updated crontab entry")
608
+ expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] updated crontab entry")
609
609
  @provider.run_action(:create)
610
610
  end
611
611
  end
@@ -613,16 +613,16 @@ TEST=LOL
613
613
  context "when there is a crontab with a matching section with no crontab line in it" do
614
614
  before :each do
615
615
  @provider.cron_exists = true
616
- @provider.stub(:cron_different?).and_return(true)
616
+ allow(@provider).to receive(:cron_different?).and_return(true)
617
617
  end
618
618
 
619
619
  it "should add the crontab to the entry" do
620
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
620
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
621
621
  0 2 * * * /some/other/command
622
622
 
623
623
  # Chef Name: cronhole some stuff
624
624
  CRONTAB
625
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
625
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
626
626
  0 2 * * * /some/other/command
627
627
 
628
628
  # Chef Name: cronhole some stuff
@@ -632,7 +632,7 @@ TEST=LOL
632
632
  end
633
633
 
634
634
  it "should not blat any following entries" do
635
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
635
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
636
636
  0 2 * * * /some/other/command
637
637
 
638
638
  # Chef Name: cronhole some stuff
@@ -642,7 +642,7 @@ TEST=LOL
642
642
 
643
643
  # Another comment
644
644
  CRONTAB
645
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
645
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
646
646
  0 2 * * * /some/other/command
647
647
 
648
648
  # Chef Name: cronhole some stuff
@@ -657,7 +657,7 @@ TEST=LOL
657
657
  end
658
658
 
659
659
  it "should handle env vars with no crontab" do
660
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
660
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
661
661
  0 2 * * * /some/other/command
662
662
 
663
663
  # Chef Name: cronhole some stuff
@@ -675,7 +675,7 @@ HOME=/home/foo
675
675
  @new_resource.path '/usr/bin:/my/custom/path'
676
676
  @new_resource.shell '/bin/foosh'
677
677
  @new_resource.home '/home/foo'
678
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
678
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
679
679
  0 2 * * * /some/other/command
680
680
 
681
681
  # Chef Name: cronhole some stuff
@@ -697,8 +697,8 @@ HOME=/home/foo
697
697
  context "when there is a crontab with a matching and identical section" do
698
698
  before :each do
699
699
  @provider.cron_exists = true
700
- @provider.stub(:cron_different?).and_return(false)
701
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
700
+ allow(@provider).to receive(:cron_different?).and_return(false)
701
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
702
702
  0 2 * * * /some/other/command
703
703
 
704
704
  # Chef Name: cronhole some stuff
@@ -709,18 +709,18 @@ CRONTAB
709
709
  end
710
710
 
711
711
  it "should not update the crontab" do
712
- @provider.should_not_receive(:write_crontab)
712
+ expect(@provider).not_to receive(:write_crontab)
713
713
  @provider.run_action(:create)
714
714
  end
715
715
 
716
716
  it "should not mark the resource as updated" do
717
717
  @provider.run_action(:create)
718
- @new_resource.should_not be_updated_by_last_action
718
+ expect(@new_resource).not_to be_updated_by_last_action
719
719
  end
720
720
 
721
721
  it "should log nothing changed" do
722
- Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'")
723
- Chef::Log.should_receive(:debug).with("Skipping existing cron entry '#{@new_resource.name}'")
722
+ expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
723
+ expect(Chef::Log).to receive(:debug).with("Skipping existing cron entry '#{@new_resource.name}'")
724
724
  @provider.run_action(:create)
725
725
  end
726
726
  end
@@ -728,8 +728,8 @@ CRONTAB
728
728
 
729
729
  describe "action_delete" do
730
730
  before :each do
731
- @provider.stub(:write_crontab)
732
- @provider.stub(:read_crontab).and_return(nil)
731
+ allow(@provider).to receive(:write_crontab)
732
+ allow(@provider).to receive(:read_crontab).and_return(nil)
733
733
  end
734
734
 
735
735
  context "when the user's crontab has no matching section" do
@@ -738,21 +738,21 @@ CRONTAB
738
738
  end
739
739
 
740
740
  it "should do nothing" do
741
- @provider.should_not_receive(:write_crontab)
742
- Chef::Log.should_not_receive(:info)
741
+ expect(@provider).not_to receive(:write_crontab)
742
+ expect(Chef::Log).not_to receive(:info)
743
743
  @provider.run_action(:delete)
744
744
  end
745
745
 
746
746
  it "should not mark the resource as updated" do
747
747
  @provider.run_action(:delete)
748
- @new_resource.should_not be_updated_by_last_action
748
+ expect(@new_resource).not_to be_updated_by_last_action
749
749
  end
750
750
  end
751
751
 
752
752
  context "when the user has a crontab with a matching section" do
753
753
  before :each do
754
754
  @provider.cron_exists = true
755
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
755
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
756
756
  0 2 * * * /some/other/command
757
757
 
758
758
  # Chef Name: cronhole some stuff
@@ -765,7 +765,7 @@ CRONTAB
765
765
  end
766
766
 
767
767
  it "should remove the entry" do
768
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
768
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
769
769
  0 2 * * * /some/other/command
770
770
 
771
771
  # Chef Name: something else
@@ -777,7 +777,7 @@ CRONTAB
777
777
  end
778
778
 
779
779
  it "should remove any env vars with the entry" do
780
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
780
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
781
781
  0 2 * * * /some/other/command
782
782
 
783
783
  # Chef Name: cronhole some stuff
@@ -789,7 +789,7 @@ FOO=test
789
789
 
790
790
  # Another comment
791
791
  CRONTAB
792
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
792
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
793
793
  0 2 * * * /some/other/command
794
794
 
795
795
  # Chef Name: something else
@@ -802,11 +802,11 @@ FOO=test
802
802
 
803
803
  it "should mark the resource as updated" do
804
804
  @provider.run_action(:delete)
805
- @new_resource.should be_updated_by_last_action
805
+ expect(@new_resource).to be_updated_by_last_action
806
806
  end
807
807
 
808
808
  it "should log the action" do
809
- Chef::Log.should_receive(:info).with("#{@new_resource} deleted crontab entry")
809
+ expect(Chef::Log).to receive(:info).with("#{@new_resource} deleted crontab entry")
810
810
  @provider.run_action(:delete)
811
811
  end
812
812
  end
@@ -817,12 +817,12 @@ FOO=test
817
817
  end
818
818
 
819
819
  it "should remove the section" do
820
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
820
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
821
821
  0 2 * * * /some/other/command
822
822
 
823
823
  # Chef Name: cronhole some stuff
824
824
  CRONTAB
825
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
825
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
826
826
  0 2 * * * /some/other/command
827
827
 
828
828
  ENDCRON
@@ -830,7 +830,7 @@ FOO=test
830
830
  end
831
831
 
832
832
  it "should not blat following sections" do
833
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
833
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
834
834
  0 2 * * * /some/other/command
835
835
 
836
836
  # Chef Name: cronhole some stuff
@@ -840,7 +840,7 @@ FOO=test
840
840
 
841
841
  # Another comment
842
842
  CRONTAB
843
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
843
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
844
844
  0 2 * * * /some/other/command
845
845
 
846
846
  #30 * * 3 * /bin/true
@@ -853,7 +853,7 @@ FOO=test
853
853
  end
854
854
 
855
855
  it "should remove any envvars with the section" do
856
- @provider.stub(:read_crontab).and_return(<<-CRONTAB)
856
+ allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
857
857
  0 2 * * * /some/other/command
858
858
 
859
859
  # Chef Name: cronhole some stuff
@@ -864,7 +864,7 @@ MAILTO=foo@example.com
864
864
 
865
865
  # Another comment
866
866
  CRONTAB
867
- @provider.should_receive(:write_crontab).with(<<-ENDCRON)
867
+ expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
868
868
  0 2 * * * /some/other/command
869
869
 
870
870
  #30 * * 3 * /bin/true
@@ -889,17 +889,17 @@ MAILTO=foo@example.com
889
889
 
890
890
  # Another comment
891
891
  CRONTAB
892
- @provider.stub(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
892
+ allow(@provider).to receive(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
893
893
  end
894
894
 
895
895
  it "should call crontab -l with the user" do
896
- @provider.should_receive(:popen4).with("crontab -l -u #{@new_resource.user}").and_return(@status)
896
+ expect(@provider).to receive(:popen4).with("crontab -l -u #{@new_resource.user}").and_return(@status)
897
897
  @provider.send(:read_crontab)
898
898
  end
899
899
 
900
900
  it "should return the contents of the crontab" do
901
901
  crontab = @provider.send(:read_crontab)
902
- crontab.should == <<-CRONTAB
902
+ expect(crontab).to eq <<-CRONTAB
903
903
  0 2 * * * /some/other/command
904
904
 
905
905
  # Chef Name: something else
@@ -911,16 +911,16 @@ MAILTO=foo@example.com
911
911
 
912
912
  it "should return nil if the user has no crontab" do
913
913
  status = double("Status", :exitstatus => 1)
914
- @provider.stub(:popen4).and_return(status)
915
- @provider.send(:read_crontab).should == nil
914
+ allow(@provider).to receive(:popen4).and_return(status)
915
+ expect(@provider.send(:read_crontab)).to eq(nil)
916
916
  end
917
917
 
918
918
  it "should raise an exception if another error occurs" do
919
919
  status = double("Status", :exitstatus => 2)
920
- @provider.stub(:popen4).and_return(status)
921
- lambda do
920
+ allow(@provider).to receive(:popen4).and_return(status)
921
+ expect do
922
922
  @provider.send(:read_crontab)
923
- end.should raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
923
+ end.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
924
924
  end
925
925
  end
926
926
 
@@ -928,24 +928,24 @@ MAILTO=foo@example.com
928
928
  before :each do
929
929
  @status = double("Status", :exitstatus => 0)
930
930
  @stdin = StringIO.new
931
- @provider.stub(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status)
931
+ allow(@provider).to receive(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status)
932
932
  end
933
933
 
934
934
  it "should call crontab for the user" do
935
- @provider.should_receive(:popen4).with("crontab -u #{@new_resource.user} -", :waitlast => true).and_return(@status)
935
+ expect(@provider).to receive(:popen4).with("crontab -u #{@new_resource.user} -", :waitlast => true).and_return(@status)
936
936
  @provider.send(:write_crontab, "Foo")
937
937
  end
938
938
 
939
939
  it "should write the given string to the crontab command" do
940
940
  @provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
941
- @stdin.string.should == "Foo\n# wibble\n wah!!"
941
+ expect(@stdin.string).to eq("Foo\n# wibble\n wah!!")
942
942
  end
943
943
 
944
944
  it "should raise an exception if the command returns non-zero" do
945
- @status.stub(:exitstatus).and_return(1)
946
- lambda do
945
+ allow(@status).to receive(:exitstatus).and_return(1)
946
+ expect do
947
947
  @provider.send(:write_crontab, "Foo")
948
- end.should raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
948
+ end.to raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
949
949
  end
950
950
 
951
951
  it "should raise an exception if the command die's and parent tries to write" do
@@ -954,14 +954,14 @@ MAILTO=foo@example.com
954
954
  raise Errno::EPIPE, "Test"
955
955
  end
956
956
  end
957
- @status.stub(:exitstatus).and_return(1)
958
- @provider.stub(:popen4).and_yield(1234, WriteErrPipe.new, StringIO.new, StringIO.new).and_return(@status)
957
+ allow(@status).to receive(:exitstatus).and_return(1)
958
+ allow(@provider).to receive(:popen4).and_yield(1234, WriteErrPipe.new, StringIO.new, StringIO.new).and_return(@status)
959
959
 
960
- Chef::Log.should_receive(:debug).with("Broken pipe - Test")
960
+ expect(Chef::Log).to receive(:debug).with("Broken pipe - Test")
961
961
 
962
- lambda do
962
+ expect do
963
963
  @provider.send(:write_crontab, "Foo")
964
- end.should raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
964
+ end.to raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
965
965
  end
966
966
 
967
967
  end
@@ -970,7 +970,7 @@ MAILTO=foo@example.com
970
970
  context "when weekday is symbol" do
971
971
  it "should return weekday in crontab format" do
972
972
  @new_resource.weekday :wednesday
973
- @provider.send(:weekday_in_crontab).should eq("3")
973
+ expect(@provider.send(:weekday_in_crontab)).to eq("3")
974
974
  end
975
975
 
976
976
  it "should raise an error with an unknown weekday" do
@@ -981,7 +981,7 @@ MAILTO=foo@example.com
981
981
  context "when weekday is a number in a string" do
982
982
  it "should return the string" do
983
983
  @new_resource.weekday "3"
984
- @provider.send(:weekday_in_crontab).should eq("3")
984
+ expect(@provider.send(:weekday_in_crontab)).to eq("3")
985
985
  end
986
986
 
987
987
  it "should raise an error with an out of range number" do
@@ -992,14 +992,14 @@ MAILTO=foo@example.com
992
992
  context "when weekday is string with the name of the week" do
993
993
  it "should return the string" do
994
994
  @new_resource.weekday "mon"
995
- @provider.send(:weekday_in_crontab).should eq("mon")
995
+ expect(@provider.send(:weekday_in_crontab)).to eq("mon")
996
996
  end
997
997
  end
998
998
 
999
999
  context "when weekday is an integer" do
1000
1000
  it "should return the integer" do
1001
1001
  @new_resource.weekday 1
1002
- @provider.send(:weekday_in_crontab).should eq("1")
1002
+ expect(@provider.send(:weekday_in_crontab)).to eq("1")
1003
1003
  end
1004
1004
 
1005
1005
  it "should raise an error with an out of range integer" do