chefspec 7.0.0 → 9.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (830) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +28 -10
  3. data/Rakefile +74 -18
  4. data/chefspec.gemspec +26 -28
  5. data/lib/chefspec/api/core.rb +217 -0
  6. data/lib/chefspec/api/described.rb +53 -0
  7. data/lib/chefspec/api/do_nothing.rb +23 -21
  8. data/lib/chefspec/api/include_any_recipe.rb +24 -0
  9. data/lib/chefspec/api/include_recipe.rb +25 -23
  10. data/lib/chefspec/api/link.rb +24 -98
  11. data/lib/chefspec/api/notifications.rb +37 -35
  12. data/lib/chefspec/api/reboot.rb +9 -13
  13. data/lib/chefspec/api/render_file.rb +34 -32
  14. data/lib/chefspec/api/state_attrs.rb +27 -25
  15. data/lib/chefspec/api/stubs.rb +183 -0
  16. data/lib/chefspec/api/stubs_for.rb +139 -0
  17. data/lib/chefspec/api/subscriptions.rb +34 -32
  18. data/lib/chefspec/api/user.rb +221 -219
  19. data/lib/chefspec/api.rb +32 -89
  20. data/lib/chefspec/berkshelf.rb +5 -5
  21. data/lib/chefspec/cacher.rb +2 -2
  22. data/lib/chefspec/coverage/filters.rb +18 -15
  23. data/lib/chefspec/coverage.rb +36 -40
  24. data/lib/chefspec/deprecations.rb +5 -14
  25. data/lib/chefspec/errors.rb +8 -7
  26. data/lib/chefspec/expect_exception.rb +2 -1
  27. data/lib/chefspec/extensions/chef/client.rb +6 -7
  28. data/lib/chefspec/extensions/chef/conditional.rb +5 -3
  29. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +33 -0
  30. data/lib/chefspec/extensions/chef/cookbook_loader.rb +14 -0
  31. data/lib/chefspec/extensions/chef/cookbook_uploader.rb +4 -3
  32. data/lib/chefspec/extensions/chef/data_query.rb +8 -11
  33. data/lib/chefspec/extensions/chef/lwrp_base.rb +18 -21
  34. data/lib/chefspec/extensions/chef/provider.rb +39 -0
  35. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +15 -17
  36. data/lib/chefspec/extensions/chef/resource.rb +148 -9
  37. data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +84 -0
  38. data/lib/chefspec/extensions/chef/securable.rb +1 -1
  39. data/lib/chefspec/extensions/ohai/system.rb +11 -0
  40. data/lib/chefspec/extensions.rb +21 -0
  41. data/lib/chefspec/file_cache_path_proxy.rb +3 -3
  42. data/lib/chefspec/formatter.rb +15 -3
  43. data/lib/chefspec/librarian.rb +7 -6
  44. data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
  45. data/lib/chefspec/matchers/include_any_recipe_matcher.rb +51 -0
  46. data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
  47. data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
  48. data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
  49. data/lib/chefspec/matchers/render_file_matcher.rb +39 -29
  50. data/lib/chefspec/matchers/resource_matcher.rb +19 -17
  51. data/lib/chefspec/matchers.rb +9 -8
  52. data/lib/chefspec/mixins/normalize.rb +1 -1
  53. data/lib/chefspec/policyfile.rb +16 -9
  54. data/lib/chefspec/renderer.rb +4 -4
  55. data/lib/chefspec/rspec.rb +4 -8
  56. data/lib/chefspec/runner.rb +8 -0
  57. data/lib/chefspec/server.rb +1 -1
  58. data/lib/chefspec/server_methods.rb +9 -9
  59. data/lib/chefspec/server_runner.rb +21 -17
  60. data/lib/chefspec/solo_runner.rb +148 -42
  61. data/lib/chefspec/stubs/command_registry.rb +1 -1
  62. data/lib/chefspec/stubs/command_stub.rb +1 -1
  63. data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
  64. data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
  65. data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
  66. data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
  67. data/lib/chefspec/stubs/registry.rb +1 -1
  68. data/lib/chefspec/stubs/search_registry.rb +2 -2
  69. data/lib/chefspec/stubs/search_stub.rb +2 -2
  70. data/lib/chefspec/util.rb +7 -7
  71. data/lib/chefspec/version.rb +1 -1
  72. data/lib/chefspec/zero_server.rb +23 -21
  73. data/lib/chefspec.rb +29 -36
  74. data/spec/spec_helper.rb +3 -4
  75. data/spec/support/hash.rb +4 -4
  76. data/spec/unit/cacher_spec.rb +17 -17
  77. data/spec/unit/coverage/filters_spec.rb +16 -16
  78. data/spec/unit/deprecations_spec.rb +9 -35
  79. data/spec/unit/errors_spec.rb +15 -15
  80. data/spec/unit/expect_exception_spec.rb +9 -9
  81. data/spec/unit/macros_spec.rb +57 -57
  82. data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
  83. data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +52 -0
  84. data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
  85. data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
  86. data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
  87. data/spec/unit/matchers/render_file_matcher_spec.rb +31 -24
  88. data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
  89. data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
  90. data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
  91. data/spec/unit/renderer_spec.rb +36 -36
  92. data/spec/unit/server_runner_spec.rb +6 -6
  93. data/spec/unit/solo_runner_spec.rb +70 -70
  94. data/spec/unit/stubs/command_registry_spec.rb +11 -11
  95. data/spec/unit/stubs/command_stub_spec.rb +26 -26
  96. data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
  97. data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
  98. data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
  99. data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
  100. data/spec/unit/stubs/registry_spec.rb +9 -9
  101. data/spec/unit/stubs/search_registry_spec.rb +17 -17
  102. data/spec/unit/stubs/search_stub_spec.rb +14 -14
  103. data/spec/unit/stubs/stub_spec.rb +22 -22
  104. data/templates/errors/may_need_to_specify_platform.erb +3 -3
  105. data/templates/errors/shell_out_not_stubbed.erb +10 -0
  106. metadata +47 -902
  107. data/.gitignore +0 -16
  108. data/.travis.yml +0 -32
  109. data/CHANGELOG.md +0 -777
  110. data/CONTRIBUTING.md +0 -52
  111. data/ISSUES.md +0 -41
  112. data/README.md +0 -1230
  113. data/examples/apt_package/recipes/install.rb +0 -13
  114. data/examples/apt_package/recipes/purge.rb +0 -13
  115. data/examples/apt_package/recipes/reconfig.rb +0 -13
  116. data/examples/apt_package/recipes/remove.rb +0 -13
  117. data/examples/apt_package/recipes/upgrade.rb +0 -13
  118. data/examples/apt_package/spec/install_spec.rb +0 -26
  119. data/examples/apt_package/spec/purge_spec.rb +0 -22
  120. data/examples/apt_package/spec/reconfig_spec.rb +0 -22
  121. data/examples/apt_package/spec/remove_spec.rb +0 -22
  122. data/examples/apt_package/spec/upgrade_spec.rb +0 -22
  123. data/examples/apt_repository/recipes/add.rb +0 -8
  124. data/examples/apt_repository/recipes/remove.rb +0 -4
  125. data/examples/apt_repository/spec/add_spec.rb +0 -17
  126. data/examples/apt_repository/spec/remove_spec.rb +0 -12
  127. data/examples/apt_update/recipes/periodic.rb +0 -5
  128. data/examples/apt_update/recipes/update.rb +0 -3
  129. data/examples/apt_update/spec/periodic_spec.rb +0 -17
  130. data/examples/apt_update/spec/update_spec.rb +0 -12
  131. data/examples/attributes/attributes/default.rb +0 -1
  132. data/examples/attributes/recipes/default.rb +0 -4
  133. data/examples/attributes/spec/default_spec.rb +0 -20
  134. data/examples/batch/recipes/run.rb +0 -9
  135. data/examples/batch/spec/run_spec.rb +0 -22
  136. data/examples/bff_package/recipes/install.rb +0 -13
  137. data/examples/bff_package/recipes/purge.rb +0 -13
  138. data/examples/bff_package/recipes/remove.rb +0 -13
  139. data/examples/bff_package/recipes/upgrade.rb +0 -13
  140. data/examples/bff_package/spec/install_spec.rb +0 -23
  141. data/examples/bff_package/spec/purge_spec.rb +0 -19
  142. data/examples/bff_package/spec/remove_spec.rb +0 -19
  143. data/examples/bff_package/spec/upgrade_spec.rb +0 -19
  144. data/examples/cab_package/recipes/install.rb +0 -13
  145. data/examples/cab_package/recipes/remove.rb +0 -13
  146. data/examples/cab_package/spec/install_spec.rb +0 -26
  147. data/examples/cab_package/spec/remove_spec.rb +0 -22
  148. data/examples/cached/recipes/default.rb +0 -1
  149. data/examples/cached/spec/default_spec.rb +0 -13
  150. data/examples/chef_gem/recipes/install.rb +0 -18
  151. data/examples/chef_gem/recipes/purge.rb +0 -16
  152. data/examples/chef_gem/recipes/reconfig.rb +0 -16
  153. data/examples/chef_gem/recipes/remove.rb +0 -16
  154. data/examples/chef_gem/recipes/upgrade.rb +0 -16
  155. data/examples/chef_gem/spec/install_spec.rb +0 -23
  156. data/examples/chef_gem/spec/purge_spec.rb +0 -19
  157. data/examples/chef_gem/spec/reconfig_spec.rb +0 -19
  158. data/examples/chef_gem/spec/remove_spec.rb +0 -19
  159. data/examples/chef_gem/spec/upgrade_spec.rb +0 -19
  160. data/examples/chocolatey_package/recipes/install.rb +0 -6
  161. data/examples/chocolatey_package/recipes/remove.rb +0 -8
  162. data/examples/chocolatey_package/recipes/upgrade.rb +0 -8
  163. data/examples/chocolatey_package/spec/install_spec.rb +0 -19
  164. data/examples/chocolatey_package/spec/remove_spec.rb +0 -18
  165. data/examples/chocolatey_package/spec/upgrade_spec.rb +0 -18
  166. data/examples/compile_time/recipes/default.rb +0 -3
  167. data/examples/compile_time/spec/default_spec.rb +0 -27
  168. data/examples/cookbook_file/recipes/create.rb +0 -15
  169. data/examples/cookbook_file/recipes/create_if_missing.rb +0 -15
  170. data/examples/cookbook_file/recipes/delete.rb +0 -15
  171. data/examples/cookbook_file/recipes/touch.rb +0 -15
  172. data/examples/cookbook_file/spec/create_if_missing_spec.rb +0 -28
  173. data/examples/cookbook_file/spec/create_spec.rb +0 -32
  174. data/examples/cookbook_file/spec/delete_spec.rb +0 -19
  175. data/examples/cookbook_file/spec/touch_spec.rb +0 -19
  176. data/examples/cron/recipes/create.rb +0 -10
  177. data/examples/cron/recipes/delete.rb +0 -9
  178. data/examples/cron/spec/create_spec.rb +0 -19
  179. data/examples/cron/spec/delete_spec.rb +0 -15
  180. data/examples/custom_matcher/libraries/matcher.rb +0 -23
  181. data/examples/custom_matcher/providers/thing.rb +0 -2
  182. data/examples/custom_matcher/recipes/install.rb +0 -13
  183. data/examples/custom_matcher/recipes/remove.rb +0 -13
  184. data/examples/custom_matcher/resources/thing.rb +0 -5
  185. data/examples/custom_matcher/spec/install_spec.rb +0 -27
  186. data/examples/custom_matcher/spec/remove_spec.rb +0 -23
  187. data/examples/custom_resource/libraries/matchers.rb +0 -5
  188. data/examples/custom_resource/recipes/default.rb +0 -1
  189. data/examples/custom_resource/resources/custom_resource.rb +0 -9
  190. data/examples/custom_resource/spec/default_spec.rb +0 -18
  191. data/examples/deploy/recipes/deploy.rb +0 -10
  192. data/examples/deploy/recipes/force_deploy.rb +0 -9
  193. data/examples/deploy/recipes/rollback.rb +0 -9
  194. data/examples/deploy/spec/deploy_spec.rb +0 -15
  195. data/examples/deploy/spec/force_deploy_spec.rb +0 -15
  196. data/examples/deploy/spec/rollback_spec.rb +0 -15
  197. data/examples/directory/recipes/create.rb +0 -18
  198. data/examples/directory/recipes/delete.rb +0 -14
  199. data/examples/directory/spec/create_spec.rb +0 -34
  200. data/examples/directory/spec/delete_spec.rb +0 -26
  201. data/examples/dnf_package/recipes/install.rb +0 -13
  202. data/examples/dnf_package/recipes/purge.rb +0 -13
  203. data/examples/dnf_package/recipes/remove.rb +0 -13
  204. data/examples/dnf_package/recipes/upgrade.rb +0 -13
  205. data/examples/dnf_package/spec/install_spec.rb +0 -26
  206. data/examples/dnf_package/spec/purge_spec.rb +0 -22
  207. data/examples/dnf_package/spec/remove_spec.rb +0 -22
  208. data/examples/dnf_package/spec/upgrade_spec.rb +0 -22
  209. data/examples/do_nothing/recipes/default.rb +0 -3
  210. data/examples/do_nothing/spec/default_spec.rb +0 -15
  211. data/examples/dpkg_package/recipes/install.rb +0 -13
  212. data/examples/dpkg_package/recipes/purge.rb +0 -13
  213. data/examples/dpkg_package/recipes/remove.rb +0 -13
  214. data/examples/dpkg_package/spec/install_spec.rb +0 -26
  215. data/examples/dpkg_package/spec/purge_spec.rb +0 -22
  216. data/examples/dpkg_package/spec/remove_spec.rb +0 -22
  217. data/examples/dsc_resource/recipes/run.rb +0 -20
  218. data/examples/dsc_resource/spec/run_spec.rb +0 -38
  219. data/examples/dsc_script/recipes/run.rb +0 -12
  220. data/examples/dsc_script/spec/run_spec.rb +0 -16
  221. data/examples/env/recipes/create.rb +0 -13
  222. data/examples/env/recipes/delete.rb +0 -13
  223. data/examples/env/recipes/modify.rb +0 -13
  224. data/examples/env/spec/create_spec.rb +0 -26
  225. data/examples/env/spec/delete_spec.rb +0 -22
  226. data/examples/env/spec/modify_spec.rb +0 -22
  227. data/examples/erl_call/recipes/run.rb +0 -13
  228. data/examples/erl_call/spec/run_spec.rb +0 -23
  229. data/examples/execute/recipes/run.rb +0 -13
  230. data/examples/execute/spec/run_spec.rb +0 -23
  231. data/examples/expect_exception/recipes/compile_error.rb +0 -1
  232. data/examples/expect_exception/recipes/converge_error.rb +0 -5
  233. data/examples/expect_exception/recipes/no_error.rb +0 -1
  234. data/examples/expect_exception/spec/compile_error_spec.rb +0 -10
  235. data/examples/expect_exception/spec/converge_error_spec.rb +0 -10
  236. data/examples/expect_exception/spec/no_error_spec.rb +0 -10
  237. data/examples/file/recipes/create.rb +0 -15
  238. data/examples/file/recipes/create_if_missing.rb +0 -15
  239. data/examples/file/recipes/delete.rb +0 -15
  240. data/examples/file/recipes/touch.rb +0 -15
  241. data/examples/file/spec/create_if_missing_spec.rb +0 -28
  242. data/examples/file/spec/create_spec.rb +0 -32
  243. data/examples/file/spec/delete_spec.rb +0 -19
  244. data/examples/file/spec/touch_spec.rb +0 -19
  245. data/examples/freebsd_package/recipes/install.rb +0 -13
  246. data/examples/freebsd_package/recipes/remove.rb +0 -13
  247. data/examples/freebsd_package/spec/install_spec.rb +0 -26
  248. data/examples/freebsd_package/spec/remove_spec.rb +0 -22
  249. data/examples/gem_package/recipes/install.rb +0 -13
  250. data/examples/gem_package/recipes/purge.rb +0 -13
  251. data/examples/gem_package/recipes/reconfig.rb +0 -13
  252. data/examples/gem_package/recipes/remove.rb +0 -13
  253. data/examples/gem_package/recipes/upgrade.rb +0 -13
  254. data/examples/gem_package/spec/install_spec.rb +0 -23
  255. data/examples/gem_package/spec/purge_spec.rb +0 -19
  256. data/examples/gem_package/spec/reconfig_spec.rb +0 -19
  257. data/examples/gem_package/spec/remove_spec.rb +0 -19
  258. data/examples/gem_package/spec/upgrade_spec.rb +0 -19
  259. data/examples/git/recipes/checkout.rb +0 -13
  260. data/examples/git/recipes/export.rb +0 -13
  261. data/examples/git/recipes/sync.rb +0 -13
  262. data/examples/git/spec/checkout_spec.rb +0 -19
  263. data/examples/git/spec/export_spec.rb +0 -19
  264. data/examples/git/spec/sync_spec.rb +0 -23
  265. data/examples/group/recipes/create.rb +0 -13
  266. data/examples/group/recipes/manage.rb +0 -13
  267. data/examples/group/recipes/modify.rb +0 -13
  268. data/examples/group/recipes/remove.rb +0 -13
  269. data/examples/group/spec/create_spec.rb +0 -23
  270. data/examples/group/spec/manage_spec.rb +0 -19
  271. data/examples/group/spec/modify_spec.rb +0 -19
  272. data/examples/group/spec/remove_spec.rb +0 -18
  273. data/examples/guards/recipes/default.rb +0 -13
  274. data/examples/guards/spec/default_spec.rb +0 -17
  275. data/examples/heavy_provider_light_resource/libraries/resource_service.rb +0 -15
  276. data/examples/heavy_provider_light_resource/providers/service.rb +0 -9
  277. data/examples/heavy_provider_light_resource/recipes/default.rb +0 -3
  278. data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +0 -7
  279. data/examples/homebrew_package/recipes/install.rb +0 -13
  280. data/examples/homebrew_package/recipes/purge.rb +0 -13
  281. data/examples/homebrew_package/recipes/remove.rb +0 -13
  282. data/examples/homebrew_package/recipes/upgrade.rb +0 -13
  283. data/examples/homebrew_package/spec/install_spec.rb +0 -23
  284. data/examples/homebrew_package/spec/purge_spec.rb +0 -19
  285. data/examples/homebrew_package/spec/remove_spec.rb +0 -19
  286. data/examples/homebrew_package/spec/upgrade_spec.rb +0 -19
  287. data/examples/http_request/recipes/delete.rb +0 -13
  288. data/examples/http_request/recipes/get.rb +0 -13
  289. data/examples/http_request/recipes/head.rb +0 -13
  290. data/examples/http_request/recipes/options.rb +0 -13
  291. data/examples/http_request/recipes/post.rb +0 -13
  292. data/examples/http_request/recipes/put.rb +0 -13
  293. data/examples/http_request/spec/delete_spec.rb +0 -19
  294. data/examples/http_request/spec/get_spec.rb +0 -23
  295. data/examples/http_request/spec/head_spec.rb +0 -19
  296. data/examples/http_request/spec/options_spec.rb +0 -19
  297. data/examples/http_request/spec/post_spec.rb +0 -19
  298. data/examples/http_request/spec/put_spec.rb +0 -19
  299. data/examples/ifconfig/recipes/add.rb +0 -9
  300. data/examples/ifconfig/recipes/delete.rb +0 -8
  301. data/examples/ifconfig/recipes/disable.rb +0 -8
  302. data/examples/ifconfig/recipes/enable.rb +0 -8
  303. data/examples/ifconfig/spec/add_spec.rb +0 -19
  304. data/examples/ifconfig/spec/delete_spec.rb +0 -15
  305. data/examples/ifconfig/spec/disable_spec.rb +0 -15
  306. data/examples/ifconfig/spec/enable_spec.rb +0 -15
  307. data/examples/include_recipe/recipes/default.rb +0 -1
  308. data/examples/include_recipe/recipes/not.rb +0 -0
  309. data/examples/include_recipe/recipes/other.rb +0 -0
  310. data/examples/include_recipe/spec/default_spec.rb +0 -13
  311. data/examples/ips_package/recipes/install.rb +0 -13
  312. data/examples/ips_package/recipes/remove.rb +0 -13
  313. data/examples/ips_package/recipes/upgrade.rb +0 -13
  314. data/examples/ips_package/spec/install_spec.rb +0 -26
  315. data/examples/ips_package/spec/remove_spec.rb +0 -22
  316. data/examples/ips_package/spec/upgrade_spec.rb +0 -22
  317. data/examples/launchd/recipes/create.rb +0 -5
  318. data/examples/launchd/recipes/create_if_missing.rb +0 -3
  319. data/examples/launchd/recipes/delete.rb +0 -3
  320. data/examples/launchd/recipes/disable.rb +0 -3
  321. data/examples/launchd/recipes/enable.rb +0 -3
  322. data/examples/launchd/spec/create_if_missing_spec.rb +0 -10
  323. data/examples/launchd/spec/create_spec.rb +0 -14
  324. data/examples/launchd/spec/delete_spec.rb +0 -10
  325. data/examples/launchd/spec/disable_spec.rb +0 -10
  326. data/examples/launchd/spec/enable_spec.rb +0 -10
  327. data/examples/link/recipes/create.rb +0 -13
  328. data/examples/link/recipes/delete.rb +0 -13
  329. data/examples/link/recipes/link_to.rb +0 -3
  330. data/examples/link/spec/create_spec.rb +0 -23
  331. data/examples/link/spec/delete_spec.rb +0 -19
  332. data/examples/link/spec/link_to_spec.rb +0 -11
  333. data/examples/log/recipes/write.rb +0 -14
  334. data/examples/log/spec/write_spec.rb +0 -24
  335. data/examples/macports_package/recipes/install.rb +0 -13
  336. data/examples/macports_package/recipes/purge.rb +0 -13
  337. data/examples/macports_package/recipes/remove.rb +0 -13
  338. data/examples/macports_package/recipes/upgrade.rb +0 -13
  339. data/examples/macports_package/spec/install_spec.rb +0 -23
  340. data/examples/macports_package/spec/purge_spec.rb +0 -19
  341. data/examples/macports_package/spec/remove_spec.rb +0 -19
  342. data/examples/macports_package/spec/upgrade_spec.rb +0 -19
  343. data/examples/mdadm/recipes/assemble.rb +0 -13
  344. data/examples/mdadm/recipes/create.rb +0 -13
  345. data/examples/mdadm/recipes/stop.rb +0 -13
  346. data/examples/mdadm/spec/assemble_spec.rb +0 -19
  347. data/examples/mdadm/spec/create_spec.rb +0 -23
  348. data/examples/mdadm/spec/stop_spec.rb +0 -19
  349. data/examples/mount/recipes/disable.rb +0 -8
  350. data/examples/mount/recipes/enable.rb +0 -8
  351. data/examples/mount/recipes/mount.rb +0 -9
  352. data/examples/mount/recipes/remount.rb +0 -8
  353. data/examples/mount/recipes/umount.rb +0 -8
  354. data/examples/mount/spec/disable_spec.rb +0 -15
  355. data/examples/mount/spec/enable_spec.rb +0 -15
  356. data/examples/mount/spec/mount_spec.rb +0 -19
  357. data/examples/mount/spec/remount_spec.rb +0 -15
  358. data/examples/mount/spec/umount_spec.rb +0 -15
  359. data/examples/msu_package/recipes/install.rb +0 -13
  360. data/examples/msu_package/recipes/remove.rb +0 -13
  361. data/examples/msu_package/spec/install_spec.rb +0 -26
  362. data/examples/msu_package/spec/remove_spec.rb +0 -22
  363. data/examples/multiple_actions/recipes/default.rb +0 -3
  364. data/examples/multiple_actions/recipes/reversed.rb +0 -9
  365. data/examples/multiple_actions/recipes/sequential.rb +0 -9
  366. data/examples/multiple_actions/spec/default_spec.rb +0 -14
  367. data/examples/multiple_actions/spec/reversed_spec.rb +0 -17
  368. data/examples/multiple_actions/spec/sequential_spec.rb +0 -17
  369. data/examples/multiple_run_action/recipes/default.rb +0 -5
  370. data/examples/multiple_run_action/spec/default_spec.rb +0 -18
  371. data/examples/notifications/recipes/before.rb +0 -7
  372. data/examples/notifications/recipes/chained.rb +0 -12
  373. data/examples/notifications/recipes/default.rb +0 -7
  374. data/examples/notifications/recipes/delayed.rb +0 -7
  375. data/examples/notifications/recipes/immediately.rb +0 -7
  376. data/examples/notifications/spec/before_spec.rb +0 -16
  377. data/examples/notifications/spec/chained_spec.rb +0 -21
  378. data/examples/notifications/spec/default_spec.rb +0 -16
  379. data/examples/notifications/spec/delayed_spec.rb +0 -16
  380. data/examples/notifications/spec/immediately_spec.rb +0 -16
  381. data/examples/ohai/recipes/reload.rb +0 -13
  382. data/examples/ohai/spec/reload_spec.rb +0 -23
  383. data/examples/openbsd_package/recipes/install.rb +0 -13
  384. data/examples/openbsd_package/recipes/purge.rb +0 -13
  385. data/examples/openbsd_package/recipes/remove.rb +0 -13
  386. data/examples/openbsd_package/recipes/upgrade.rb +0 -13
  387. data/examples/openbsd_package/spec/install_spec.rb +0 -23
  388. data/examples/openbsd_package/spec/purge_spec.rb +0 -19
  389. data/examples/openbsd_package/spec/remove_spec.rb +0 -19
  390. data/examples/openbsd_package/spec/upgrade_spec.rb +0 -19
  391. data/examples/osx_profile/recipes/install.rb +0 -8
  392. data/examples/osx_profile/recipes/remove.rb +0 -8
  393. data/examples/osx_profile/spec/install_spec.rb +0 -15
  394. data/examples/osx_profile/spec/remove_spec.rb +0 -13
  395. data/examples/package/recipes/install.rb +0 -17
  396. data/examples/package/recipes/purge.rb +0 -17
  397. data/examples/package/recipes/reconfig.rb +0 -17
  398. data/examples/package/recipes/remove.rb +0 -17
  399. data/examples/package/recipes/upgrade.rb +0 -17
  400. data/examples/package/spec/install_spec.rb +0 -27
  401. data/examples/package/spec/purge_spec.rb +0 -23
  402. data/examples/package/spec/reconfig_spec.rb +0 -23
  403. data/examples/package/spec/remove_spec.rb +0 -23
  404. data/examples/package/spec/upgrade_spec.rb +0 -23
  405. data/examples/pacman_package/recipes/install.rb +0 -13
  406. data/examples/pacman_package/recipes/purge.rb +0 -13
  407. data/examples/pacman_package/recipes/remove.rb +0 -13
  408. data/examples/pacman_package/recipes/upgrade.rb +0 -13
  409. data/examples/pacman_package/spec/install_spec.rb +0 -26
  410. data/examples/pacman_package/spec/purge_spec.rb +0 -22
  411. data/examples/pacman_package/spec/remove_spec.rb +0 -22
  412. data/examples/pacman_package/spec/upgrade_spec.rb +0 -22
  413. data/examples/paludis_package/recipes/install.rb +0 -13
  414. data/examples/paludis_package/recipes/purge.rb +0 -13
  415. data/examples/paludis_package/recipes/remove.rb +0 -13
  416. data/examples/paludis_package/recipes/upgrade.rb +0 -13
  417. data/examples/paludis_package/spec/install_spec.rb +0 -23
  418. data/examples/paludis_package/spec/purge_spec.rb +0 -19
  419. data/examples/paludis_package/spec/remove_spec.rb +0 -19
  420. data/examples/paludis_package/spec/upgrade_spec.rb +0 -19
  421. data/examples/portage_package/recipes/install.rb +0 -13
  422. data/examples/portage_package/recipes/purge.rb +0 -13
  423. data/examples/portage_package/recipes/remove.rb +0 -13
  424. data/examples/portage_package/recipes/upgrade.rb +0 -13
  425. data/examples/portage_package/spec/install_spec.rb +0 -26
  426. data/examples/portage_package/spec/purge_spec.rb +0 -22
  427. data/examples/portage_package/spec/remove_spec.rb +0 -22
  428. data/examples/portage_package/spec/upgrade_spec.rb +0 -22
  429. data/examples/powershell_script/recipes/run.rb +0 -9
  430. data/examples/powershell_script/spec/run_spec.rb +0 -22
  431. data/examples/reboot/recipes/cancel.rb +0 -3
  432. data/examples/reboot/recipes/now.rb +0 -3
  433. data/examples/reboot/recipes/request.rb +0 -3
  434. data/examples/reboot/spec/cancel_spec.rb +0 -9
  435. data/examples/reboot/spec/now_spec.rb +0 -9
  436. data/examples/reboot/spec/request_spec.rb +0 -9
  437. data/examples/registry_key/recipes/create.rb +0 -13
  438. data/examples/registry_key/recipes/create_if_missing.rb +0 -13
  439. data/examples/registry_key/recipes/delete.rb +0 -13
  440. data/examples/registry_key/recipes/delete_key.rb +0 -13
  441. data/examples/registry_key/spec/create_if_missing_spec.rb +0 -22
  442. data/examples/registry_key/spec/create_spec.rb +0 -26
  443. data/examples/registry_key/spec/delete_key_spec.rb +0 -22
  444. data/examples/registry_key/spec/delete_spec.rb +0 -22
  445. data/examples/remote_directory/recipes/create.rb +0 -13
  446. data/examples/remote_directory/recipes/create_if_missing.rb +0 -13
  447. data/examples/remote_directory/recipes/delete.rb +0 -13
  448. data/examples/remote_directory/spec/create_if_missing_spec.rb +0 -19
  449. data/examples/remote_directory/spec/create_spec.rb +0 -23
  450. data/examples/remote_directory/spec/delete_spec.rb +0 -19
  451. data/examples/remote_file/recipes/create.rb +0 -18
  452. data/examples/remote_file/recipes/create_if_missing.rb +0 -16
  453. data/examples/remote_file/recipes/delete.rb +0 -16
  454. data/examples/remote_file/recipes/touch.rb +0 -16
  455. data/examples/remote_file/spec/create_if_missing_spec.rb +0 -19
  456. data/examples/remote_file/spec/create_spec.rb +0 -23
  457. data/examples/remote_file/spec/delete_spec.rb +0 -19
  458. data/examples/remote_file/spec/touch_spec.rb +0 -19
  459. data/examples/render_file/files/default/cookbook_file +0 -1
  460. data/examples/render_file/recipes/default.rb +0 -15
  461. data/examples/render_file/recipes/template_helpers.rb +0 -9
  462. data/examples/render_file/spec/default_spec.rb +0 -155
  463. data/examples/render_file/spec/template_helpers_spec.rb +0 -10
  464. data/examples/render_file/templates/default/_partial.erb +0 -1
  465. data/examples/render_file/templates/default/partial.erb +0 -1
  466. data/examples/render_file/templates/default/template.erb +0 -1
  467. data/examples/render_file/templates/default/template_with_helper.erb +0 -1
  468. data/examples/roles/recipes/another.rb +0 -3
  469. data/examples/roles/recipes/default.rb +0 -1
  470. data/examples/roles/roles/role.rb +0 -9
  471. data/examples/roles/spec/default_spec.rb +0 -21
  472. data/examples/route/recipes/add.rb +0 -13
  473. data/examples/route/recipes/delete.rb +0 -13
  474. data/examples/route/spec/add_spec.rb +0 -23
  475. data/examples/route/spec/delete_spec.rb +0 -19
  476. data/examples/rpm_package/recipes/install.rb +0 -13
  477. data/examples/rpm_package/recipes/remove.rb +0 -13
  478. data/examples/rpm_package/recipes/upgrade.rb +0 -13
  479. data/examples/rpm_package/spec/install_spec.rb +0 -26
  480. data/examples/rpm_package/spec/remove_spec.rb +0 -22
  481. data/examples/rpm_package/spec/upgrade_spec.rb +0 -22
  482. data/examples/ruby_block/recipes/create.rb +0 -8
  483. data/examples/ruby_block/recipes/run.rb +0 -9
  484. data/examples/ruby_block/spec/create_spec.rb +0 -13
  485. data/examples/ruby_block/spec/run_spec.rb +0 -18
  486. data/examples/script/recipes/run_bash.rb +0 -9
  487. data/examples/script/recipes/run_csh.rb +0 -9
  488. data/examples/script/recipes/run_ksh.rb +0 -9
  489. data/examples/script/recipes/run_perl.rb +0 -9
  490. data/examples/script/recipes/run_python.rb +0 -9
  491. data/examples/script/recipes/run_ruby.rb +0 -9
  492. data/examples/script/recipes/run_script.rb +0 -9
  493. data/examples/script/spec/run_bash_spec.rb +0 -19
  494. data/examples/script/spec/run_csh_spec.rb +0 -19
  495. data/examples/script/spec/run_ksh_spec.rb +0 -19
  496. data/examples/script/spec/run_perl_spec.rb +0 -19
  497. data/examples/script/spec/run_python_spec.rb +0 -19
  498. data/examples/script/spec/run_ruby_spec.rb +0 -19
  499. data/examples/script/spec/run_script_spec.rb +0 -19
  500. data/examples/server/recipes/client.rb +0 -6
  501. data/examples/server/recipes/data_bag.rb +0 -7
  502. data/examples/server/recipes/environment.rb +0 -6
  503. data/examples/server/recipes/node.rb +0 -6
  504. data/examples/server/recipes/render_with_cached.rb +0 -3
  505. data/examples/server/recipes/role.rb +0 -6
  506. data/examples/server/recipes/search.rb +0 -5
  507. data/examples/server/spec/client_spec.rb +0 -18
  508. data/examples/server/spec/data_bag_spec.rb +0 -25
  509. data/examples/server/spec/environment_spec.rb +0 -18
  510. data/examples/server/spec/exotic_port_spec.rb +0 -17
  511. data/examples/server/spec/node_spec.rb +0 -49
  512. data/examples/server/spec/render_with_cached_spec.rb +0 -15
  513. data/examples/server/spec/role_spec.rb +0 -18
  514. data/examples/server/spec/search_spec.rb +0 -61
  515. data/examples/service/recipes/disable.rb +0 -13
  516. data/examples/service/recipes/enable.rb +0 -13
  517. data/examples/service/recipes/reload.rb +0 -13
  518. data/examples/service/recipes/restart.rb +0 -13
  519. data/examples/service/recipes/start.rb +0 -13
  520. data/examples/service/recipes/stop.rb +0 -13
  521. data/examples/service/spec/disable_spec.rb +0 -19
  522. data/examples/service/spec/enable_spec.rb +0 -19
  523. data/examples/service/spec/reload_spec.rb +0 -19
  524. data/examples/service/spec/restart_spec.rb +0 -19
  525. data/examples/service/spec/start_spec.rb +0 -19
  526. data/examples/service/spec/stop_spec.rb +0 -19
  527. data/examples/smartos_package/recipes/install.rb +0 -13
  528. data/examples/smartos_package/recipes/remove.rb +0 -13
  529. data/examples/smartos_package/recipes/upgrade.rb +0 -13
  530. data/examples/smartos_package/spec/install_spec.rb +0 -26
  531. data/examples/smartos_package/spec/remove_spec.rb +0 -22
  532. data/examples/smartos_package/spec/upgrade_spec.rb +0 -22
  533. data/examples/solaris_package/recipes/install.rb +0 -13
  534. data/examples/solaris_package/recipes/remove.rb +0 -13
  535. data/examples/solaris_package/recipes/upgrade.rb +0 -13
  536. data/examples/solaris_package/spec/install_spec.rb +0 -26
  537. data/examples/solaris_package/spec/remove_spec.rb +0 -22
  538. data/examples/solaris_package/spec/upgrade_spec.rb +0 -22
  539. data/examples/state_attrs/providers/lwrp.rb +0 -2
  540. data/examples/state_attrs/recipes/default.rb +0 -3
  541. data/examples/state_attrs/resources/lwrp.rb +0 -6
  542. data/examples/state_attrs/spec/default_spec.rb +0 -12
  543. data/examples/step_into/providers/lwrp.rb +0 -3
  544. data/examples/step_into/providers/provides.rb +0 -3
  545. data/examples/step_into/recipes/default.rb +0 -3
  546. data/examples/step_into/resources/lwrp.rb +0 -4
  547. data/examples/step_into/resources/provides.rb +0 -6
  548. data/examples/step_into/spec/default_spec.rb +0 -30
  549. data/examples/stub_command/recipes/default.rb +0 -5
  550. data/examples/stub_command/recipes/other_recipe.rb +0 -3
  551. data/examples/stub_command/spec/default_spec.rb +0 -28
  552. data/examples/stub_data_bag/recipes/default.rb +0 -5
  553. data/examples/stub_data_bag/spec/default_spec.rb +0 -27
  554. data/examples/stub_data_bag_item/recipes/default.rb +0 -5
  555. data/examples/stub_data_bag_item/spec/default_spec.rb +0 -27
  556. data/examples/stub_node/recipes/default.rb +0 -0
  557. data/examples/stub_node/spec/default_spec.rb +0 -17
  558. data/examples/stub_search/recipes/block.rb +0 -3
  559. data/examples/stub_search/recipes/default.rb +0 -2
  560. data/examples/stub_search/spec/block_spec.rb +0 -27
  561. data/examples/stub_search/spec/default_spec.rb +0 -27
  562. data/examples/subscribes/recipes/before.rb +0 -5
  563. data/examples/subscribes/recipes/chained.rb +0 -10
  564. data/examples/subscribes/recipes/default.rb +0 -5
  565. data/examples/subscribes/recipes/delayed.rb +0 -5
  566. data/examples/subscribes/recipes/immediately.rb +0 -5
  567. data/examples/subscribes/spec/before_spec.rb +0 -16
  568. data/examples/subscribes/spec/chained_spec.rb +0 -21
  569. data/examples/subscribes/spec/default_spec.rb +0 -16
  570. data/examples/subscribes/spec/delayed_spec.rb +0 -16
  571. data/examples/subscribes/spec/immediately_spec.rb +0 -16
  572. data/examples/subversion/recipes/checkout.rb +0 -13
  573. data/examples/subversion/recipes/export.rb +0 -13
  574. data/examples/subversion/recipes/force_export.rb +0 -13
  575. data/examples/subversion/recipes/sync.rb +0 -13
  576. data/examples/subversion/spec/checkout_spec.rb +0 -19
  577. data/examples/subversion/spec/export_spec.rb +0 -19
  578. data/examples/subversion/spec/force_export_spec.rb +0 -19
  579. data/examples/subversion/spec/sync_spec.rb +0 -23
  580. data/examples/systemd_unit/recipes/create.rb +0 -3
  581. data/examples/systemd_unit/recipes/delete.rb +0 -3
  582. data/examples/systemd_unit/recipes/disable.rb +0 -3
  583. data/examples/systemd_unit/recipes/enable.rb +0 -3
  584. data/examples/systemd_unit/recipes/mask.rb +0 -3
  585. data/examples/systemd_unit/recipes/reload_or_restart.rb +0 -3
  586. data/examples/systemd_unit/recipes/reload_or_try_restart.rb +0 -3
  587. data/examples/systemd_unit/recipes/restart.rb +0 -3
  588. data/examples/systemd_unit/recipes/start.rb +0 -3
  589. data/examples/systemd_unit/recipes/stop.rb +0 -3
  590. data/examples/systemd_unit/recipes/try_restart.rb +0 -3
  591. data/examples/systemd_unit/recipes/unmask.rb +0 -3
  592. data/examples/systemd_unit/spec/create_spec.rb +0 -10
  593. data/examples/systemd_unit/spec/delete_spec.rb +0 -10
  594. data/examples/systemd_unit/spec/disable_spec.rb +0 -10
  595. data/examples/systemd_unit/spec/enable_spec.rb +0 -10
  596. data/examples/systemd_unit/spec/mask_spec.rb +0 -10
  597. data/examples/systemd_unit/spec/reload_or_restart_spec.rb +0 -10
  598. data/examples/systemd_unit/spec/reload_or_try_restart_spec.rb +0 -10
  599. data/examples/systemd_unit/spec/restart_spec.rb +0 -10
  600. data/examples/systemd_unit/spec/start_spec.rb +0 -10
  601. data/examples/systemd_unit/spec/stop_spec.rb +0 -10
  602. data/examples/systemd_unit/spec/try_restart_spec.rb +0 -10
  603. data/examples/systemd_unit/spec/unmask_spec.rb +0 -10
  604. data/examples/template/recipes/create.rb +0 -15
  605. data/examples/template/recipes/create_if_missing.rb +0 -15
  606. data/examples/template/recipes/delete.rb +0 -15
  607. data/examples/template/recipes/touch.rb +0 -15
  608. data/examples/template/spec/create_if_missing_spec.rb +0 -28
  609. data/examples/template/spec/create_spec.rb +0 -32
  610. data/examples/template/spec/delete_spec.rb +0 -19
  611. data/examples/template/spec/touch_spec.rb +0 -19
  612. data/examples/use_inline_resources/libraries/matchers.rb +0 -5
  613. data/examples/use_inline_resources/providers/lwrp.rb +0 -7
  614. data/examples/use_inline_resources/recipes/default.rb +0 -1
  615. data/examples/use_inline_resources/resources/lwrp.rb +0 -4
  616. data/examples/use_inline_resources/spec/default_spec.rb +0 -18
  617. data/examples/user/recipes/create.rb +0 -13
  618. data/examples/user/recipes/lock.rb +0 -13
  619. data/examples/user/recipes/manage.rb +0 -13
  620. data/examples/user/recipes/modify.rb +0 -13
  621. data/examples/user/recipes/remove.rb +0 -13
  622. data/examples/user/recipes/unlock.rb +0 -13
  623. data/examples/user/spec/create_spec.rb +0 -26
  624. data/examples/user/spec/lock_spec.rb +0 -22
  625. data/examples/user/spec/manage_spec.rb +0 -22
  626. data/examples/user/spec/modify_spec.rb +0 -22
  627. data/examples/user/spec/remove_spec.rb +0 -22
  628. data/examples/user/spec/unlock_spec.rb +0 -22
  629. data/examples/windows_package/recipes/install.rb +0 -13
  630. data/examples/windows_package/recipes/remove.rb +0 -13
  631. data/examples/windows_package/spec/install_spec.rb +0 -22
  632. data/examples/windows_package/spec/remove_spec.rb +0 -22
  633. data/examples/windows_service/recipes/configure_startup.rb +0 -13
  634. data/examples/windows_service/recipes/disable.rb +0 -13
  635. data/examples/windows_service/recipes/enable.rb +0 -13
  636. data/examples/windows_service/recipes/reload.rb +0 -13
  637. data/examples/windows_service/recipes/restart.rb +0 -13
  638. data/examples/windows_service/recipes/start.rb +0 -13
  639. data/examples/windows_service/recipes/stop.rb +0 -13
  640. data/examples/windows_service/spec/configure_startup_spec.rb +0 -22
  641. data/examples/windows_service/spec/disable_spec.rb +0 -22
  642. data/examples/windows_service/spec/enable_spec.rb +0 -22
  643. data/examples/windows_service/spec/reload_spec.rb +0 -22
  644. data/examples/windows_service/spec/restart_spec.rb +0 -22
  645. data/examples/windows_service/spec/start_spec.rb +0 -22
  646. data/examples/windows_service/spec/stop_spec.rb +0 -22
  647. data/examples/yum_package/recipes/install.rb +0 -13
  648. data/examples/yum_package/recipes/purge.rb +0 -13
  649. data/examples/yum_package/recipes/remove.rb +0 -13
  650. data/examples/yum_package/recipes/upgrade.rb +0 -13
  651. data/examples/yum_package/spec/install_spec.rb +0 -26
  652. data/examples/yum_package/spec/purge_spec.rb +0 -22
  653. data/examples/yum_package/spec/remove_spec.rb +0 -22
  654. data/examples/yum_package/spec/upgrade_spec.rb +0 -22
  655. data/examples/yum_repository/recipes/add.rb +0 -8
  656. data/examples/yum_repository/recipes/create.rb +0 -8
  657. data/examples/yum_repository/recipes/delete.rb +0 -3
  658. data/examples/yum_repository/recipes/makecache.rb +0 -3
  659. data/examples/yum_repository/recipes/remove.rb +0 -7
  660. data/examples/yum_repository/spec/add_spec.rb +0 -12
  661. data/examples/yum_repository/spec/create_spec.rb +0 -17
  662. data/examples/yum_repository/spec/delete_spec.rb +0 -12
  663. data/examples/yum_repository/spec/makecache_spec.rb +0 -12
  664. data/examples/yum_repository/spec/remove_spec.rb +0 -12
  665. data/examples/zypper_package/recipes/install.rb +0 -13
  666. data/examples/zypper_package/recipes/purge.rb +0 -13
  667. data/examples/zypper_package/recipes/remove.rb +0 -13
  668. data/examples/zypper_package/recipes/upgrade.rb +0 -13
  669. data/examples/zypper_package/spec/install_spec.rb +0 -23
  670. data/examples/zypper_package/spec/purge_spec.rb +0 -19
  671. data/examples/zypper_package/spec/remove_spec.rb +0 -19
  672. data/examples/zypper_package/spec/upgrade_spec.rb +0 -19
  673. data/features/apt_package.feature +0 -14
  674. data/features/apt_repository.feature +0 -15
  675. data/features/apt_update.feature +0 -13
  676. data/features/attributes.feature +0 -7
  677. data/features/batch.feature +0 -10
  678. data/features/bff_package.feature +0 -12
  679. data/features/cab_package.feature +0 -21
  680. data/features/cached.feature +0 -7
  681. data/features/chef_gem.feature +0 -14
  682. data/features/chocolatey_package.feature +0 -14
  683. data/features/compile_time.feature +0 -7
  684. data/features/cookbook_file.feature +0 -13
  685. data/features/cron.feature +0 -11
  686. data/features/custom_matcher.feature +0 -11
  687. data/features/custom_resource.feature +0 -7
  688. data/features/deploy.feature +0 -12
  689. data/features/directory.feature +0 -11
  690. data/features/dnf_package.feature +0 -26
  691. data/features/do_nothing.feature +0 -10
  692. data/features/dpkg_package.feature +0 -12
  693. data/features/dsc_resource.feature +0 -10
  694. data/features/dsc_script.feature +0 -10
  695. data/features/env.feature +0 -12
  696. data/features/erl_call.feature +0 -10
  697. data/features/execute.feature +0 -10
  698. data/features/exotic_zero_port.feature +0 -7
  699. data/features/expect_exception.feature +0 -12
  700. data/features/file.feature +0 -13
  701. data/features/freebsd_package.feature +0 -11
  702. data/features/gem_package.feature +0 -14
  703. data/features/git.feature +0 -12
  704. data/features/group.feature +0 -13
  705. data/features/guards.feature +0 -10
  706. data/features/heavy_provider_light_resource.feature +0 -10
  707. data/features/homebrew_package.feature +0 -12
  708. data/features/http_request.feature +0 -15
  709. data/features/ifconfig.feature +0 -13
  710. data/features/include_recipe.feature +0 -10
  711. data/features/ips_package.feature +0 -12
  712. data/features/launchd.feature +0 -17
  713. data/features/link.feature +0 -12
  714. data/features/log.feature +0 -10
  715. data/features/macports_package.feature +0 -13
  716. data/features/mdadm.feature +0 -12
  717. data/features/mount.feature +0 -14
  718. data/features/msu_package.feature +0 -23
  719. data/features/multiple_actions.feature +0 -12
  720. data/features/multiple_run_action.feature +0 -7
  721. data/features/notifications.feature +0 -14
  722. data/features/ohai.feature +0 -10
  723. data/features/openbsd_package.feature +0 -12
  724. data/features/osx_profile.feature +0 -13
  725. data/features/package.feature +0 -14
  726. data/features/pacman_package.feature +0 -13
  727. data/features/paludis_package.feature +0 -12
  728. data/features/portage_package.feature +0 -13
  729. data/features/powershell_script.feature +0 -10
  730. data/features/reboot.feature +0 -12
  731. data/features/registry_key.feature +0 -13
  732. data/features/remote_directory.feature +0 -12
  733. data/features/remote_file.feature +0 -13
  734. data/features/render_file.feature +0 -11
  735. data/features/roles.feature +0 -7
  736. data/features/route.feature +0 -11
  737. data/features/rpm_package.feature +0 -12
  738. data/features/ruby_block.feature +0 -11
  739. data/features/script.feature +0 -16
  740. data/features/server.feature +0 -16
  741. data/features/server_on_disk.feature +0 -16
  742. data/features/service.feature +0 -15
  743. data/features/smartos_package.feature +0 -12
  744. data/features/solaris_package.feature +0 -12
  745. data/features/state_attrs.feature +0 -7
  746. data/features/step_definitions/background_steps.rb +0 -7
  747. data/features/step_into.feature +0 -7
  748. data/features/stub_command.feature +0 -7
  749. data/features/stub_data_bag.feature +0 -7
  750. data/features/stub_data_bag_item.feature +0 -7
  751. data/features/stub_node.feature +0 -7
  752. data/features/stub_search.feature +0 -7
  753. data/features/subscribes.feature +0 -14
  754. data/features/subversion.feature +0 -13
  755. data/features/support/env.rb +0 -38
  756. data/features/support/executor.rb +0 -20
  757. data/features/support/exotic_zero_port.rb +0 -3
  758. data/features/support/on_disk.rb +0 -7
  759. data/features/systemd_unit.feature +0 -27
  760. data/features/template.feature +0 -13
  761. data/features/use_inline_resources.feature +0 -7
  762. data/features/user.feature +0 -15
  763. data/features/windows_package.feature +0 -11
  764. data/features/windows_service.feature +0 -16
  765. data/features/yum_package.feature +0 -13
  766. data/features/yum_repository.feature +0 -23
  767. data/features/zypper_package.feature +0 -13
  768. data/lib/chefspec/api/apt_package.rb +0 -192
  769. data/lib/chefspec/api/apt_repository.rb +0 -56
  770. data/lib/chefspec/api/apt_update.rb +0 -53
  771. data/lib/chefspec/api/batch.rb +0 -43
  772. data/lib/chefspec/api/bff_package.rb +0 -154
  773. data/lib/chefspec/api/cab_package.rb +0 -80
  774. data/lib/chefspec/api/chef_gem.rb +0 -191
  775. data/lib/chefspec/api/chocolatey_package.rb +0 -107
  776. data/lib/chefspec/api/cookbook_file.rb +0 -166
  777. data/lib/chefspec/api/cron.rb +0 -80
  778. data/lib/chefspec/api/deploy.rb +0 -117
  779. data/lib/chefspec/api/directory.rb +0 -80
  780. data/lib/chefspec/api/dnf_package.rb +0 -154
  781. data/lib/chefspec/api/dpkg_package.rb +0 -117
  782. data/lib/chefspec/api/dsc_resource.rb +0 -49
  783. data/lib/chefspec/api/dsc_script.rb +0 -37
  784. data/lib/chefspec/api/easy_install_package.rb +0 -154
  785. data/lib/chefspec/api/env.rb +0 -117
  786. data/lib/chefspec/api/erl_call.rb +0 -43
  787. data/lib/chefspec/api/execute.rb +0 -43
  788. data/lib/chefspec/api/file.rb +0 -166
  789. data/lib/chefspec/api/freebsd_package.rb +0 -80
  790. data/lib/chefspec/api/gem_package.rb +0 -191
  791. data/lib/chefspec/api/git.rb +0 -117
  792. data/lib/chefspec/api/group.rb +0 -154
  793. data/lib/chefspec/api/homebrew_package.rb +0 -154
  794. data/lib/chefspec/api/http_request.rb +0 -228
  795. data/lib/chefspec/api/ifconfig.rb +0 -154
  796. data/lib/chefspec/api/ips_package.rb +0 -117
  797. data/lib/chefspec/api/launchd.rb +0 -151
  798. data/lib/chefspec/api/log.rb +0 -43
  799. data/lib/chefspec/api/macports_package.rb +0 -154
  800. data/lib/chefspec/api/mdadm.rb +0 -117
  801. data/lib/chefspec/api/mount.rb +0 -192
  802. data/lib/chefspec/api/msu_package.rb +0 -81
  803. data/lib/chefspec/api/ohai.rb +0 -43
  804. data/lib/chefspec/api/openbsd_package.rb +0 -155
  805. data/lib/chefspec/api/osx_profile.rb +0 -63
  806. data/lib/chefspec/api/package.rb +0 -192
  807. data/lib/chefspec/api/pacman_package.rb +0 -155
  808. data/lib/chefspec/api/paludis_package.rb +0 -155
  809. data/lib/chefspec/api/portage_package.rb +0 -155
  810. data/lib/chefspec/api/powershell_script.rb +0 -43
  811. data/lib/chefspec/api/registry_key.rb +0 -166
  812. data/lib/chefspec/api/remote_directory.rb +0 -120
  813. data/lib/chefspec/api/remote_file.rb +0 -166
  814. data/lib/chefspec/api/route.rb +0 -80
  815. data/lib/chefspec/api/rpm_package.rb +0 -117
  816. data/lib/chefspec/api/ruby_block.rb +0 -68
  817. data/lib/chefspec/api/script.rb +0 -278
  818. data/lib/chefspec/api/service.rb +0 -246
  819. data/lib/chefspec/api/smartos_package.rb +0 -117
  820. data/lib/chefspec/api/solaris_package.rb +0 -117
  821. data/lib/chefspec/api/subversion.rb +0 -154
  822. data/lib/chefspec/api/systemd_unit.rb +0 -353
  823. data/lib/chefspec/api/template.rb +0 -166
  824. data/lib/chefspec/api/windows_package.rb +0 -86
  825. data/lib/chefspec/api/windows_service.rb +0 -286
  826. data/lib/chefspec/api/yum_package.rb +0 -154
  827. data/lib/chefspec/api/yum_repository.rb +0 -130
  828. data/lib/chefspec/api/zypper_package.rb +0 -154
  829. data/lib/chefspec/macros.rb +0 -222
  830. data/spec/unit/api_spec.rb +0 -18
data/README.md DELETED
@@ -1,1230 +0,0 @@
1
- # ChefSpec
2
-
3
- [![Gem Version](https://badge.fury.io/rb/chefspec.svg)](https://badge.fury.io/rb/chefspec) [![Build Status](https://travis-ci.org/sethvargo/chefspec.svg?branch=master)](https://travis-ci.org/sethvargo/chefspec)
4
-
5
- ChefSpec is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.
6
-
7
- ChefSpec runs your cookbook(s) locally with Chef Solo without actually converging a node. This has two primary benefits:
8
-
9
- - It's really fast!
10
- - Your tests can vary node attributes, operating systems, and search results to assert behavior under varying conditions.
11
-
12
- ## What people are saying
13
-
14
- > I just wanted to drop you a line to say "HELL YES!" to ChefSpec. - [Joe Goggins](https://twitter.com/jgoggins)
15
-
16
- > OK ChefSpec is my new best friend. Delightful few hours working with it. - [Michael Ivey](https://twitter.com/ivey)
17
-
18
- **Chat with us - [#chefspec](irc://irc.freenode.net/chefspec) on Freenode**
19
-
20
- ## Important Notes
21
-
22
- - **ChefSpec requires Ruby 2.2 or later and Chef 12.14.89 or later!**
23
- - **This documentation corresponds to the master branch, which may be unreleased. Please check the README of the latest git tag or the gem's source for your version's documentation!**
24
- - **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding aruba test from the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).**
25
- - **ChefSpec aims to maintain compatibility with the two most recent minor versions of Chef.** If you are running an older version of Chef it may work, or you will need to run an older version of ChefSpec.
26
-
27
- ## Notes on Compatibility with Chef Versions
28
-
29
- As a general rule, if it is tested in the Travis CI matrix, it is a supported version. The section below details any specific versions that are _not_ supported and why:
30
-
31
- Additionally, if you look at a cucumber feature and see a tag like `@not_chef_x_y_z`, that means that particular functionality is not supported on those versions of Chef.
32
-
33
- ## Writing a Cookbook Example
34
-
35
- If you want `knife` to automatically generate spec stubs for you, install [knife-spec](https://github.com/sethvargo/knife-spec).
36
-
37
- Given an extremely basic Chef recipe that just installs an operating system package:
38
-
39
- ```ruby
40
- package 'foo'
41
- ```
42
-
43
- the associated ChefSpec test might look like:
44
-
45
- ```ruby
46
- require 'chefspec'
47
-
48
- describe 'example::default' do
49
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
50
-
51
- it 'installs foo' do
52
- expect(chef_run).to install_package('foo')
53
- end
54
- end
55
- ```
56
-
57
- Let's step through this file to see what is happening:
58
-
59
- 1. At the top of the spec file we require the chefspec gem. This is required so that our custom matchers are loaded. In larger projects, it is common practice to create a file named "spec_helper.rb" and include ChefSpec and perform other setup tasks in that file.
60
- 2. The `describe` keyword is part of RSpec and indicates that everything nested beneath is describing the `example::default` recipe. The convention is to have a separate spec for each recipe in your cookbook.
61
- 3. The `let` block on creates the `ChefSpec:SoloRunner` with mocked Ohai data for Ubuntu 16.04 from [Fauxhai](https://github.com/customink/fauxhai). It then does a fake Chef run with the run_list of `example::default`. Any subsequent examples can then refer to `chef_run` in order to make assertions about the resources that were created during the mock converge.
62
- 4. The `described_recipe` macro is a ChefSpec helper method that infers the recipe from the `describe` block. Alternatively you could specify the recipe directly.
63
- 5. The `it` block is an example specifying that the `foo` package is installed. Normally you will have multiple `it` blocks per recipe, each making a single assertion.
64
-
65
- ## Configuration
66
-
67
- ChefSpec exposes a configuration layer at the global level and at the `Runner` level. The following settings are available:
68
-
69
- ```ruby
70
- RSpec.configure do |config|
71
- # Specify the path for Chef Solo to find cookbooks (default: [inferred from
72
- # the location of the calling spec file])
73
- config.cookbook_path = '/var/cookbooks'
74
-
75
- # Specify the path for Chef Solo to find roles (default: [ascending search])
76
- config.role_path = '/var/roles'
77
-
78
- # Specify the path for Chef Solo to find environments (default: [ascending search])
79
- config.environment_path = '/var/environments'
80
-
81
- # Specify the path for Chef Solo file cache path (default: nil)
82
- config.file_cache_path = Chef::Config[:file_cache_path]
83
-
84
- # Specify the Chef log_level (default: :warn)
85
- config.log_level = :debug
86
-
87
- # Specify the path to a local JSON file with Ohai data (default: nil)
88
- config.path = 'ohai.json'
89
-
90
- # Specify the operating platform to mock Ohai data from (default: nil)
91
- config.platform = 'ubuntu'
92
-
93
- # Specify the operating version to mock Ohai data from (default: nil)
94
- config.version = '14.04'
95
- end
96
- ```
97
-
98
- Values specified at the initialization of a "Runner" merge and take precedence over any global settings:
99
-
100
- ```ruby
101
- # Override only the operating system version (platform is still "ubuntu" from above)
102
- ChefSpec::SoloRunner.new(version: '16.04')
103
-
104
- # Use a different operating system platform and version
105
- ChefSpec::SoloRunner.new(platform: 'centos', version: '7.3.1611')
106
-
107
- # Specify a different cookbook_path
108
- ChefSpec::SoloRunner.new(cookbook_path: '/var/my/other/path', role_path: '/var/my/roles')
109
-
110
- # By default ChefSpec sets a new temporary directory for file caching in every run.
111
- # This can be overridden by passing the `file_cache_path` option.
112
- # Note: Resources containing `Chef::Config[:file_cache_path]` in their name or
113
- # attributes, will fail unless this option is specified.
114
- ChefSpec::SoloRunner.new(file_cache_path: Chef::Config[:file_cache_path])
115
-
116
- # Add debug log output
117
- ChefSpec::SoloRunner.new(log_level: :debug).converge(described_recipe)
118
- ```
119
-
120
- **NOTE** You do not _need_ to specify a platform and version to use ChefSpec. However, some cookbooks may rely on [Ohai](http://github.com/chef/ohai) data that ChefSpec cannot not automatically generate. Specifying the `platform` and `version` keys instructs ChefSpec to load stubbed Ohai attributes from another platform using [fauxhai](https://github.com/customink/fauxhai). See the [PLATFORMS.md file](https://github.com/customink/fauxhai/blob/master/PLATFORMS.md) in the Fauxhai repo for a complete list of platforms and versions for use with ChefSpec.
121
-
122
- ### ChefZero Server
123
-
124
- The `ServerRunner` uses a [chef-zero](https://github.com/chef/chef-zero) instance as a stand-in for a full Chef Server. The instance is created at the initiation of the ChefSpec suite and is terminated at its completion. In between each test the state of the ChefZero server is completely reset.
125
-
126
- ```ruby
127
- RSpec.configure do |config|
128
- # When using ChefSpec::ServerRunner, specify the data storage method (options: in_memory, on_disk; default: in_memory)
129
- # If you are in a low-memory environment, setting this value to :on_disk may improve speed and/or reliability.
130
- config.server_runner_data_store = :on_disk
131
-
132
- # Whether or not to clear the cookbooks on the ChefZero instance in-between each test (default: true)
133
- # For most people, not clearing the cookbooks will drastically improve test execution time. This is a
134
- # good option for people who are using chefspec within the context of a single Berksfile or Policyfile.
135
- config.server_runner_clear_cookbooks = false
136
- end
137
- ```
138
-
139
- ### Berkshelf
140
-
141
- If you are using Berkshelf, simply require `chefspec/berkshelf` in your `spec_helper` after requiring `chefspec`:
142
-
143
- ```ruby
144
- # spec_helper.rb
145
- require 'chefspec'
146
- require 'chefspec/berkshelf'
147
- ```
148
-
149
- Requiring this file will:
150
-
151
- - Create a temporary working directory
152
- - Download all the dependencies listed in your `Berksfile` into the temporary directory
153
- - Set ChefSpec's `cookbook_path` to the temporary directory
154
-
155
- You can customize the list of options passed to the installation command using the `berkshelf_options` RSpec configuration:
156
-
157
- ```ruby
158
- RSpec.configuration do |config|
159
- config.berkshelf_options = { only: "my-group" }
160
- end
161
- ```
162
-
163
- This is a Ruby hash and valid options include `only` and `except`.
164
-
165
- ### Librarian
166
-
167
- If you are using Librarian, simply require `chefspec/librarian` in your `spec_helper` after requiring `chefspec`:
168
-
169
- ```ruby
170
- # spec_helper.rb
171
- require 'chefspec'
172
- require 'chefspec/librarian'
173
- ```
174
-
175
- Requiring this file will:
176
-
177
- - Create a temporary working directory
178
- - Download all the dependencies listed in your `Cheffile` into the temporary directory
179
- - Set ChefSpec's `cookbook_path` to the temporary directory
180
-
181
- **NOTE** In order to test the cookbook in the current working directory, you have to write your `Cheffile` like this:
182
-
183
- ```ruby
184
- # Cheffile
185
- site 'https://supermarket.chef.io/api/v1'
186
-
187
- cookbook 'name_of_your_cookbook', path: '.'
188
- ```
189
-
190
- ### Policyfile
191
-
192
- If you are using Chef Policies with ChefDK, simply require `chefspec/policyfile` in your `spec_helper`, and ensure you are using the `ChefSpec::ServerRunner` - Chef Solo does not support the exported repository format because the cookbook names use the unique version identifier.
193
-
194
- ```ruby
195
- # spec_helper.rb
196
- require 'chefspec'
197
- require 'chefspec/policyfile'
198
- ```
199
-
200
- Requiring this file will:
201
-
202
- - Create a temporary working directory
203
- - Download all the dependencies listed in your `Policyfile.rb` into the temporary directory
204
- - Set ChefSpec's `cookbook_path` to the temporary directory
205
-
206
- Your `Policyfile.rb` should look something like this:
207
-
208
- ```ruby
209
- name 'my-cookbook'
210
- run_list 'my-cookbook::default'
211
- default_source :community
212
- cookbook 'my-cookbook', path: '.'
213
- ```
214
-
215
- ## Running Specs
216
-
217
- ChefSpec is actually an RSpec extension, so you can run your tests using the RSpec CLI:
218
-
219
- ```bash
220
- $ rspec
221
- ```
222
-
223
- You can also specify a specific spec to run and various RSpec command line options:
224
-
225
- ```bash
226
- $ rspec spec/unit/recipes/default_spec.rb --color
227
- ```
228
-
229
- For more information on the RSpec CLI, please see the [documentation](https://relishapp.com/rspec/rspec-core/docs/command-line).
230
-
231
- ## Making Assertions
232
-
233
- ChefSpec asserts that resource actions have been performed. In general, ChefSpec follows the following pattern:
234
-
235
- ```ruby
236
- require 'chefspec'
237
-
238
- describe 'example::default' do
239
- let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
240
-
241
- it 'does something' do
242
- expect(chef_run).to ACTION_RESOURCE(NAME)
243
- end
244
- end
245
- ```
246
-
247
- where:
248
-
249
- - _ACTION_ - the action on the resource (e.g. `install`)
250
- - _RESOURCE_ - the name of the resource (e.g. `package`)
251
- - _NAME_ - the name attribute for the resource (e.g. `apache2`)
252
-
253
- **NOTE** One exception to this rule is the `create_if_missing` action on the `file` resource. In this case the assertion is actually `create_file_if_missing`. Refer to `examples/file/spec/create_if_missing_spec.rb` for some examples.
254
-
255
- Here's a more concrete example:
256
-
257
- ```ruby
258
- require 'chefspec'
259
-
260
- describe 'example::default' do
261
- let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
262
-
263
- it 'installs apache2' do
264
- expect(chef_run).to install_package('apache2')
265
- end
266
- end
267
- ```
268
-
269
- This test is asserting that the Chef run will have a _package_ resource with the name _apache2_ with an action of _install_.
270
-
271
- To test that a resource action is performed with a specific set of attributes, you can call `with(ATTRIBUTES_HASH)` on the expectation, per the following example:
272
-
273
- ```ruby
274
- require 'chefspec'
275
-
276
- describe 'example::default' do
277
- let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
278
-
279
- it 'adds the member vagrant to the docker group' do
280
- expect(chef_run).to modify_group('docker').with(members: ['vagrant'])
281
- end
282
- end
283
- ```
284
-
285
- This test is asserting that the Chef run will have a _group_ resource with the name _docker_, an action of _modify_, and an attributes hash including `{ members: ['vagrant'] }`.
286
-
287
- ChefSpec includes matchers for all of Chef's core resources using the above schema. Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding cucumber test from the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).
288
-
289
- Additionally, ChefSpec includes the following helpful matchers. They are also [documented in Yard](http://rubydoc.info/github/sethvargo/chefspec), but they are included here because they do not follow the "general pattern".
290
-
291
- ### include_recipe
292
-
293
- Assert that the Chef run included a recipe from another cookbook
294
-
295
- ```ruby
296
- expect(chef_run).to include_recipe('other_cookbook::recipe')
297
- ```
298
-
299
- Keep the resources from an included recipe from being loaded into the Chef run, but test that the recipe was included
300
-
301
- ```ruby
302
- describe 'example::default' do
303
- let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
304
-
305
- before do
306
- allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).and_call_original
307
- allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('other_cookbook::default')
308
- end
309
-
310
- it 'includes the other_cookbook' do
311
- expect_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('other_cookbook::default')
312
- chef_run
313
- end
314
- end
315
- ```
316
-
317
- ### notify
318
-
319
- Assert that a resource notifies another in the Chef run
320
-
321
- ```ruby
322
- resource = chef_run.template('/etc/foo')
323
- expect(resource).to notify('service[apache2]').to(:restart).immediately
324
- ```
325
-
326
- ### subscribes
327
-
328
- Assert that a resource subscribes to another in the Chef run
329
-
330
- ```ruby
331
- resource = chef_run.service('apache2')
332
- expect(resource).to subscribe_to('template[/etc/foo]').on(:create).delayed
333
- ```
334
-
335
- ### render_file
336
-
337
- Assert that the Chef run renders a file (with optional content); this will match `cookbook_file`, `file`, and `template` resources and can also check the resulting content
338
-
339
- ```ruby
340
- expect(chef_run).to render_file('/etc/foo')
341
- expect(chef_run).to render_file('/etc/foo').with_content('This is content')
342
- expect(chef_run).to render_file('/etc/foo').with_content(/regex works too.+/)
343
- expect(chef_run).to render_file('/etc/foo').with_content { |content|
344
- # Regular RSpec matches work in here
345
- expect(content).to include('any RSpec matcher')
346
- }
347
- ```
348
-
349
- You can use any RSpec content matcher inside of the `with_content` predicate:
350
-
351
- ```ruby
352
- expect(chef_run).to render_file('/etc/foo').with_content(start_with('# First line'))
353
- ```
354
-
355
- It is possible to assert which [Chef phase of execution](https://docs.chef.io/chef_client.html#the-chef-client-title-run) a resource is created. Given a resource that is installed at compile time using `run_action`:
356
-
357
- ```ruby
358
- package('apache2').run_action(:install)
359
- ```
360
-
361
- You can assert that this package is installed during runtime using the `.at_compile_time` predicate on the resource matcher:
362
-
363
- ```ruby
364
- expect(chef_run).to install_package('apache2').at_compile_time
365
- ```
366
-
367
- Similarly, you can assert that a resource is executed during convergence time:
368
-
369
- ```ruby
370
- expect(chef_run).to install_package('apache2').at_converge_time
371
- ```
372
-
373
- Since "converge time" is the default behavior for all recipes, this test might be redundant and the predicate could be dropped depending on your situation.
374
-
375
- ### do_nothing
376
-
377
- Assert that a resource performs no action
378
-
379
- ```ruby
380
- resource = chef_run.execute('install')
381
- expect(resource).to do_nothing
382
- ```
383
-
384
- **For more complex examples, please see the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples) or the [Yard documentation](http://rubydoc.info/github/sethvargo/chefspec).**
385
-
386
- ## Setting node Attributes
387
-
388
- Node attribute can be set when creating the `Runner`. The initializer yields a block that gives full access to the node object:
389
-
390
- ```ruby
391
- describe 'example::default' do
392
- let(:chef_run) do
393
- ChefSpec::SoloRunner.new do |node|
394
- node.normal['cookbook']['attribute'] = 'hello'
395
- end.converge(described_recipe)
396
- end
397
- end
398
- ```
399
-
400
- ### Automatic attributes
401
-
402
- ChefSpec provides mocked automatic Ohai data using [fauxhai](https://github.com/customink/fauxhai). To mock out `automatic` attributes, you must use the `automatic` key:
403
-
404
- ```ruby
405
- describe 'example::default' do
406
- let(:chef_run) do
407
- ChefSpec::SoloRunner.new do |node|
408
- node.automatic['memory']['total'] = '512kB'
409
- end.converge(described_recipe)
410
- end
411
- end
412
- ```
413
-
414
- The `node` that is returned is actually a [`Chef::Node`](https://docs.chef.io/nodes.html) object.
415
-
416
- To set an attribute within a specific test, set the attribute in the `it` block and then **(re-)converge the node**:
417
-
418
- ```ruby
419
- describe 'example::default' do
420
- let(:chef_run) { ChefSpec::SoloRunner.new } # Notice we don't converge here
421
-
422
- it 'performs the action' do
423
- chef_run.node.normal['cookbook']['attribute'] = 'hello'
424
- chef_run.converge(described_recipe) # The converge happens inside the test
425
-
426
- expect(chef_run).to do_something
427
- end
428
- end
429
- ```
430
-
431
- ## Using a Chef Server
432
-
433
- All the examples thus far have used the `ChefSpec::SoloRunner`, which runs ChefSpec in Chef Solo mode. ChefSpec also includes the ability to create in-memory Chef Servers. This server can be populated with fake data and used to test search, data bags, and other "server-only" features.
434
-
435
- To use the ChefSpec server, simply replace `ChefSpec::SoloRunner` with `ChefSpec::ServerRunner`:
436
-
437
- ```diff
438
- describe 'example::default' do
439
- - let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
440
- + let(:chef_run) { ChefSpec::ServerRunner.converge(described_recipe) }
441
- end
442
- ```
443
-
444
- This will automatically create a Chef Server, synchronize all the cookbooks in your `cookbook_path`, and wire all the internals of Chef together. Recipe calls to `search`, `data_bag` and `data_bag_item` will now query this ChefSpec server.
445
-
446
- ### DSL
447
-
448
- The ChefSpec server includes a collection of helpful DSL methods for populating data into the Chef Server.
449
-
450
- Create a client:
451
-
452
- ```ruby
453
- ChefSpec::ServerRunner.new do |node, server|
454
- server.create_client('my_client', { admin: true })
455
- end
456
- ```
457
-
458
- Create a data bag (and items):
459
-
460
- ```ruby
461
- ChefSpec::ServerRunner.new do |node, server|
462
- server.create_data_bag('my_data_bag', {
463
- 'item_1' => {
464
- 'password' => 'abc123'
465
- },
466
- 'item_2' => {
467
- 'password' => 'def456'
468
- }
469
- })
470
- end
471
- ```
472
-
473
- Create an environment:
474
-
475
- ```ruby
476
- ChefSpec::ServerRunner.new do |node, server|
477
- server.create_environment('my_environment', { default_attributes: { description: '...' } })
478
- end
479
- ```
480
-
481
- Create a node:
482
-
483
- ```ruby
484
- ChefSpec::ServerRunner.new do |node, server|
485
- server.create_node('my_node', { run_list: ['...'] })
486
- end
487
- ```
488
-
489
- Note: the current "node" is always uploaded to the server. However, due to the way the Chef Client compiles cookbooks, you must update the current node on the server if any attributes are changed:
490
-
491
- ```ruby
492
- ChefSpec::ServerRunner.new do |node, server|
493
- node.normal['attribute'] = 'value'
494
-
495
- # At this point, the server already has a copy of the current node object due
496
- # to the way Chef compiled the resources. However, that node does not have
497
- # this new value. As such, you must "save" the node back to the server to
498
- # persist this attribute update.
499
- server.update_node(node)
500
- end
501
- ```
502
-
503
- You may also use the `stub_node` macro, which will create a new `Chef::Node` object and accepts the same parameters as the Chef Runner and a Fauxhai object:
504
-
505
- ```ruby
506
- www = stub_node(platform: 'ubuntu', version: '16.04') do |node|
507
- node.normal['attribute'] = 'value'
508
- end
509
-
510
- # `www` is now a local Chef::Node object you can use in your test. To publish
511
- # this node to the server, call `create_node`:
512
-
513
- ChefSpec::ServerRunner.new do |node, server|
514
- server.create_node(www)
515
- end
516
- ```
517
-
518
- Create a role:
519
-
520
- ```ruby
521
- ChefSpec::ServerRunner.new do |node, server|
522
- server.create_role('my_role', { default_attributes: {} })
523
- end
524
- ```
525
-
526
- **NOTE** The ChefSpec server is empty at the start of each example to avoid interdependent tests.
527
-
528
- ### Data Store
529
-
530
- The `ServerRunner` has two options for how it will store data: `in_memory` or `on_disk`. The default value is `in_memory`. These two options have different performance implications based on your specific setup. If you are running into performance problems (slow tests, frequent hanging, etc) with one setting, try using the other.
531
-
532
- ## Stubbing
533
-
534
- ### Command
535
-
536
- Given a recipe with shell guard:
537
-
538
- ```ruby
539
- template '/tmp/foo.txt' do
540
- not_if 'grep text /tmp/foo.txt'
541
- end
542
- ```
543
-
544
- ChefSpec will raise an error like:
545
-
546
- ```text
547
- Real commands are disabled. Unregistered command: `grep text /tmp/foo.txt`
548
-
549
- You can stub this command with:
550
-
551
- stub_command("grep text /tmp/foo.txt").and_return(true)
552
-
553
- ============================================================
554
- ```
555
-
556
- Just like the error message says, you must stub the command result. This can be done inside a `before` block or inside the `it` block, and the stubbing method accepts both a value or Ruby code. If provided a value, the result is static. If provided a Ruby block, the block is evaluated each time the search is called.
557
-
558
- ```ruby
559
- describe 'example::default' do
560
- let(:chef_run) { ChefSpec::SoloRunner.new }
561
-
562
- before do
563
- stub_command("grep text /tmp/foo.txt").and_return(true)
564
- end
565
- end
566
- ```
567
-
568
- ```ruby
569
- describe 'example::default' do
570
- let(:chef_run) { ChefSpec::SoloRunner.new }
571
-
572
- before do
573
- stub_command("grep text /tmp/foo.txt") { rand(50)%2 == 0 }
574
- end
575
- end
576
- ```
577
-
578
- The stubbed command can also be passed as a regular expression, allowing multiple commands to be stubbed with one line.
579
-
580
- ```ruby
581
- describe 'example::default' do
582
- let(:chef_run) { ChefSpec::SoloRunner.new }
583
-
584
- before do
585
- stub_command(/(foo)|(bar)/).and_return(true)
586
- end
587
- end
588
- ```
589
-
590
- ### Library Helpers
591
-
592
- Given a library helper with a `has_bacon?` method:
593
-
594
- ```ruby
595
- module Demo
596
- module Helper
597
-
598
- include Chef::Mixin::ShellOut
599
-
600
- def has_bacon?
601
- cmd = shell_out!('getent passwd bacon', {:returns => [0,2]})
602
- cmd.stderr.empty? && (cmd.stdout =~ /^bacon/)
603
- end
604
- end
605
- end
606
- ```
607
-
608
- Stub the output of the library helper. [Additional information](http://jtimberman.housepub.org/blog/2015/05/30/quick-tip-stubbing-library-helpers-in-chefspec/)
609
-
610
- ```ruby
611
- before do
612
- allow_any_instance_of(Chef::Node).to receive(:has_bacon?).and_return(true)
613
- end
614
- ```
615
-
616
- ### Data Bag & Data Bag Item
617
-
618
- **NOTE** This is not required if you are using a ChefSpec server.
619
-
620
- Given a recipe that executes a `data_bag` method:
621
-
622
- ```ruby
623
- data_bag('users').each do |user|
624
- data_bag_item('users', user['id'])
625
- end
626
- ```
627
-
628
- ChefSpec will raise an error like:
629
-
630
- ```text
631
- Real data_bags are disabled. Unregistered data_bag: data_bag(:users)
632
-
633
- You can stub this data_bag with:
634
-
635
- stub_data_bag("users").and_return([])
636
-
637
- ============================================================
638
- ```
639
-
640
- Just like the error message says, you must stub the result of the `data_bag` call. This can be done inside a `before` block or inside the `it` block, and the stubbing method accepts both a value or Ruby code. If provided a value, the result is static. If provided a Ruby block, the block is evaluated each time the search is called.
641
-
642
- ```ruby
643
- describe 'example::default' do
644
- let(:chef_run) { ChefSpec::SoloRunner.new }
645
-
646
- before do
647
- stub_data_bag('users').and_return([])
648
- end
649
- end
650
- ```
651
-
652
- ```ruby
653
- describe 'example::default' do
654
- let(:chef_run) { ChefSpec::SoloRunner.new }
655
-
656
- before do
657
- stub_data_bag('users').and_return(['svargo', 'francis'])
658
-
659
- stub_data_bag_item('users', 'svargo').and_return({ ... })
660
- stub_data_bag_item('users', 'francis') { (ruby code) }
661
- end
662
- end
663
- ```
664
-
665
- If you are using **Encrypted Data Bag Items**, you'll need to dive into the RSpec layer and stub that class method instead:
666
-
667
- ```ruby
668
- describe 'example::default' do
669
- before do
670
- allow(Chef::EncryptedDataBagItem).to receive(:load).with('users', 'svargo').and_return(...)
671
- end
672
- end
673
- ```
674
-
675
- ### Search
676
-
677
- **NOTE** This is not required if you are using a ChefSpec server.
678
-
679
- Because ChefSpec is a unit-testing framework, it is recommended that all third-party API calls be mocked or stubbed. ChefSpec exposes a helpful RSpec macro for stubbing search results in your tests. If you converge a Chef recipe that implements a `search` call, ChefSpec will throw an error like:
680
-
681
- ```text
682
- Real searches are disabled. Unregistered search: search(:node, 'name:hello')
683
-
684
- You can stub this search with:
685
-
686
- stub_search(:node, 'name:hello') { }
687
-
688
- ============================================================
689
- ```
690
-
691
- Just like the error message says, you must stub the search result. This can be done inside a `before` block or inside the `it` block, and the stubbing method accepts both a value or Ruby code. If provided a value, the result is static. If provided a Ruby block, the block is evaluated each time the search is called.
692
-
693
- ```ruby
694
- describe 'example::default' do
695
- let(:chef_run) { ChefSpec::SoloRunner.new }
696
-
697
- before do
698
- stub_search(:node, 'name:hello').and_return([])
699
- end
700
- end
701
- ```
702
-
703
- ```ruby
704
- describe 'example::default' do
705
- let(:chef_run) { ChefSpec::SoloRunner.new }
706
-
707
- before do
708
- stub_search(:node, 'name:hello') { (ruby_code) }
709
- end
710
- end
711
- ```
712
-
713
- ## Reporting
714
-
715
- ChefSpec can generate a report of resources read over resources tested.
716
-
717
- To generate the coverage report, add the following to your `spec_helper.rb` before you require any "Chef" code:
718
-
719
- ```ruby
720
- require 'chefspec'
721
- ChefSpec::Coverage.start!
722
-
723
- # Existing spec_helper contents...
724
- ```
725
-
726
- By default, that method will output helpful information to standard out:
727
-
728
- ```text
729
- ChefSpec Coverage report generated...
730
-
731
- Total Resources: 6
732
- Touched Resources: 1
733
- Touch Coverage: 16.67%
734
-
735
- Untouched Resources:
736
-
737
- package[git] bacon/recipes/default.rb:2
738
- package[build-essential] bacon/recipes/default.rb:3
739
- package[apache2] bacon/recipes/default.rb:4
740
- package[libvirt] bacon/recipes/default.rb:5
741
- package[core] bacon/recipes/default.rb:6
742
- ```
743
-
744
- By default, ChefSpec will test all cookbooks that are loaded as part of the Chef Client run. If you have a cookbook with many dependencies, this may be less than desirable. To restrict coverage reporting against certain cookbooks, `ChefSpec::Coverage` yields a block:
745
-
746
- ```ruby
747
- ChefSpec::Coverage.start! do
748
- add_filter 'vendor/cookbooks'
749
- end
750
- ```
751
-
752
- The `add_filter` method accepts a variety of objects. For example:
753
-
754
- ```ruby
755
- ChefSpec::Coverage.start! do
756
- # Strings are interpreted as file paths, with a forward anchor
757
- add_filter 'vendor/cookbooks'
758
-
759
- # Regular expressions must be escaped, but provide a nicer API for negative
760
- # back tracking
761
- add_filter /cookbooks\/(?!omnibus)/
762
-
763
- # Custom block filters yield a {Chef::Resource} object - if the block
764
- # evaluates to true, it will be filtered
765
- add_filter do |resource|
766
- # Bob's cookbook's are completely untested! Ignore them until he gets his
767
- # shit together.
768
- resource.source_file =~ /cookbooks\/bob-(.+)/
769
- end
770
- end
771
- ```
772
-
773
- For more complex scenarios, you can create a custom `Filter` object that inherits from `ChefSpec::Coverage::Filter` and implements the `matches?` method.
774
-
775
- ```ruby
776
- class CustomFilter < ChefSpec::Coverage::Filter
777
- def initialize(arg1, arg2, █)
778
- # Create a custom initialization method, do some magic, etc.
779
- end
780
-
781
- def matches?(resource)
782
- # Custom matching logic in here - anything that evaluates to "true" will be
783
- # filtered.
784
- end
785
- end
786
-
787
- ChefSpec::Coverage.start! do
788
- add_filter CustomFilter.new('foo', :bar)
789
- end
790
- ```
791
-
792
- If you are using ChefSpec's Berkshelf plugin, a filter is automatically created for you. If you would like to ignore that filter, you can `clear` all the filters before defining your own:
793
-
794
- ```ruby
795
- ChefSpec::Coverage.start! do
796
- filters.clear
797
-
798
- # Add your custom filters now
799
- end
800
- ```
801
-
802
- If you would like a different output format for the Coverage.report! output, you can specify one of the three built-in templates, or supply your own by calling the set_template in the `ChefSpec::Coverage` block:
803
-
804
- ```ruby
805
- ChefSpec::Coverage.start! do
806
- set_template 'json.erb'
807
- end
808
- ```
809
-
810
- Provided templates are human.erb_(default)_, table.erb and json.erb, to supply a custom template, specify a relative(to run directory) or absolute path.
811
-
812
- ```ruby
813
- ChefSpec::Coverage.start! do
814
- set_template '/opt/custom/templates/verbose.erb'
815
- end
816
- ```
817
-
818
- If you would like to add alternative reporting for the Coverage.report! ouput, you can supply your own by calling add_output in the `ChefSepc::Coverage` block:
819
- Note the reportOutput has the following items in it: total, touched, coverage and collections of untouched_resources and all_resources
820
-
821
- ```ruby
822
- ChefSpec::Coverage.start! do
823
- add_output do |reportOutput|
824
- File.open( "coverage.json","w" ) do |f|
825
- f.puts(reportOutput[:total])
826
- f.puts(reportOutput[:touched])
827
- f.puts(reportOutput[:coverage])
828
- f.puts(reportOutput[:untouched_resources])
829
- f.puts(reportOutput[:all_resources])
830
- end
831
- end
832
- end
833
- ```
834
- Note the above example outputs the raw data without applying formatting.
835
-
836
- ## Mocking Out Environments
837
-
838
- ### ServerRunner
839
-
840
- ```ruby
841
- ChefSpec::ServerRunner.new do |node, server|
842
- # Create the environment
843
- server.create_environment('staging', { default_attributes: { cookbook_attr: 'value' } })
844
-
845
- # Assign the environment to the node
846
- node.chef_environment = 'staging'
847
- end
848
- ```
849
-
850
- ### SoloRunner
851
-
852
- If you want to mock out `node.chef_environment`, you'll need to use RSpec mocks/stubs twice:
853
-
854
- ```ruby
855
- let(:chef_run) do
856
- ChefSpec::SoloRunner.new do |node|
857
- # Create a new environment (you could also use a different :let block or :before block)
858
- env = Chef::Environment.new
859
- env.name 'staging'
860
-
861
- # Stub the node to return this environment
862
- allow(node).to receive(:chef_environment).and_return(env.name)
863
-
864
- # Stub any calls to Environment.load to return this environment
865
- allow(Chef::Environment).to receive(:load).and_return(env)
866
- end.converge('cookbook::recipe')
867
- end
868
- ```
869
-
870
- **There is probably a better/easier way to do this. If you have a better solution, please open an issue or Pull Request so we can make this less painful :)**
871
-
872
- ## Testing LWRPs
873
-
874
- **WARNING** Cookbooks with dashes (hyphens) are difficult to test with ChefSpec because of how Chef classifies objects. We recommend naming cookbooks with underscores (`_`) instead of dashes (`-`).
875
-
876
- ChefSpec overrides all providers to take no action (otherwise it would actually converge your system). This means that the steps inside your LWRP are not actually executed. If an LWRP performs actions, those actions are never executed or added to the resource collection.
877
-
878
- In order to run the actions exposed by your LWRP, you have to explicitly tell the `Runner` to step into it:
879
-
880
- ```ruby
881
- require 'chefspec'
882
-
883
- describe 'foo::default' do
884
- let(:chef_run) do
885
- ChefSpec::SoloRunner.new(step_into: ['my_lwrp']).converge('foo::default')
886
- end
887
-
888
- it 'installs the foo package through my_lwrp' do
889
- expect(chef_run).to install_package('foo')
890
- end
891
- end
892
- ```
893
-
894
- **NOTE:** If your cookbook exposes LWRPs, it is highly recommended you also create a `libraries/matchers.rb` file as outlined below in the "Packaging Custom Matchers" section. **You should never `step_into` an LWRP unless you are testing it. Never `step_into` an LWRP from another cookbook!**
895
-
896
- ## Packaging Custom Matchers
897
-
898
- ChefSpec exposes the ability for cookbook authors to package custom matchers inside a cookbook so that other developers may take advantage of them in testing. This is done by creating a special library file in the cookbook named `matchers.rb`:
899
-
900
- ```ruby
901
- # cookbook/libraries/matchers.rb
902
-
903
- if defined?(ChefSpec)
904
- def my_custom_matcher(resource_name)
905
- ChefSpec::Matchers::ResourceMatcher.new(resource, action, resource_name)
906
- end
907
- end
908
- ```
909
-
910
- 1. The entire contents of this file must be wrapped with the conditional clause checking if `ChefSpec` is defined.
911
- 2. Each matcher is actually a top-level method. The above example corresponds to the following RSpec test:
912
-
913
- ```ruby
914
- expect(chef_run).to my_custom_matcher('...')
915
- ```
916
-
917
- 3. `ChefSpec::Matchers::ResourceMatcher` accepts three parameters:
918
-
919
- 1. The name of the resource to find in the resource collection (i.e. the name of the LWRP).
920
- 2. The action that resource should receive.
921
- 3. The value of the name attribute of the resource to find. (This is typically proxied as the value from the matcher definition.)
922
-
923
- ChefSpec's built-in `ResourceMatcher` _should_ satisfy most common use cases for packaging a custom matcher with your LWRPs. However, if your cookbook is extending Chef core or is outside of the scope of a traditional "resource", you may need to create a custom matcher. For more information on custom matchers in RSpec, please [watch the Railscast on Custom Matchers](http://railscasts.com/episodes/157-rspec-matchers-macros) or look at some of the other custom matchers in ChefSpec's source code.
924
-
925
- ### Example
926
-
927
- Suppose I have a cookbook named "motd" with a resource/provider "message".
928
-
929
- ```ruby
930
- # motd/resources/message.rb
931
- actions :write
932
- default_action :write
933
-
934
- attribute :message, name_attribute: true
935
- ```
936
-
937
- ```ruby
938
- # motd/providers/message.rb
939
- action :write do
940
- # ...
941
- end
942
- ```
943
-
944
- Chef will dynamically build the `motd_message` LWRP at runtime that can be used in the recipe DSL:
945
-
946
- ```ruby
947
- motd_message 'my message'
948
- ```
949
-
950
- You can package a custom ChefSpec matcher with the motd cookbook by including the following code in `libraries/matchers.rb`:
951
-
952
- ```ruby
953
- # motd/libraries/matchers.rb
954
- if defined?(ChefSpec)
955
- def write_motd_message(message)
956
- ChefSpec::Matchers::ResourceMatcher.new(:motd_message, :write, message)
957
- end
958
- end
959
- ```
960
-
961
- Other developers can write RSpec tests against your LWRP in their cookbooks:
962
-
963
- ```ruby
964
- expect(chef_run).to write_motd_message('my message')
965
- ```
966
-
967
- **Don't forget to include documentation in your cookbook's README noting the custom matcher and its API!**
968
-
969
- As a caveat, if your custom LWRP uses a custom `provides` value as shown below (Chef 12+), you will need to package slightly different custom matchers:
970
-
971
- ```ruby
972
- # motd/resources/message.rb
973
- actions :write
974
- default_action :write
975
-
976
- provides :foobar
977
-
978
- attribute :message, name_attribute: true
979
- ```
980
-
981
- With a custom `provides` declaration, the resource is still inserted into the resource collection with its generic name; `provides` is just sugar for use in the recipe. As such, you will also need to introduce sugar into your custom matchers:
982
-
983
- ```ruby
984
- # motd/libraries/matchers.rb
985
- if defined?(ChefSpec)
986
- def write_foobar(message)
987
- ChefSpec::Matchers::ResourceMatcher.new(:motd_message, :write, message)
988
- end
989
- end
990
- ```
991
-
992
- Notice that we have changed the name of the method to match the "foobar" action, but the resource matcher definition remains unchanged. When the Chef run executes, the resource will be inserted into the collection as `motd_message`, even though it was given a custom provides.
993
-
994
- ## Writing Custom Matchers
995
-
996
- If you are testing a cookbook that does not package its LWRP matchers, you can create your own following the same pattern as the "Packaging Custom Matchers" section. Simply, create a file at `spec/support/matchers.rb` and add your resource matchers:
997
-
998
- ```ruby
999
- # spec/support/matchers.rb
1000
- def my_custom_matcher(resource_name)
1001
- ChefSpec::Matchers::ResourceMatcher.new(:resource, :action, resource_name)
1002
- end
1003
- ```
1004
-
1005
- Then require this file in your `spec_helper.rb` so the matcher can be used:
1006
-
1007
- ```ruby
1008
- require_relative 'support/matchers'
1009
- ```
1010
-
1011
- Please use this as a _temporary_ solution. Consider sending a Pull Request to the LWRP author(s) packaging the custom resource matchers (see previous section).
1012
-
1013
- ## Matchers for looking up custom resources
1014
-
1015
- ChefSpec also provides a helper method to define a method on the Chef runner for locating a resource in the collection. This is helpful while asserting against custom resource notifications.
1016
-
1017
- ```ruby
1018
- # matchers.rb
1019
- ChefSpec.define_matcher :my_custom_resource
1020
- ```
1021
-
1022
- And then in your spec suite, you can obtain the custom resource for assertions:
1023
-
1024
- ```ruby
1025
- let(:chef_run) { ChefSpec::SoloRunner.converge('...') }
1026
-
1027
- it 'notifies the thing' do
1028
- custom = chef_run.my_custom_resource('name')
1029
- expect(custom).to notify('service[apache2]').to(:restart).immediately
1030
- end
1031
- ```
1032
-
1033
- You can use this functionality to bundle lookup matchers with cookbooks, or to provide your own when the upstream cookbook doesn't include it.
1034
-
1035
- ## Expecting Exceptions
1036
-
1037
- In Chef 11, custom formatters were introduced and ChefSpec uses a custom formatter to suppress Chef Client output. In the event of a convergence failure, ChefSpec will output the error message from the run to help you debug:
1038
-
1039
- ```text
1040
- ================================================================================
1041
- Recipe Compile Error in apt_package/recipes/install.rb
1042
- ================================================================================
1043
-
1044
- RuntimeError
1045
- ------------
1046
- RuntimeError
1047
-
1048
- Cookbook Trace:
1049
- ---------------
1050
- .../apt_package/recipes/install.rb:1:in `from_file'
1051
- .../apt_package/spec/install_spec.rb:4:in `block (2 levels) in <top (required)>'
1052
- .../apt_package/spec/install_spec.rb:7:in `block (2 levels) in <top (required)>'
1053
-
1054
- Relevant File Content:
1055
- ----------------------
1056
- .../apt_package/recipes/install.rb:
1057
-
1058
- 1>> raise RuntimeError
1059
- 2:
1060
- 3: apt_package 'default_action'
1061
- ```
1062
-
1063
- This output is automatically silenced when using RSpec's `raise_error` matcher:
1064
-
1065
- ```ruby
1066
- let(:chef_run) { ChefSpec::SoloRunner.converge('cookbook::recipe') }
1067
-
1068
- it 'raises an error' do
1069
- expect {
1070
- chef_run
1071
- }.to raise_error
1072
- end
1073
- ```
1074
-
1075
- You can also assert that a particular error was raised. If the error matches the given type, the output is suppressed. If not, the test fails and the entire stack trace is presented.
1076
-
1077
- ```ruby
1078
- let(:chef_run) { ChefSpec::SoloRunner.converge('cookbook::recipe') }
1079
-
1080
- it 'raises an error' do
1081
- expect {
1082
- chef_run
1083
- }.to raise_error(RuntimeError)
1084
- end
1085
- ```
1086
-
1087
- ## Testing Multiple Recipes
1088
-
1089
- Even though ChefSpec is cookbook-centric, you can still converge multiple recipes in a single `ChefSpec::SoloRunner` instance. Given a cookbook "sandwich" with recipes "bacon", "lettuce" and "tomato":
1090
-
1091
- ```ruby
1092
- # cookbooks/sandwich/recipes/bacon.rb
1093
- package 'bacon'
1094
-
1095
- # cookbooks/sandwich/recipes/lettuce.rb
1096
- package 'lettuce'
1097
-
1098
- # cookbooks/sandwich/recipes/tomato.rb
1099
- package 'tomato'
1100
- ```
1101
-
1102
- ```ruby
1103
- let(:chef_run) { ChefSpec::SoloRunner.converge('sandwich::bacon', 'sandwich::lettuce', 'sandwich::tomato') }
1104
- ```
1105
-
1106
- ```ruby
1107
- expect(chef_run).to install_package('bacon')
1108
- expect(chef_run).to install_package('lettuce')
1109
- expect(chef_run).to install_package('tomato')
1110
- ```
1111
-
1112
- ## Testing Roles
1113
-
1114
- Roles can also be used in a single `ChefSpec::SoloRunner` instance. Given a cookbook "bacon" with a default recipe:
1115
-
1116
- ```ruby
1117
- # cookbooks/bacon/recipes/default.rb
1118
- package 'foo'
1119
- ```
1120
-
1121
- and a default attributes file:
1122
-
1123
- ```ruby
1124
- # cookbooks/bacon/attributes/default.rb
1125
- default['bacon']['temperature'] = 200
1126
- ```
1127
-
1128
- and a role "breakfast":
1129
-
1130
- ```ruby
1131
- # roles/breakfast.rb
1132
- default_attributes(
1133
- 'bacon' => {
1134
- 'temperature' => 150 # NOTE: This is different from the default value
1135
- }
1136
- )
1137
- run_list([
1138
- 'recipe[bacon::default]'
1139
- ])
1140
- ```
1141
-
1142
- You can test that the role is appropriately applied by telling the `ChefSpec::SoloRunner` to converge on the _role_ instead of a recipe:
1143
-
1144
- ```ruby
1145
- let(:chef_run) { ChefSpec::SoloRunner.converge('role[breakfast]') }
1146
- ```
1147
-
1148
- Assert that the run_list is properly expanded:
1149
-
1150
- ```ruby
1151
- expect(chef_run).to include_recipe('bacon::default')
1152
- ```
1153
-
1154
- Assert that the correct attribute is used:
1155
-
1156
- ```ruby
1157
- expect(chef_run.node['bacon']['temperature']).to eq(150)
1158
- ```
1159
-
1160
- **NOTE** If your roles live somewhere outside of the expected path, you must set `RSpec.config.role_path` to point to the directory containing your roles **before** invoking the `#converge` method!
1161
-
1162
- ```ruby
1163
- RSpec.configure do |config|
1164
- config.role_path = '/var/my/roles' # global setting
1165
- end
1166
-
1167
- # - OR -
1168
-
1169
- ChefSpec::SoloRunner.new(role_path: '/var/my/roles') # local setting
1170
- ```
1171
-
1172
- ## Faster Specs
1173
-
1174
- ChefSpec aims to provide the easiest and simplest path for new users to write RSpec examples for Chef cookbooks. In doing so, it makes some sacrifices in terms of speed and agility of execution. In other words, ChefSpec favors "speed to develop" over "speed to execute". Many of these decisions are directly related to the way Chef dynamically loads resources at runtime.
1175
-
1176
- If you understand how RSpec works and would like to see some significant speed improvements in your specs, you can use the `ChefSpec::Cacher` module inspired by [Juri Timošin](https://github.com/DracoAter). Simply convert all your `let` blocks to `cached`:
1177
-
1178
- ```ruby
1179
- # before
1180
- let(:chef_run) { ChefSpec::SoloRunner.new }
1181
-
1182
- # after
1183
- cached(:chef_run) { ChefSpec::SoloRunner.new }
1184
- ```
1185
-
1186
- Everything else should work the same. Be advised, as the method name suggests, this will cache the results of your Chef Client Run for the **entire RSpec example**. This makes stubbing more of a challenge, since the node is already converged. For more information, please see [Juri Timošin's blog post on faster specs](http://dracoater.blogspot.com/2013/12/testing-chef-cookbooks-part-25-speeding.html) as well as the discussion in [#275](https://github.com/sethvargo/chefspec/issues/275).
1187
-
1188
- ## Media & Third-party Tutorials
1189
-
1190
- - [CustomInk's Testing Chef Cookbooks](http://technology.customink.com/blog/2012/08/03/testing-chef-cookbooks/)
1191
- - [Jake Vanderdray's Practical ChefSpec](http://files.meetup.com/1780846/ChefSpec.pdf)
1192
- - [Jim Hopp's excellent Test Driven Development for Chef Practitioners](http://www.youtube.com/watch?v=o2e0aZUAVGw)
1193
- - [Joshua Timberman's Starting ChefSpec Examples](http://jtimberman.housepub.org/blog/2013/05/09/starting-chefspec-example/)
1194
- - [Juri Timošin's post on faster specs](http://dracoater.blogspot.com/2013/12/testing-chef-cookbooks-part-25-speeding.html)
1195
- - [Seth Vargo's Chef recipe code coverage](https://sethvargo.com/chef-recipe-code-coverage/)
1196
- - [Seth Vargo's TDDing tmux talk](http://www.confreaks.com/videos/2364-mwrc2013-tdding-tmux)
1197
- - [Stephen Nelson Smith's Test-Driven Infrastructure with Chef](http://shop.oreilly.com/product/0636920030973.do)
1198
-
1199
- ## Development
1200
-
1201
- 1. Fork the repository from GitHub.
1202
- 2. Clone your fork to your local machine:
1203
-
1204
- ```
1205
- $ git clone git@github.com:USER/chefspec.git
1206
- ```
1207
-
1208
- 3. Create a git branch
1209
-
1210
- ```
1211
- $ git checkout -b my_bug_fix
1212
- ```
1213
-
1214
- 4. **Write tests**
1215
-
1216
- 5. Make your changes/patches/fixes, committing appropriately
1217
-
1218
- 6. Run the tests: `bundle exec rake`
1219
-
1220
- 7. Push your changes to GitHub
1221
-
1222
- 8. Open a Pull Request
1223
-
1224
- ChefSpec is on [Travis CI][travis] which tests against multiple Chef and Ruby versions.
1225
-
1226
- If you are contributing, please see the [Contributing Guidelines](https://github.com/sethvargo/chefspec/blob/master/CONTRIBUTING.md) for more information.
1227
-
1228
- ## License
1229
-
1230
- MIT - see the accompanying [LICENSE](https://github.com/sethvargo/chefspec/blob/master/LICENSE) file for details.