chefspec 5.0.0 → 7.0.0

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 (443) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -25
  3. data/CHANGELOG.md +506 -371
  4. data/Gemfile +9 -0
  5. data/README.md +118 -75
  6. data/chefspec.gemspec +4 -5
  7. data/examples/apt_package/recipes/purge.rb +2 -2
  8. data/examples/apt_package/recipes/reconfig.rb +2 -2
  9. data/examples/apt_package/recipes/remove.rb +2 -2
  10. data/examples/apt_package/recipes/upgrade.rb +2 -2
  11. data/examples/apt_package/spec/install_spec.rb +4 -1
  12. data/examples/apt_package/spec/purge_spec.rb +4 -1
  13. data/examples/apt_package/spec/reconfig_spec.rb +4 -1
  14. data/examples/apt_package/spec/remove_spec.rb +4 -1
  15. data/examples/apt_package/spec/upgrade_spec.rb +4 -1
  16. data/examples/apt_repository/spec/add_spec.rb +4 -1
  17. data/examples/apt_repository/spec/remove_spec.rb +4 -1
  18. data/examples/apt_update/recipes/periodic.rb +1 -1
  19. data/examples/apt_update/spec/periodic_spec.rb +5 -2
  20. data/examples/apt_update/spec/update_spec.rb +4 -1
  21. data/examples/attributes/spec/default_spec.rb +1 -1
  22. data/examples/batch/recipes/run.rb +0 -4
  23. data/examples/batch/spec/run_spec.rb +4 -10
  24. data/examples/bff_package/recipes/install.rb +13 -0
  25. data/examples/bff_package/recipes/purge.rb +13 -0
  26. data/examples/bff_package/recipes/remove.rb +13 -0
  27. data/examples/bff_package/recipes/upgrade.rb +13 -0
  28. data/examples/bff_package/spec/install_spec.rb +23 -0
  29. data/examples/bff_package/spec/purge_spec.rb +19 -0
  30. data/examples/bff_package/spec/remove_spec.rb +19 -0
  31. data/examples/bff_package/spec/upgrade_spec.rb +19 -0
  32. data/examples/cab_package/recipes/install.rb +13 -0
  33. data/examples/cab_package/recipes/remove.rb +13 -0
  34. data/examples/cab_package/spec/install_spec.rb +26 -0
  35. data/examples/cab_package/spec/remove_spec.rb +22 -0
  36. data/examples/cached/spec/default_spec.rb +1 -1
  37. data/examples/chef_gem/spec/install_spec.rb +1 -1
  38. data/examples/chef_gem/spec/purge_spec.rb +1 -1
  39. data/examples/chef_gem/spec/reconfig_spec.rb +1 -1
  40. data/examples/chef_gem/spec/remove_spec.rb +1 -1
  41. data/examples/chef_gem/spec/upgrade_spec.rb +1 -1
  42. data/examples/chocolatey_package/spec/install_spec.rb +4 -6
  43. data/examples/chocolatey_package/spec/remove_spec.rb +4 -6
  44. data/examples/chocolatey_package/spec/upgrade_spec.rb +4 -6
  45. data/examples/compile_time/spec/default_spec.rb +1 -1
  46. data/examples/cookbook_file/spec/create_if_missing_spec.rb +3 -3
  47. data/examples/cookbook_file/spec/create_spec.rb +3 -3
  48. data/examples/cookbook_file/spec/delete_spec.rb +1 -1
  49. data/examples/cookbook_file/spec/touch_spec.rb +1 -1
  50. data/examples/cron/spec/create_spec.rb +1 -1
  51. data/examples/cron/spec/delete_spec.rb +1 -1
  52. data/examples/custom_matcher/providers/thing.rb +1 -1
  53. data/examples/custom_matcher/spec/install_spec.rb +1 -1
  54. data/examples/custom_matcher/spec/remove_spec.rb +1 -1
  55. data/examples/custom_resource/libraries/matchers.rb +5 -0
  56. data/examples/custom_resource/recipes/default.rb +1 -0
  57. data/examples/custom_resource/resources/custom_resource.rb +9 -0
  58. data/examples/custom_resource/spec/default_spec.rb +18 -0
  59. data/examples/deploy/spec/deploy_spec.rb +1 -1
  60. data/examples/deploy/spec/force_deploy_spec.rb +1 -1
  61. data/examples/deploy/spec/rollback_spec.rb +1 -1
  62. data/examples/directory/spec/create_spec.rb +4 -4
  63. data/examples/directory/spec/delete_spec.rb +3 -3
  64. data/examples/dnf_package/recipes/install.rb +13 -0
  65. data/examples/dnf_package/recipes/purge.rb +13 -0
  66. data/examples/dnf_package/recipes/remove.rb +13 -0
  67. data/examples/dnf_package/recipes/upgrade.rb +13 -0
  68. data/examples/dnf_package/spec/install_spec.rb +26 -0
  69. data/examples/dnf_package/spec/purge_spec.rb +22 -0
  70. data/examples/dnf_package/spec/remove_spec.rb +22 -0
  71. data/examples/dnf_package/spec/upgrade_spec.rb +22 -0
  72. data/examples/do_nothing/spec/default_spec.rb +1 -1
  73. data/examples/dpkg_package/spec/install_spec.rb +4 -6
  74. data/examples/dpkg_package/spec/purge_spec.rb +4 -6
  75. data/examples/dpkg_package/spec/remove_spec.rb +4 -6
  76. data/examples/dsc_resource/recipes/{default.rb → run.rb} +6 -6
  77. data/examples/dsc_resource/spec/{default_spec.rb → run_spec.rb} +8 -10
  78. data/examples/dsc_script/recipes/run.rb +12 -0
  79. data/examples/dsc_script/spec/run_spec.rb +16 -0
  80. data/examples/env/spec/create_spec.rb +4 -6
  81. data/examples/env/spec/delete_spec.rb +4 -6
  82. data/examples/env/spec/modify_spec.rb +4 -6
  83. data/examples/erl_call/spec/run_spec.rb +1 -1
  84. data/examples/execute/spec/run_spec.rb +1 -1
  85. data/examples/expect_exception/spec/compile_error_spec.rb +1 -1
  86. data/examples/expect_exception/spec/converge_error_spec.rb +1 -1
  87. data/examples/expect_exception/spec/no_error_spec.rb +1 -1
  88. data/examples/file/spec/create_if_missing_spec.rb +3 -3
  89. data/examples/file/spec/create_spec.rb +3 -3
  90. data/examples/file/spec/delete_spec.rb +1 -1
  91. data/examples/file/spec/touch_spec.rb +1 -1
  92. data/examples/freebsd_package/spec/install_spec.rb +4 -1
  93. data/examples/freebsd_package/spec/remove_spec.rb +4 -1
  94. data/examples/gem_package/spec/install_spec.rb +1 -1
  95. data/examples/gem_package/spec/purge_spec.rb +1 -1
  96. data/examples/gem_package/spec/reconfig_spec.rb +1 -1
  97. data/examples/gem_package/spec/remove_spec.rb +1 -1
  98. data/examples/gem_package/spec/upgrade_spec.rb +1 -1
  99. data/examples/git/spec/checkout_spec.rb +1 -1
  100. data/examples/git/spec/export_spec.rb +1 -1
  101. data/examples/git/spec/sync_spec.rb +1 -1
  102. data/examples/group/spec/create_spec.rb +1 -1
  103. data/examples/group/spec/manage_spec.rb +1 -1
  104. data/examples/group/spec/modify_spec.rb +1 -1
  105. data/examples/group/spec/remove_spec.rb +1 -1
  106. data/examples/guards/spec/default_spec.rb +1 -1
  107. data/examples/heavy_provider_light_resource/libraries/resource_service.rb +1 -1
  108. data/examples/heavy_provider_light_resource/recipes/default.rb +1 -2
  109. data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +2 -2
  110. data/examples/homebrew_package/recipes/install.rb +13 -0
  111. data/examples/homebrew_package/recipes/purge.rb +13 -0
  112. data/examples/homebrew_package/recipes/remove.rb +13 -0
  113. data/examples/homebrew_package/recipes/upgrade.rb +13 -0
  114. data/examples/homebrew_package/spec/install_spec.rb +23 -0
  115. data/examples/homebrew_package/spec/purge_spec.rb +19 -0
  116. data/examples/homebrew_package/spec/remove_spec.rb +19 -0
  117. data/examples/homebrew_package/spec/upgrade_spec.rb +19 -0
  118. data/examples/http_request/spec/delete_spec.rb +1 -1
  119. data/examples/http_request/spec/get_spec.rb +1 -1
  120. data/examples/http_request/spec/head_spec.rb +1 -1
  121. data/examples/http_request/spec/options_spec.rb +1 -1
  122. data/examples/http_request/spec/post_spec.rb +1 -1
  123. data/examples/http_request/spec/put_spec.rb +1 -1
  124. data/examples/ifconfig/spec/add_spec.rb +1 -1
  125. data/examples/ifconfig/spec/delete_spec.rb +1 -1
  126. data/examples/ifconfig/spec/disable_spec.rb +1 -1
  127. data/examples/ifconfig/spec/enable_spec.rb +1 -1
  128. data/examples/include_recipe/spec/default_spec.rb +1 -1
  129. data/examples/ips_package/spec/install_spec.rb +4 -6
  130. data/examples/ips_package/spec/remove_spec.rb +4 -6
  131. data/examples/ips_package/spec/upgrade_spec.rb +4 -6
  132. data/examples/launchd/recipes/create.rb +5 -0
  133. data/examples/launchd/recipes/create_if_missing.rb +3 -0
  134. data/examples/launchd/recipes/delete.rb +3 -0
  135. data/examples/launchd/recipes/disable.rb +3 -0
  136. data/examples/launchd/recipes/enable.rb +3 -0
  137. data/examples/launchd/spec/create_if_missing_spec.rb +10 -0
  138. data/examples/launchd/spec/create_spec.rb +14 -0
  139. data/examples/launchd/spec/delete_spec.rb +10 -0
  140. data/examples/launchd/spec/disable_spec.rb +10 -0
  141. data/examples/launchd/spec/enable_spec.rb +10 -0
  142. data/examples/link/spec/create_spec.rb +1 -1
  143. data/examples/link/spec/delete_spec.rb +1 -1
  144. data/examples/link/spec/link_to_spec.rb +1 -1
  145. data/examples/log/spec/write_spec.rb +1 -1
  146. data/examples/macports_package/spec/install_spec.rb +1 -1
  147. data/examples/macports_package/spec/purge_spec.rb +1 -1
  148. data/examples/macports_package/spec/remove_spec.rb +1 -1
  149. data/examples/macports_package/spec/upgrade_spec.rb +1 -1
  150. data/examples/mdadm/spec/assemble_spec.rb +1 -1
  151. data/examples/mdadm/spec/create_spec.rb +1 -1
  152. data/examples/mdadm/spec/stop_spec.rb +1 -1
  153. data/examples/mount/spec/disable_spec.rb +1 -1
  154. data/examples/mount/spec/enable_spec.rb +1 -1
  155. data/examples/mount/spec/mount_spec.rb +1 -1
  156. data/examples/mount/spec/remount_spec.rb +1 -1
  157. data/examples/mount/spec/umount_spec.rb +1 -1
  158. data/examples/msu_package/recipes/install.rb +13 -0
  159. data/examples/msu_package/recipes/remove.rb +13 -0
  160. data/examples/msu_package/spec/install_spec.rb +26 -0
  161. data/examples/msu_package/spec/remove_spec.rb +22 -0
  162. data/examples/multiple_actions/recipes/reversed.rb +9 -0
  163. data/examples/multiple_actions/recipes/sequential.rb +5 -3
  164. data/examples/multiple_actions/spec/default_spec.rb +1 -1
  165. data/examples/multiple_actions/spec/reversed_spec.rb +17 -0
  166. data/examples/multiple_actions/spec/sequential_spec.rb +5 -4
  167. data/examples/multiple_run_action/recipes/default.rb +2 -2
  168. data/examples/multiple_run_action/spec/default_spec.rb +1 -1
  169. data/examples/notifications/spec/before_spec.rb +1 -1
  170. data/examples/notifications/spec/chained_spec.rb +1 -1
  171. data/examples/notifications/spec/default_spec.rb +1 -1
  172. data/examples/notifications/spec/delayed_spec.rb +1 -1
  173. data/examples/notifications/spec/immediately_spec.rb +1 -1
  174. data/examples/ohai/spec/reload_spec.rb +1 -1
  175. data/examples/openbsd_package/recipes/install.rb +13 -0
  176. data/examples/openbsd_package/recipes/purge.rb +13 -0
  177. data/examples/openbsd_package/recipes/remove.rb +13 -0
  178. data/examples/openbsd_package/recipes/upgrade.rb +13 -0
  179. data/examples/openbsd_package/spec/install_spec.rb +23 -0
  180. data/examples/openbsd_package/spec/purge_spec.rb +19 -0
  181. data/examples/openbsd_package/spec/remove_spec.rb +19 -0
  182. data/examples/openbsd_package/spec/upgrade_spec.rb +19 -0
  183. data/examples/osx_profile/recipes/install.rb +8 -0
  184. data/examples/osx_profile/recipes/remove.rb +8 -0
  185. data/examples/osx_profile/spec/install_spec.rb +15 -0
  186. data/examples/osx_profile/spec/remove_spec.rb +13 -0
  187. data/examples/package/recipes/install.rb +1 -1
  188. data/examples/package/recipes/purge.rb +1 -1
  189. data/examples/package/recipes/reconfig.rb +1 -1
  190. data/examples/package/recipes/remove.rb +1 -1
  191. data/examples/package/recipes/upgrade.rb +1 -1
  192. data/examples/package/spec/install_spec.rb +2 -2
  193. data/examples/package/spec/purge_spec.rb +2 -2
  194. data/examples/package/spec/reconfig_spec.rb +2 -2
  195. data/examples/package/spec/remove_spec.rb +2 -2
  196. data/examples/package/spec/upgrade_spec.rb +2 -2
  197. data/examples/pacman_package/spec/install_spec.rb +4 -6
  198. data/examples/pacman_package/spec/purge_spec.rb +4 -6
  199. data/examples/pacman_package/spec/remove_spec.rb +4 -6
  200. data/examples/pacman_package/spec/upgrade_spec.rb +4 -6
  201. data/examples/paludis_package/recipes/install.rb +13 -0
  202. data/examples/paludis_package/recipes/purge.rb +13 -0
  203. data/examples/paludis_package/recipes/remove.rb +13 -0
  204. data/examples/paludis_package/recipes/upgrade.rb +13 -0
  205. data/examples/paludis_package/spec/install_spec.rb +23 -0
  206. data/examples/paludis_package/spec/purge_spec.rb +19 -0
  207. data/examples/paludis_package/spec/remove_spec.rb +19 -0
  208. data/examples/paludis_package/spec/upgrade_spec.rb +19 -0
  209. data/examples/portage_package/spec/install_spec.rb +4 -1
  210. data/examples/portage_package/spec/purge_spec.rb +4 -1
  211. data/examples/portage_package/spec/remove_spec.rb +4 -1
  212. data/examples/portage_package/spec/upgrade_spec.rb +4 -1
  213. data/examples/powershell_script/recipes/run.rb +0 -4
  214. data/examples/powershell_script/spec/run_spec.rb +4 -10
  215. data/examples/reboot/spec/cancel_spec.rb +1 -2
  216. data/examples/reboot/spec/now_spec.rb +1 -2
  217. data/examples/reboot/spec/request_spec.rb +1 -2
  218. data/examples/registry_key/spec/create_if_missing_spec.rb +4 -1
  219. data/examples/registry_key/spec/create_spec.rb +4 -1
  220. data/examples/registry_key/spec/delete_key_spec.rb +4 -1
  221. data/examples/registry_key/spec/delete_spec.rb +4 -1
  222. data/examples/remote_directory/spec/create_if_missing_spec.rb +1 -1
  223. data/examples/remote_directory/spec/create_spec.rb +1 -1
  224. data/examples/remote_directory/spec/delete_spec.rb +1 -1
  225. data/examples/remote_file/spec/create_if_missing_spec.rb +1 -1
  226. data/examples/remote_file/spec/create_spec.rb +1 -1
  227. data/examples/remote_file/spec/delete_spec.rb +1 -1
  228. data/examples/remote_file/spec/touch_spec.rb +1 -1
  229. data/examples/render_file/spec/default_spec.rb +1 -1
  230. data/examples/render_file/spec/template_helpers_spec.rb +1 -1
  231. data/examples/roles/roles/role.rb +4 -4
  232. data/examples/roles/spec/default_spec.rb +1 -1
  233. data/examples/route/spec/add_spec.rb +1 -1
  234. data/examples/route/spec/delete_spec.rb +1 -1
  235. data/examples/rpm_package/spec/install_spec.rb +4 -6
  236. data/examples/rpm_package/spec/remove_spec.rb +4 -6
  237. data/examples/rpm_package/spec/upgrade_spec.rb +4 -6
  238. data/examples/ruby_block/recipes/create.rb +8 -0
  239. data/examples/ruby_block/spec/create_spec.rb +13 -0
  240. data/examples/ruby_block/spec/run_spec.rb +1 -1
  241. data/examples/script/recipes/run_bash.rb +0 -4
  242. data/examples/script/recipes/run_csh.rb +0 -4
  243. data/examples/script/recipes/run_ksh.rb +9 -0
  244. data/examples/script/recipes/run_perl.rb +0 -4
  245. data/examples/script/recipes/run_python.rb +0 -4
  246. data/examples/script/recipes/run_ruby.rb +0 -4
  247. data/examples/script/recipes/run_script.rb +0 -4
  248. data/examples/script/spec/run_bash_spec.rb +1 -5
  249. data/examples/script/spec/run_csh_spec.rb +1 -5
  250. data/examples/script/spec/run_ksh_spec.rb +19 -0
  251. data/examples/script/spec/run_perl_spec.rb +1 -5
  252. data/examples/script/spec/run_python_spec.rb +1 -5
  253. data/examples/script/spec/run_ruby_spec.rb +1 -5
  254. data/examples/script/spec/run_script_spec.rb +1 -5
  255. data/examples/server/spec/client_spec.rb +2 -2
  256. data/examples/server/spec/data_bag_spec.rb +9 -11
  257. data/examples/server/spec/environment_spec.rb +1 -1
  258. data/examples/server/spec/exotic_port_spec.rb +17 -0
  259. data/examples/server/spec/node_spec.rb +6 -6
  260. data/examples/server/spec/render_with_cached_spec.rb +1 -1
  261. data/examples/server/spec/role_spec.rb +1 -1
  262. data/examples/server/spec/search_spec.rb +2 -2
  263. data/examples/service/recipes/disable.rb +1 -1
  264. data/examples/service/recipes/enable.rb +1 -1
  265. data/examples/service/recipes/reload.rb +1 -1
  266. data/examples/service/recipes/restart.rb +1 -1
  267. data/examples/service/recipes/start.rb +1 -1
  268. data/examples/service/recipes/stop.rb +1 -1
  269. data/examples/service/spec/disable_spec.rb +1 -1
  270. data/examples/service/spec/enable_spec.rb +1 -1
  271. data/examples/service/spec/reload_spec.rb +1 -1
  272. data/examples/service/spec/restart_spec.rb +1 -1
  273. data/examples/service/spec/start_spec.rb +1 -1
  274. data/examples/service/spec/stop_spec.rb +1 -1
  275. data/examples/smartos_package/spec/install_spec.rb +4 -1
  276. data/examples/smartos_package/spec/remove_spec.rb +4 -1
  277. data/examples/smartos_package/spec/upgrade_spec.rb +4 -1
  278. data/examples/solaris_package/recipes/upgrade.rb +13 -0
  279. data/examples/solaris_package/spec/install_spec.rb +4 -1
  280. data/examples/solaris_package/spec/remove_spec.rb +4 -1
  281. data/examples/solaris_package/spec/upgrade_spec.rb +22 -0
  282. data/examples/state_attrs/providers/lwrp.rb +0 -1
  283. data/examples/state_attrs/spec/default_spec.rb +1 -1
  284. data/examples/step_into/spec/default_spec.rb +4 -4
  285. data/examples/stub_command/spec/default_spec.rb +3 -3
  286. data/examples/stub_data_bag/spec/default_spec.rb +3 -3
  287. data/examples/stub_data_bag_item/spec/default_spec.rb +5 -5
  288. data/examples/stub_search/recipes/block.rb +3 -0
  289. data/examples/stub_search/recipes/default.rb +2 -5
  290. data/examples/stub_search/spec/block_spec.rb +27 -0
  291. data/examples/stub_search/spec/default_spec.rb +5 -5
  292. data/examples/subscribes/spec/before_spec.rb +1 -1
  293. data/examples/subscribes/spec/chained_spec.rb +1 -1
  294. data/examples/subscribes/spec/default_spec.rb +1 -2
  295. data/examples/subscribes/spec/delayed_spec.rb +1 -1
  296. data/examples/subscribes/spec/immediately_spec.rb +1 -1
  297. data/examples/subversion/spec/checkout_spec.rb +1 -1
  298. data/examples/subversion/spec/export_spec.rb +1 -1
  299. data/examples/subversion/spec/force_export_spec.rb +1 -1
  300. data/examples/subversion/spec/sync_spec.rb +1 -1
  301. data/examples/systemd_unit/recipes/create.rb +3 -0
  302. data/examples/systemd_unit/recipes/delete.rb +3 -0
  303. data/examples/systemd_unit/recipes/disable.rb +3 -0
  304. data/examples/systemd_unit/recipes/enable.rb +3 -0
  305. data/examples/systemd_unit/recipes/mask.rb +3 -0
  306. data/examples/systemd_unit/recipes/reload_or_restart.rb +3 -0
  307. data/examples/systemd_unit/recipes/reload_or_try_restart.rb +3 -0
  308. data/examples/systemd_unit/recipes/restart.rb +3 -0
  309. data/examples/systemd_unit/recipes/start.rb +3 -0
  310. data/examples/systemd_unit/recipes/stop.rb +3 -0
  311. data/examples/systemd_unit/recipes/try_restart.rb +3 -0
  312. data/examples/systemd_unit/recipes/unmask.rb +3 -0
  313. data/examples/systemd_unit/spec/create_spec.rb +10 -0
  314. data/examples/systemd_unit/spec/delete_spec.rb +10 -0
  315. data/examples/systemd_unit/spec/disable_spec.rb +10 -0
  316. data/examples/systemd_unit/spec/enable_spec.rb +10 -0
  317. data/examples/systemd_unit/spec/mask_spec.rb +10 -0
  318. data/examples/systemd_unit/spec/reload_or_restart_spec.rb +10 -0
  319. data/examples/systemd_unit/spec/reload_or_try_restart_spec.rb +10 -0
  320. data/examples/systemd_unit/spec/restart_spec.rb +10 -0
  321. data/examples/systemd_unit/spec/start_spec.rb +10 -0
  322. data/examples/systemd_unit/spec/stop_spec.rb +10 -0
  323. data/examples/systemd_unit/spec/try_restart_spec.rb +10 -0
  324. data/examples/systemd_unit/spec/unmask_spec.rb +10 -0
  325. data/examples/template/spec/create_if_missing_spec.rb +3 -3
  326. data/examples/template/spec/create_spec.rb +3 -3
  327. data/examples/template/spec/delete_spec.rb +1 -1
  328. data/examples/template/spec/touch_spec.rb +1 -1
  329. data/examples/use_inline_resources/spec/default_spec.rb +3 -3
  330. data/examples/user/spec/create_spec.rb +4 -1
  331. data/examples/user/spec/lock_spec.rb +4 -1
  332. data/examples/user/spec/manage_spec.rb +4 -1
  333. data/examples/user/spec/modify_spec.rb +4 -1
  334. data/examples/user/spec/remove_spec.rb +4 -1
  335. data/examples/user/spec/unlock_spec.rb +4 -1
  336. data/examples/windows_package/spec/install_spec.rb +4 -6
  337. data/examples/windows_package/spec/remove_spec.rb +4 -6
  338. data/examples/windows_service/spec/configure_startup_spec.rb +4 -6
  339. data/examples/windows_service/spec/disable_spec.rb +4 -6
  340. data/examples/windows_service/spec/enable_spec.rb +4 -6
  341. data/examples/windows_service/spec/reload_spec.rb +4 -6
  342. data/examples/windows_service/spec/restart_spec.rb +4 -6
  343. data/examples/windows_service/spec/start_spec.rb +4 -6
  344. data/examples/windows_service/spec/stop_spec.rb +4 -6
  345. data/examples/yum_package/spec/install_spec.rb +4 -1
  346. data/examples/yum_package/spec/purge_spec.rb +4 -1
  347. data/examples/yum_package/spec/remove_spec.rb +4 -1
  348. data/examples/yum_package/spec/upgrade_spec.rb +4 -1
  349. data/examples/yum_repository/recipes/add.rb +8 -0
  350. data/examples/yum_repository/recipes/create.rb +8 -0
  351. data/examples/yum_repository/recipes/delete.rb +3 -0
  352. data/examples/yum_repository/recipes/makecache.rb +3 -0
  353. data/examples/yum_repository/recipes/remove.rb +7 -0
  354. data/examples/yum_repository/spec/add_spec.rb +12 -0
  355. data/examples/yum_repository/spec/create_spec.rb +17 -0
  356. data/examples/yum_repository/spec/delete_spec.rb +12 -0
  357. data/examples/yum_repository/spec/makecache_spec.rb +12 -0
  358. data/examples/yum_repository/spec/remove_spec.rb +12 -0
  359. data/examples/zypper_package/recipes/install.rb +13 -0
  360. data/examples/zypper_package/recipes/purge.rb +13 -0
  361. data/examples/zypper_package/recipes/remove.rb +13 -0
  362. data/examples/zypper_package/recipes/upgrade.rb +13 -0
  363. data/examples/zypper_package/spec/install_spec.rb +23 -0
  364. data/examples/zypper_package/spec/purge_spec.rb +19 -0
  365. data/examples/zypper_package/spec/remove_spec.rb +19 -0
  366. data/examples/zypper_package/spec/upgrade_spec.rb +19 -0
  367. data/features/apt_repository.feature +15 -0
  368. data/features/apt_update.feature +13 -0
  369. data/features/attributes.feature +1 -1
  370. data/features/bff_package.feature +12 -0
  371. data/features/cab_package.feature +21 -0
  372. data/features/chocolatey_package.feature +1 -6
  373. data/features/compile_time.feature +1 -1
  374. data/features/custom_resource.feature +7 -0
  375. data/features/dnf_package.feature +26 -0
  376. data/features/dsc_resource.feature +5 -4
  377. data/features/dsc_script.feature +10 -0
  378. data/features/exotic_zero_port.feature +7 -0
  379. data/features/homebrew_package.feature +12 -0
  380. data/features/launchd.feature +17 -0
  381. data/features/msu_package.feature +23 -0
  382. data/features/multiple_actions.feature +1 -0
  383. data/features/notifications.feature +0 -7
  384. data/features/openbsd_package.feature +12 -0
  385. data/features/osx_profile.feature +13 -0
  386. data/features/paludis_package.feature +12 -0
  387. data/features/roles.feature +1 -1
  388. data/features/ruby_block.feature +1 -0
  389. data/features/script.feature +1 -0
  390. data/features/server_on_disk.feature +16 -0
  391. data/features/solaris_package.feature +1 -0
  392. data/features/stub_search.feature +1 -1
  393. data/features/subscribes.feature +0 -7
  394. data/features/support/env.rb +8 -0
  395. data/features/support/exotic_zero_port.rb +3 -0
  396. data/features/support/on_disk.rb +7 -0
  397. data/features/systemd_unit.feature +27 -0
  398. data/features/windows_package.feature +0 -4
  399. data/features/yum_repository.feature +23 -0
  400. data/features/{easy_install_package.feature → zypper_package.feature} +2 -2
  401. data/lib/chefspec/api/bff_package.rb +154 -0
  402. data/lib/chefspec/api/cab_package.rb +80 -0
  403. data/lib/chefspec/api/dnf_package.rb +154 -0
  404. data/lib/chefspec/api/dsc_script.rb +37 -0
  405. data/lib/chefspec/api/homebrew_package.rb +154 -0
  406. data/lib/chefspec/api/launchd.rb +151 -0
  407. data/lib/chefspec/api/msu_package.rb +81 -0
  408. data/lib/chefspec/api/openbsd_package.rb +155 -0
  409. data/lib/chefspec/api/osx_profile.rb +63 -0
  410. data/lib/chefspec/api/paludis_package.rb +155 -0
  411. data/lib/chefspec/api/ruby_block.rb +31 -0
  412. data/lib/chefspec/api/script.rb +39 -0
  413. data/lib/chefspec/api/solaris_package.rb +37 -0
  414. data/lib/chefspec/api/systemd_unit.rb +353 -0
  415. data/lib/chefspec/api/yum_repository.rb +130 -0
  416. data/lib/chefspec/api/zypper_package.rb +154 -0
  417. data/lib/chefspec/api.rb +15 -0
  418. data/lib/chefspec/coverage.rb +25 -7
  419. data/lib/chefspec/extensions/chef/data_query.rb +6 -1
  420. data/lib/chefspec/extensions/chef/lwrp_base.rb +21 -35
  421. data/lib/chefspec/macros.rb +1 -1
  422. data/lib/chefspec/matchers/resource_matcher.rb +20 -27
  423. data/lib/chefspec/rspec.rb +3 -0
  424. data/lib/chefspec/server_methods.rb +9 -12
  425. data/lib/chefspec/server_runner.rb +2 -42
  426. data/lib/chefspec/solo_runner.rb +11 -10
  427. data/lib/chefspec/version.rb +1 -1
  428. data/lib/chefspec/zero_server.rb +140 -0
  429. data/lib/chefspec.rb +0 -1
  430. data/spec/unit/macros_spec.rb +2 -2
  431. data/spec/unit/solo_runner_spec.rb +3 -2
  432. data/templates/errors/may_need_to_specify_platform.erb +1 -1
  433. metadata +195 -26
  434. data/examples/easy_install_package/recipes/install.rb +0 -13
  435. data/examples/easy_install_package/recipes/purge.rb +0 -13
  436. data/examples/easy_install_package/recipes/remove.rb +0 -13
  437. data/examples/easy_install_package/recipes/upgrade.rb +0 -13
  438. data/examples/easy_install_package/spec/install_spec.rb +0 -23
  439. data/examples/easy_install_package/spec/purge_spec.rb +0 -19
  440. data/examples/easy_install_package/spec/remove_spec.rb +0 -19
  441. data/examples/easy_install_package/spec/upgrade_spec.rb +0 -19
  442. data/gemfiles/chefspec.gemfile +0 -15
  443. data/lib/chefspec/chef_backwards_compat.rb +0 -79
@@ -8,3 +8,4 @@ Feature: The ruby_block matcher
8
8
  Examples:
9
9
  | Matcher |
10
10
  | run |
11
+ | create |
@@ -11,5 +11,6 @@ Feature: The script matcher
11
11
  | run_csh |
12
12
  | run_perl |
13
13
  | run_python |
14
+ | run_ksh |
14
15
  | run_ruby |
15
16
  | run_script |
@@ -0,0 +1,16 @@
1
+ Feature: The ChefSpec server with on-disk storage
2
+ Background:
3
+ * I am using the "server" cookbook
4
+
5
+ Scenario Outline: Running specs
6
+ * I successfully run `rspec spec/<Component>_spec.rb --require ../../../features/support/on_disk.rb`
7
+ * the output should contain "0 failures"
8
+ Examples:
9
+ | Component |
10
+ | client |
11
+ | data_bag |
12
+ | environment |
13
+ | node |
14
+ | render_with_cached |
15
+ | role |
16
+ | search |
@@ -9,3 +9,4 @@ Feature: The solaris_package matcher
9
9
  | Matcher |
10
10
  | install |
11
11
  | remove |
12
+ | upgrade |
@@ -3,5 +3,5 @@ Feature: The stub_search matcher
3
3
  * I am using the "stub_search" cookbook
4
4
 
5
5
  Scenario: Running specs
6
- * I successfully run `rspec spec/default_spec.rb`
6
+ * I successfully run `rspec spec/default_spec.rb spec/block_spec.rb`
7
7
  * the output should contain "0 failures"
@@ -1,10 +1,3 @@
1
- @not_chef_12_0_3
2
- @not_chef_12_1_2
3
- @not_chef_12_2_1
4
- @not_chef_12_3_0
5
- @not_chef_12_4_3
6
- @not_chef_12_5_1
7
-
8
1
  Feature: The subscribes matcher
9
2
  Background:
10
3
  * I am using the "subscribes" cookbook
@@ -20,6 +20,14 @@ Before do
20
20
  # RSpec::Runner) removes our configurations :(
21
21
  load 'lib/chefspec/rspec.rb'
22
22
 
23
+ # These settings need to be specified manually here rather than in rspec.rb
24
+ # because we do not want the zero-server terminating between each run. The
25
+ # runs happen too quickly in succession the port doesn't have time to get reset.
26
+ RSpec.configure do |config|
27
+ config.before(:suite) { ChefSpec::ZeroServer.setup! }
28
+ config.after(:each) { ChefSpec::ZeroServer.reset! }
29
+ end
30
+
23
31
  # Use a temporary directory to suppress Travis warnings
24
32
  @dirs = [Dir.mktmpdir]
25
33
  end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.server_runner_port = (8900..8910)
3
+ end
@@ -0,0 +1,7 @@
1
+ # We need to add this setting because for the first test, we haven't had a chance
2
+ # to load the chefspec rspec.rb file, so the first test will fail if we simply
3
+ # try to set it like we would otherwise.
4
+
5
+ RSpec.configure do |config|
6
+ config.add_setting :server_runner_data_store, default: :on_disk
7
+ end
@@ -0,0 +1,27 @@
1
+ @not_chef_12_6_0
2
+ @not_chef_12_7_2
3
+ @not_chef_12_8_1
4
+ @not_chef_12_9_41
5
+ @not_chef_12_10_24
6
+
7
+ Feature: The systemd_unit matcher
8
+ Background:
9
+ * I am using the "systemd_unit" cookbook
10
+
11
+ Scenario Outline: Running specs
12
+ * I successfully run `rspec spec/<Matcher>_spec.rb`
13
+ * the output should contain "0 failures"
14
+ Examples:
15
+ | Matcher |
16
+ | create |
17
+ | delete |
18
+ | enable |
19
+ | disable |
20
+ | mask |
21
+ | unmask |
22
+ | start |
23
+ | stop |
24
+ | restart |
25
+ | try_restart |
26
+ | reload_or_restart |
27
+ | reload_or_try_restart |
@@ -1,7 +1,3 @@
1
- @not_chef_12_0_3
2
- @not_chef_12_1_2
3
- @not_chef_12_2_1
4
- @not_chef_12_3_0
5
1
  Feature: The windows_package matcher
6
2
  Background:
7
3
  * I am using the "windows_package" cookbook
@@ -0,0 +1,23 @@
1
+ @not_chef_12_6_0
2
+ @not_chef_12_7_2
3
+ @not_chef_12_8_1
4
+ @not_chef_12_9_41
5
+ @not_chef_12_10_24
6
+ @not_chef_12_11_18
7
+ @not_chef_12_12_15
8
+ @not_chef_12_13_37
9
+
10
+ Feature: The yum_repository matcher
11
+ Background:
12
+ * I am using the "yum_repository" cookbook
13
+
14
+ Scenario Outline: Running specs
15
+ * I successfully run `rspec spec/<Matcher>_spec.rb`
16
+ * the output should contain "0 failures"
17
+ Examples:
18
+ | Matcher |
19
+ | create |
20
+ | delete |
21
+ | add |
22
+ | remove |
23
+ | makecache |
@@ -1,6 +1,6 @@
1
- Feature: The easy_install_package matcher
1
+ Feature: The zypper_package matcher
2
2
  Background:
3
- * I am using the "easy_install_package" cookbook
3
+ * I am using the "zypper_package" cookbook
4
4
 
5
5
  Scenario Outline: Running specs
6
6
  * I successfully run `rspec spec/<Matcher>_spec.rb`
@@ -0,0 +1,154 @@
1
+ module ChefSpec::API
2
+ # @since 5.1.0
3
+ module BffPackageMatchers
4
+ ChefSpec.define_matcher :bff_package
5
+
6
+ #
7
+ # Assert that a +bff_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +bff_package+:
10
+ #
11
+ # bff_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +bff_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +bff_package+ was installed
19
+ # expect(chef_run).to install_bff_package('apache2')
20
+ #
21
+ # @example Assert that a +bff_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_bff_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +bff_package+ was installed with attributes
25
+ # expect(chef_run).to install_bff_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +bff_package+ was installed using a regex
28
+ # expect(chef_run).to install_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +bff_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_bff_package('apache2')
32
+ #
33
+ #
34
+ # @param [String, Regex] resource_name
35
+ # the name of the resource to match
36
+ #
37
+ # @return [ChefSpec::Matchers::ResourceMatcher]
38
+ #
39
+ def install_bff_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +bff_package+ resource exists in the Chef run with the
45
+ # action +:purge+. Given a Chef Recipe that purges "apache2" as a
46
+ # +bff_package+:
47
+ #
48
+ # bff_package 'apache2' do
49
+ # action :purge
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +bff_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +bff_package+ was purged
56
+ # expect(chef_run).to purge_bff_package('apache2')
57
+ #
58
+ # @example Assert that a +bff_package+ was purged with predicate matchers
59
+ # expect(chef_run).to purge_bff_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +bff_package+ was purged with attributes
62
+ # expect(chef_run).to purge_bff_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +bff_package+ was purged using a regex
65
+ # expect(chef_run).to purge_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +bff_package+ was _not_ purged
68
+ # expect(chef_run).to_not purge_bff_package('apache2')
69
+ #
70
+ #
71
+ # @param [String, Regex] resource_name
72
+ # the name of the resource to match
73
+ #
74
+ # @return [ChefSpec::Matchers::ResourceMatcher]
75
+ #
76
+ def purge_bff_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :purge, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +bff_package+ resource exists in the Chef run with the
82
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
83
+ # +bff_package+:
84
+ #
85
+ # bff_package 'apache2' do
86
+ # action :remove
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +bff_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +bff_package+ was removed
93
+ # expect(chef_run).to remove_bff_package('apache2')
94
+ #
95
+ # @example Assert that a +bff_package+ was removed with predicate matchers
96
+ # expect(chef_run).to remove_bff_package('apache2').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +bff_package+ was removed with attributes
99
+ # expect(chef_run).to remove_bff_package('apache2').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +bff_package+ was removed using a regex
102
+ # expect(chef_run).to remove_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +bff_package+ was _not_ removed
105
+ # expect(chef_run).to_not remove_bff_package('apache2')
106
+ #
107
+ #
108
+ # @param [String, Regex] resource_name
109
+ # the name of the resource to match
110
+ #
111
+ # @return [ChefSpec::Matchers::ResourceMatcher]
112
+ #
113
+ def remove_bff_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :remove, resource_name)
115
+ end
116
+
117
+ #
118
+ # Assert that a +bff_package+ resource exists in the Chef run with the
119
+ # action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as a
120
+ # +bff_package+:
121
+ #
122
+ # bff_package 'apache2' do
123
+ # action :upgrade
124
+ # end
125
+ #
126
+ # The Examples section demonstrates the different ways to test a
127
+ # +bff_package+ resource with ChefSpec.
128
+ #
129
+ # @example Assert that a +bff_package+ was upgraded
130
+ # expect(chef_run).to upgrade_bff_package('apache2')
131
+ #
132
+ # @example Assert that a +bff_package+ was upgraded with predicate matchers
133
+ # expect(chef_run).to upgrade_bff_package('apache2').with_version('1.2.3')
134
+ #
135
+ # @example Assert that a +bff_package+ was upgraded with attributes
136
+ # expect(chef_run).to upgrade_bff_package('apache2').with(version: '1.2.3')
137
+ #
138
+ # @example Assert that a +bff_package+ was upgraded using a regex
139
+ # expect(chef_run).to upgrade_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
140
+ #
141
+ # @example Assert that a +bff_package+ was _not_ upgraded
142
+ # expect(chef_run).to_not upgrade_bff_package('apache2')
143
+ #
144
+ #
145
+ # @param [String, Regex] resource_name
146
+ # the name of the resource to match
147
+ #
148
+ # @return [ChefSpec::Matchers::ResourceMatcher]
149
+ #
150
+ def upgrade_bff_package(resource_name)
151
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :upgrade, resource_name)
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,80 @@
1
+ module ChefSpec::API
2
+ # @since 6.0.0
3
+ module CabPackageMatchers
4
+ ChefSpec.define_matcher :cab_package
5
+
6
+ #
7
+ # Assert that a +cab_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +cab_package+:
10
+ #
11
+ # cab_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +cab_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +cab_package+ was installed
19
+ # expect(chef_run).to install_cab_package('apache2')
20
+ #
21
+ # @example Assert that a +cab_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_cab_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +cab_package+ was installed with attributes
25
+ # expect(chef_run).to install_cab_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +cab_package+ was installed using a regex
28
+ # expect(chef_run).to install_cab_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +cab_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_cab_package('apache2')
32
+ #
33
+ #
34
+ # @param [String, Regex] resource_name
35
+ # the name of the resource to match
36
+ #
37
+ # @return [ChefSpec::Matchers::ResourceMatcher]
38
+ #
39
+ def install_cab_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:cab_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +cab_package+ resource exists in the Chef run with the
45
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
46
+ # +cab_package+:
47
+ #
48
+ # cab_package 'apache2' do
49
+ # action :remove
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +cab_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +cab_package+ was removed
56
+ # expect(chef_run).to remove_cab_package('apache2')
57
+ #
58
+ # @example Assert that a +cab_package+ was removed with predicate matchers
59
+ # expect(chef_run).to remove_cab_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +cab_package+ was removed with attributes
62
+ # expect(chef_run).to remove_cab_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +cab_package+ was removed using a regex
65
+ # expect(chef_run).to remove_cab_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +cab_package+ was _not_ removed
68
+ # expect(chef_run).to_not remove_cab_package('apache2')
69
+ #
70
+ #
71
+ # @param [String, Regex] resource_name
72
+ # the name of the resource to match
73
+ #
74
+ # @return [ChefSpec::Matchers::ResourceMatcher]
75
+ #
76
+ def remove_cab_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:cab_package, :remove, resource_name)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,154 @@
1
+ module ChefSpec::API
2
+ # @since 6.0.0
3
+ module DnfPackageMatchers
4
+ ChefSpec.define_matcher :dnf_package
5
+
6
+ #
7
+ # Assert that a +dnf_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +dnf_package+:
10
+ #
11
+ # dnf_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +dnf_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +dnf_package+ was installed
19
+ # expect(chef_run).to install_dnf_package('apache2')
20
+ #
21
+ # @example Assert that a +dnf_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_dnf_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +dnf_package+ was installed with attributes
25
+ # expect(chef_run).to install_dnf_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +dnf_package+ was installed using a regex
28
+ # expect(chef_run).to install_dnf_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +dnf_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_dnf_package('apache2')
32
+ #
33
+ #
34
+ # @param [String, Regex] resource_name
35
+ # the name of the resource to match
36
+ #
37
+ # @return [ChefSpec::Matchers::ResourceMatcher]
38
+ #
39
+ def install_dnf_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:dnf_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +dnf_package+ resource exists in the Chef run with the
45
+ # action +:purge+. Given a Chef Recipe that purges "apache2" as a
46
+ # +dnf_package+:
47
+ #
48
+ # dnf_package 'apache2' do
49
+ # action :purge
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +dnf_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +dnf_package+ was purged
56
+ # expect(chef_run).to purge_dnf_package('apache2')
57
+ #
58
+ # @example Assert that a +dnf_package+ was purged with predicate matchers
59
+ # expect(chef_run).to purge_dnf_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +dnf_package+ was purged with attributes
62
+ # expect(chef_run).to purge_dnf_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +dnf_package+ was purged using a regex
65
+ # expect(chef_run).to purge_dnf_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +dnf_package+ was _not_ purged
68
+ # expect(chef_run).to_not purge_dnf_package('apache2')
69
+ #
70
+ #
71
+ # @param [String, Regex] resource_name
72
+ # the name of the resource to match
73
+ #
74
+ # @return [ChefSpec::Matchers::ResourceMatcher]
75
+ #
76
+ def purge_dnf_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:dnf_package, :purge, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +dnf_package+ resource exists in the Chef run with the
82
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
83
+ # +dnf_package+:
84
+ #
85
+ # dnf_package 'apache2' do
86
+ # action :remove
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +dnf_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +dnf_package+ was removed
93
+ # expect(chef_run).to remove_dnf_package('apache2')
94
+ #
95
+ # @example Assert that a +dnf_package+ was removed with predicate matchers
96
+ # expect(chef_run).to remove_dnf_package('apache2').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +dnf_package+ was removed with attributes
99
+ # expect(chef_run).to remove_dnf_package('apache2').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +dnf_package+ was removed using a regex
102
+ # expect(chef_run).to remove_dnf_package('apache2').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +dnf_package+ was _not_ removed
105
+ # expect(chef_run).to_not remove_dnf_package('apache2')
106
+ #
107
+ #
108
+ # @param [String, Regex] resource_name
109
+ # the name of the resource to match
110
+ #
111
+ # @return [ChefSpec::Matchers::ResourceMatcher]
112
+ #
113
+ def remove_dnf_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:dnf_package, :remove, resource_name)
115
+ end
116
+
117
+ #
118
+ # Assert that a +dnf_package+ resource exists in the Chef run with the
119
+ # action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as a
120
+ # +dnf_package+:
121
+ #
122
+ # dnf_package 'apache2' do
123
+ # action :upgrade
124
+ # end
125
+ #
126
+ # The Examples section demonstrates the different ways to test a
127
+ # +dnf_package+ resource with ChefSpec.
128
+ #
129
+ # @example Assert that a +dnf_package+ was upgraded
130
+ # expect(chef_run).to upgrade_dnf_package('apache2')
131
+ #
132
+ # @example Assert that a +dnf_package+ was upgraded with predicate matchers
133
+ # expect(chef_run).to upgrade_dnf_package('apache2').with_version('1.2.3')
134
+ #
135
+ # @example Assert that a +dnf_package+ was upgraded with attributes
136
+ # expect(chef_run).to upgrade_dnf_package('apache2').with(version: '1.2.3')
137
+ #
138
+ # @example Assert that a +dnf_package+ was upgraded using a regex
139
+ # expect(chef_run).to upgrade_dnf_package('apache2').with(version: /(\d+\.){2}\.\d+/)
140
+ #
141
+ # @example Assert that a +dnf_package+ was _not_ upgraded
142
+ # expect(chef_run).to_not upgrade_dnf_package('apache2')
143
+ #
144
+ #
145
+ # @param [String, Regex] resource_name
146
+ # the name of the resource to match
147
+ #
148
+ # @return [ChefSpec::Matchers::ResourceMatcher]
149
+ #
150
+ def upgrade_dnf_package(resource_name)
151
+ ChefSpec::Matchers::ResourceMatcher.new(:dnf_package, :upgrade, resource_name)
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,37 @@
1
+ module ChefSpec::API
2
+ # @since 5.1.0
3
+ module DscScriptMatchers
4
+ ChefSpec.define_matcher :dsc_script
5
+
6
+ #
7
+ # Assert that a +dsc_script+ resource exists in the Chef run with
8
+ # the action +:run+. Given a Chef Recipe that runs "something" using
9
+ # +dsc_script+:
10
+ #
11
+ # dsc_script 'something' do
12
+ # code <<-EOH
13
+ # something
14
+ # EOH
15
+ # action :run
16
+ # end
17
+ #
18
+ # The Examples section demonstrates the different ways to test a
19
+ # +dsc_script+ resource with ChefSpec.
20
+ #
21
+ # @example Assert that a +dsc_script+ was run
22
+ # expect(chef_run).to dsc_script('something')
23
+ #
24
+ # @example Assert that a +dsc_script+ was _not_ run
25
+ # expect(chef_run).to_not dsc_script('something')
26
+ #
27
+ #
28
+ # @param [String, Regex] resource_name
29
+ # the name of the resource to match
30
+ #
31
+ # @return [ChefSpec::Matchers::ResourceMatcher]
32
+ #
33
+ def run_dsc_script(resource_name)
34
+ ChefSpec::Matchers::ResourceMatcher.new(:dsc_script, :run, resource_name)
35
+ end
36
+ end
37
+ end