chefspec 4.0.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +84 -87
  5. data/chefspec.gemspec +1 -1
  6. data/examples/apt_package/spec/install_spec.rb +1 -1
  7. data/examples/apt_package/spec/purge_spec.rb +1 -1
  8. data/examples/apt_package/spec/reconfig_spec.rb +1 -1
  9. data/examples/apt_package/spec/remove_spec.rb +1 -1
  10. data/examples/apt_package/spec/upgrade_spec.rb +1 -1
  11. data/examples/attributes/spec/default_spec.rb +1 -1
  12. data/examples/batch/spec/run_spec.rb +1 -1
  13. data/examples/cached/spec/default_spec.rb +1 -1
  14. data/examples/chef_gem/spec/install_spec.rb +1 -1
  15. data/examples/chef_gem/spec/purge_spec.rb +1 -1
  16. data/examples/chef_gem/spec/reconfig_spec.rb +1 -1
  17. data/examples/chef_gem/spec/remove_spec.rb +1 -1
  18. data/examples/chef_gem/spec/upgrade_spec.rb +1 -1
  19. data/examples/compile_time/spec/default_spec.rb +1 -1
  20. data/examples/cookbook_file/spec/create_if_missing_spec.rb +1 -1
  21. data/examples/cookbook_file/spec/create_spec.rb +1 -1
  22. data/examples/cookbook_file/spec/delete_spec.rb +1 -1
  23. data/examples/cookbook_file/spec/touch_spec.rb +1 -1
  24. data/examples/cron/spec/create_spec.rb +1 -1
  25. data/examples/cron/spec/delete_spec.rb +1 -1
  26. data/examples/custom_matcher/libraries/matcher.rb +1 -1
  27. data/examples/custom_matcher/spec/install_spec.rb +1 -1
  28. data/examples/custom_matcher/spec/remove_spec.rb +1 -1
  29. data/examples/deploy/spec/deploy_spec.rb +1 -1
  30. data/examples/deploy/spec/force_deploy_spec.rb +1 -1
  31. data/examples/deploy/spec/rollback_spec.rb +1 -1
  32. data/examples/directory/spec/create_spec.rb +1 -1
  33. data/examples/directory/spec/delete_spec.rb +1 -1
  34. data/examples/do_nothing/spec/default_spec.rb +1 -1
  35. data/examples/dpkg_package/spec/install_spec.rb +1 -1
  36. data/examples/dpkg_package/spec/purge_spec.rb +1 -1
  37. data/examples/dpkg_package/spec/remove_spec.rb +1 -1
  38. data/examples/easy_install_package/spec/install_spec.rb +1 -1
  39. data/examples/easy_install_package/spec/purge_spec.rb +1 -1
  40. data/examples/easy_install_package/spec/remove_spec.rb +1 -1
  41. data/examples/easy_install_package/spec/upgrade_spec.rb +1 -1
  42. data/examples/env/spec/create_spec.rb +1 -1
  43. data/examples/env/spec/delete_spec.rb +1 -1
  44. data/examples/env/spec/modify_spec.rb +1 -1
  45. data/examples/erl_call/spec/run_spec.rb +1 -1
  46. data/examples/execute/spec/run_spec.rb +1 -1
  47. data/examples/expect_exception/spec/compile_error_spec.rb +1 -1
  48. data/examples/expect_exception/spec/converge_error_spec.rb +1 -1
  49. data/examples/expect_exception/spec/no_error_spec.rb +1 -1
  50. data/examples/file/spec/create_if_missing_spec.rb +1 -1
  51. data/examples/file/spec/create_spec.rb +1 -1
  52. data/examples/file/spec/delete_spec.rb +1 -1
  53. data/examples/file/spec/touch_spec.rb +1 -1
  54. data/examples/freebsd_package/spec/install_spec.rb +1 -1
  55. data/examples/freebsd_package/spec/remove_spec.rb +1 -1
  56. data/examples/gem_package/spec/install_spec.rb +1 -1
  57. data/examples/gem_package/spec/purge_spec.rb +1 -1
  58. data/examples/gem_package/spec/reconfig_spec.rb +1 -1
  59. data/examples/gem_package/spec/remove_spec.rb +1 -1
  60. data/examples/gem_package/spec/upgrade_spec.rb +1 -1
  61. data/examples/git/spec/checkout_spec.rb +1 -1
  62. data/examples/git/spec/export_spec.rb +1 -1
  63. data/examples/git/spec/sync_spec.rb +1 -1
  64. data/examples/group/spec/create_spec.rb +1 -1
  65. data/examples/group/spec/manage_spec.rb +1 -1
  66. data/examples/group/spec/modify_spec.rb +1 -1
  67. data/examples/group/spec/remove_spec.rb +1 -1
  68. data/examples/guards/spec/default_spec.rb +1 -1
  69. data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -1
  70. data/examples/http_request/spec/delete_spec.rb +1 -1
  71. data/examples/http_request/spec/get_spec.rb +1 -1
  72. data/examples/http_request/spec/head_spec.rb +1 -1
  73. data/examples/http_request/spec/options_spec.rb +1 -1
  74. data/examples/http_request/spec/post_spec.rb +1 -1
  75. data/examples/http_request/spec/put_spec.rb +1 -1
  76. data/examples/ifconfig/spec/add_spec.rb +1 -1
  77. data/examples/ifconfig/spec/delete_spec.rb +1 -1
  78. data/examples/ifconfig/spec/disable_spec.rb +1 -1
  79. data/examples/ifconfig/spec/enable_spec.rb +1 -1
  80. data/examples/include_recipe/spec/default_spec.rb +1 -1
  81. data/examples/inherits/spec/default_spec.rb +1 -1
  82. data/examples/ips_package/spec/install_spec.rb +1 -1
  83. data/examples/ips_package/spec/remove_spec.rb +1 -1
  84. data/examples/ips_package/spec/upgrade_spec.rb +1 -1
  85. data/examples/link/spec/create_spec.rb +1 -1
  86. data/examples/link/spec/delete_spec.rb +1 -1
  87. data/examples/link/spec/link_to_spec.rb +1 -1
  88. data/examples/log/spec/write_spec.rb +1 -1
  89. data/examples/macports_package/spec/install_spec.rb +1 -1
  90. data/examples/macports_package/spec/purge_spec.rb +1 -1
  91. data/examples/macports_package/spec/remove_spec.rb +1 -1
  92. data/examples/macports_package/spec/upgrade_spec.rb +1 -1
  93. data/examples/mdadm/spec/assemble_spec.rb +1 -1
  94. data/examples/mdadm/spec/create_spec.rb +1 -1
  95. data/examples/mdadm/spec/stop_spec.rb +1 -1
  96. data/examples/mount/spec/disable_spec.rb +1 -1
  97. data/examples/mount/spec/enable_spec.rb +1 -1
  98. data/examples/mount/spec/mount_spec.rb +1 -1
  99. data/examples/mount/spec/remount_spec.rb +1 -1
  100. data/examples/mount/spec/umount_spec.rb +1 -1
  101. data/examples/multiple_actions/spec/default_spec.rb +1 -1
  102. data/examples/multiple_actions/spec/sequential_spec.rb +4 -1
  103. data/examples/multiple_run_action/spec/default_spec.rb +1 -1
  104. data/examples/notifications/spec/chained_spec.rb +1 -1
  105. data/examples/notifications/spec/default_spec.rb +1 -1
  106. data/examples/notifications/spec/delayed_spec.rb +1 -1
  107. data/examples/notifications/spec/immediately_spec.rb +1 -1
  108. data/examples/ohai/spec/reload_spec.rb +1 -1
  109. data/examples/package/spec/install_spec.rb +1 -1
  110. data/examples/package/spec/purge_spec.rb +1 -1
  111. data/examples/package/spec/reconfig_spec.rb +1 -1
  112. data/examples/package/spec/remove_spec.rb +1 -1
  113. data/examples/package/spec/upgrade_spec.rb +1 -1
  114. data/examples/pacman_package/spec/install_spec.rb +1 -1
  115. data/examples/pacman_package/spec/purge_spec.rb +1 -1
  116. data/examples/pacman_package/spec/remove_spec.rb +1 -1
  117. data/examples/pacman_package/spec/upgrade_spec.rb +1 -1
  118. data/examples/portage_package/spec/install_spec.rb +1 -1
  119. data/examples/portage_package/spec/purge_spec.rb +1 -1
  120. data/examples/portage_package/spec/remove_spec.rb +1 -1
  121. data/examples/portage_package/spec/upgrade_spec.rb +1 -1
  122. data/examples/powershell_script/spec/run_spec.rb +1 -1
  123. data/examples/registry_key/spec/create_if_missing_spec.rb +1 -1
  124. data/examples/registry_key/spec/create_spec.rb +1 -1
  125. data/examples/registry_key/spec/delete_key_spec.rb +1 -1
  126. data/examples/registry_key/spec/delete_spec.rb +1 -1
  127. data/examples/remote_directory/spec/create_if_missing_spec.rb +1 -1
  128. data/examples/remote_directory/spec/create_spec.rb +1 -1
  129. data/examples/remote_directory/spec/delete_spec.rb +1 -1
  130. data/examples/remote_file/spec/create_if_missing_spec.rb +1 -1
  131. data/examples/remote_file/spec/create_spec.rb +1 -1
  132. data/examples/remote_file/spec/delete_spec.rb +1 -1
  133. data/examples/remote_file/spec/touch_spec.rb +1 -1
  134. data/examples/render_file/spec/default_spec.rb +1 -1
  135. data/examples/render_file/spec/template_helpers_spec.rb +1 -1
  136. data/examples/roles/spec/default_spec.rb +1 -1
  137. data/examples/route/spec/add_spec.rb +1 -1
  138. data/examples/route/spec/delete_spec.rb +1 -1
  139. data/examples/rpm_package/spec/install_spec.rb +1 -1
  140. data/examples/rpm_package/spec/remove_spec.rb +1 -1
  141. data/examples/rpm_package/spec/upgrade_spec.rb +1 -1
  142. data/examples/ruby_block/spec/run_spec.rb +1 -1
  143. data/examples/script/spec/run_bash_spec.rb +1 -1
  144. data/examples/script/spec/run_csh_spec.rb +1 -1
  145. data/examples/script/spec/run_perl_spec.rb +1 -1
  146. data/examples/script/spec/run_python_spec.rb +1 -1
  147. data/examples/script/spec/run_ruby_spec.rb +1 -1
  148. data/examples/script/spec/run_script_spec.rb +1 -1
  149. data/examples/server/spec/client_spec.rb +5 -4
  150. data/examples/server/spec/data_bag_spec.rb +10 -9
  151. data/examples/server/spec/environment_spec.rb +5 -4
  152. data/examples/server/spec/node_spec.rb +20 -14
  153. data/examples/server/spec/render_with_cached_spec.rb +1 -2
  154. data/examples/server/spec/role_spec.rb +5 -4
  155. data/examples/server/spec/search_spec.rb +7 -8
  156. data/examples/service/spec/disable_spec.rb +1 -1
  157. data/examples/service/spec/enable_spec.rb +1 -1
  158. data/examples/service/spec/reload_spec.rb +1 -1
  159. data/examples/service/spec/restart_spec.rb +1 -1
  160. data/examples/service/spec/start_spec.rb +1 -1
  161. data/examples/service/spec/stop_spec.rb +1 -1
  162. data/examples/smartos_package/spec/install_spec.rb +1 -1
  163. data/examples/smartos_package/spec/remove_spec.rb +1 -1
  164. data/examples/smartos_package/spec/upgrade_spec.rb +1 -1
  165. data/examples/solaris_package/spec/install_spec.rb +1 -1
  166. data/examples/solaris_package/spec/remove_spec.rb +1 -1
  167. data/examples/state_attrs/spec/default_spec.rb +2 -2
  168. data/examples/step_into/spec/default_spec.rb +5 -2
  169. data/examples/stub_command/spec/default_spec.rb +1 -1
  170. data/examples/stub_data_bag/spec/default_spec.rb +1 -1
  171. data/examples/stub_data_bag_item/spec/default_spec.rb +1 -1
  172. data/examples/stub_search/spec/default_spec.rb +1 -1
  173. data/examples/subscribes/spec/chained_spec.rb +1 -1
  174. data/examples/subscribes/spec/default_spec.rb +1 -1
  175. data/examples/subscribes/spec/delayed_spec.rb +1 -1
  176. data/examples/subscribes/spec/immediately_spec.rb +1 -1
  177. data/examples/subversion/spec/checkout_spec.rb +1 -1
  178. data/examples/subversion/spec/export_spec.rb +1 -1
  179. data/examples/subversion/spec/force_export_spec.rb +1 -1
  180. data/examples/subversion/spec/sync_spec.rb +1 -1
  181. data/examples/template/spec/create_if_missing_spec.rb +1 -1
  182. data/examples/template/spec/create_spec.rb +1 -1
  183. data/examples/template/spec/delete_spec.rb +1 -1
  184. data/examples/template/spec/touch_spec.rb +1 -1
  185. data/examples/use_inline_resources/spec/default_spec.rb +4 -1
  186. data/examples/user/spec/create_spec.rb +1 -1
  187. data/examples/user/spec/lock_spec.rb +1 -1
  188. data/examples/user/spec/manage_spec.rb +1 -1
  189. data/examples/user/spec/modify_spec.rb +1 -1
  190. data/examples/user/spec/remove_spec.rb +1 -1
  191. data/examples/user/spec/unlock_spec.rb +1 -1
  192. data/examples/yum_package/spec/install_spec.rb +1 -1
  193. data/examples/yum_package/spec/purge_spec.rb +1 -1
  194. data/examples/yum_package/spec/remove_spec.rb +1 -1
  195. data/examples/yum_package/spec/upgrade_spec.rb +1 -1
  196. data/features/batch.feature +0 -3
  197. data/features/powershell_script.feature +0 -3
  198. data/features/render_file.feature +1 -6
  199. data/features/server.feature +0 -3
  200. data/features/smartos_package.feature +0 -4
  201. data/features/solaris_package.feature +0 -4
  202. data/features/state_attrs.feature +0 -4
  203. data/features/support/env.rb +0 -7
  204. data/gemfiles/{chef-11.12.0.gemfile → chef-11.16.0.gemfile} +1 -1
  205. data/gemfiles/chef-12.0.0.alpha.gemfile +5 -0
  206. data/lib/chefspec.rb +46 -14
  207. data/lib/chefspec/api.rb +0 -2
  208. data/lib/chefspec/api/apt_package.rb +1 -1
  209. data/lib/chefspec/api/batch.rb +1 -1
  210. data/lib/chefspec/api/chef_gem.rb +1 -1
  211. data/lib/chefspec/api/cookbook_file.rb +1 -1
  212. data/lib/chefspec/api/cron.rb +1 -1
  213. data/lib/chefspec/api/deploy.rb +1 -1
  214. data/lib/chefspec/api/directory.rb +1 -1
  215. data/lib/chefspec/api/dpkg_package.rb +1 -1
  216. data/lib/chefspec/api/easy_install_package.rb +1 -1
  217. data/lib/chefspec/api/env.rb +1 -1
  218. data/lib/chefspec/api/erl_call.rb +1 -1
  219. data/lib/chefspec/api/execute.rb +1 -1
  220. data/lib/chefspec/api/file.rb +1 -1
  221. data/lib/chefspec/api/freebsd_package.rb +1 -1
  222. data/lib/chefspec/api/gem_package.rb +1 -1
  223. data/lib/chefspec/api/git.rb +1 -1
  224. data/lib/chefspec/api/group.rb +1 -1
  225. data/lib/chefspec/api/http_request.rb +1 -1
  226. data/lib/chefspec/api/ifconfig.rb +1 -1
  227. data/lib/chefspec/api/ips_package.rb +1 -1
  228. data/lib/chefspec/api/link.rb +1 -1
  229. data/lib/chefspec/api/log.rb +1 -1
  230. data/lib/chefspec/api/macports_package.rb +1 -1
  231. data/lib/chefspec/api/mdadm.rb +1 -1
  232. data/lib/chefspec/api/mount.rb +1 -1
  233. data/lib/chefspec/api/ohai.rb +2 -2
  234. data/lib/chefspec/api/package.rb +1 -1
  235. data/lib/chefspec/api/pacman_package.rb +1 -1
  236. data/lib/chefspec/api/portage_package.rb +1 -1
  237. data/lib/chefspec/api/powershell_script.rb +1 -1
  238. data/lib/chefspec/api/registry_key.rb +1 -1
  239. data/lib/chefspec/api/remote_directory.rb +4 -4
  240. data/lib/chefspec/api/remote_file.rb +1 -1
  241. data/lib/chefspec/api/route.rb +1 -1
  242. data/lib/chefspec/api/rpm_package.rb +1 -1
  243. data/lib/chefspec/api/ruby_block.rb +1 -1
  244. data/lib/chefspec/api/script.rb +6 -6
  245. data/lib/chefspec/api/service.rb +1 -1
  246. data/lib/chefspec/api/smartos_package.rb +1 -1
  247. data/lib/chefspec/api/solaris_package.rb +1 -1
  248. data/lib/chefspec/api/subversion.rb +1 -1
  249. data/lib/chefspec/api/template.rb +1 -1
  250. data/lib/chefspec/api/user.rb +1 -1
  251. data/lib/chefspec/api/yum_package.rb +1 -1
  252. data/lib/chefspec/coverage/filters.rb +3 -0
  253. data/lib/chefspec/deprecations.rb +19 -123
  254. data/lib/chefspec/macros.rb +2 -2
  255. data/lib/chefspec/matchers/render_file_matcher.rb +2 -2
  256. data/lib/chefspec/matchers/resource_matcher.rb +1 -1
  257. data/lib/chefspec/matchers/state_attrs_matcher.rb +1 -1
  258. data/lib/chefspec/server.rb +4 -361
  259. data/lib/chefspec/server_methods.rb +175 -0
  260. data/lib/chefspec/server_runner.rb +86 -0
  261. data/lib/chefspec/{runner.rb → solo_runner.rb} +92 -43
  262. data/lib/chefspec/version.rb +1 -1
  263. data/spec/unit/{runner_spec.rb → solo_runner_spec.rb} +31 -25
  264. metadata +13 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42b8dc074521cc846b3577e67be0b31cefbd11bd
4
- data.tar.gz: b49ec85da25e784e7688674100a675842d92448d
3
+ metadata.gz: 6f7f37a530acbb9dff67aed530b585d77fdd0775
4
+ data.tar.gz: 33079e8115211a7bb28392ea9aa26a584f2b8e43
5
5
  SHA512:
6
- metadata.gz: 5f5fbfb4a6746c897e50bccc8207bfcbbbaee688849eb6ffa28db24b88b9fa594b9b8fe9c5a745305f96440d21bf2a2ea2d137da1b7bd9a0ae154e5591706fc5
7
- data.tar.gz: 6ab6c2840dcec33358b7d507fd16147e99eaa3d0f9e8c0efbfa52e854c3977b056f91d31488223871032ee5ad057da236100cf858fd4c00c449bc78b68b2466c
6
+ metadata.gz: 62f881a2f5ca9f7438399dfba1925ea5226c742c6e3d7da85facf1df9be28a8444d799c18428af6e0d9e12288a259a64fe3af47905733ca83572b28b33c92ac2
7
+ data.tar.gz: 4ee3f4f55710eca0bc4bf036ec683306a1d9312583ebe9edbfd3dfef892d5224813586c6109be50e0af4b89d0a393095b8e263d1fc46ab5e108319989f6c445b
data/.travis.yml CHANGED
@@ -19,8 +19,9 @@ notifications:
19
19
  bundler_args: --jobs 7
20
20
 
21
21
  gemfile:
22
- - gemfiles/chef-11.12.0.gemfile
23
22
  - gemfiles/chef-11.14.0.gemfile
23
+ - gemfiles/chef-11.16.0.gemfile
24
+ - gemfiles/chef-12.0.0.alpha.gemfile
24
25
  - gemfiles/chef-master.gemfile
25
26
 
26
27
  matrix:
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  CHANGELOG for ChefSpec
2
2
  ======================
3
3
 
4
+ ## 4.1.0 (October 12, 2014)
5
+ Bugfixes:
6
+ - Bump the minimum required version of Chef to 11.14
7
+ - Filter resources that have no source line in the coverage report - this is related to a bug in Chef where, when cloning a resource, both the clone and the original resource lose their metadata
8
+
9
+ Improvements:
10
+ - Allow multiple instances of a Chef Server instance
11
+ - Separate ChefSpec::Runner into `ChefSpec::SoloRunner` and `ChefSpec::ServerRunner`
12
+ - Preliminary support for Chef 12 alpha (not 100% complete)
13
+ - Add `SoloRunner` and `ServerRunner` `.converge` methods for quickly converging if you do not need to customize the runner object
14
+ - Create isolated Chef Server instances on a per-test or per-suite basis
15
+ - Deprecate `ChefSpec::Runner.define_runner_method` in favor of `ChefSpec.define_matcher`
16
+ - Deprecate `ChefSpec::Runner.new` - you should specify if you want a `SoloRunner` or `ServerRunner`
17
+ - Updated documentation
18
+
19
+ Breaking changes:
20
+ - Due to the new `ServerRunner`, the `ChefSpec::Server` singleton object has been deprecated. As much as I would like to provide a backwards-compatible interface, there is no way to do so (as the code now supports multipel Chef Server instances). Sorry :(.
21
+ - Remove old deprecations - this is not really a breaking change, but the v2.0.0 deprecations have been removed in favor of new ones
22
+
4
23
  ## 4.0.2 (August 13, 2014)
5
24
  Bugfixes:
6
25
  - Fix a regression caused by a new version of Chef Zero in single_org mode
data/README.md CHANGED
@@ -4,17 +4,15 @@ ChefSpec
4
4
  [![Build Status](http://img.shields.io/travis/sethvargo/chefspec.svg)][travis]
5
5
  [![Dependency Status](http://img.shields.io/gemnasium/sethvargo/chefspec.svg)][gemnasium]
6
6
  [![Code Climate](http://img.shields.io/codeclimate/github/sethvargo/chefspec.svg)][codeclimate]
7
- [![Gittip](http://img.shields.io/gittip/sethvargo.svg)][gittip]
8
7
 
9
8
  [gem]: https://rubygems.org/gems/chefspec
10
9
  [travis]: http://travis-ci.org/sethvargo/chefspec
11
10
  [gemnasium]: https://gemnasium.com/sethvargo/chefspec
12
11
  [codeclimate]: https://codeclimate.com/github/sethvargo/chefspec
13
- [gittip]: https://www.gittip.com/sethvargo
14
12
 
15
13
  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.
16
14
 
17
- ChefSpec runs your cookbook locally using Chef Solo without actually converging a node. This has two primary benefits:
15
+ ChefSpec runs your cookbook(s) locally with Chef Solo without actually converging a node. This has two primary benefits:
18
16
 
19
17
  - It's really fast!
20
18
  - Your tests can vary node attributes, operating systems, and search results to assert behavior under varying conditions.
@@ -24,27 +22,17 @@ What people are saying
24
22
  ----------------------
25
23
  > I just wanted to drop you a line to say "HELL YES!" to ChefSpec. - [Joe Goggins](https://twitter.com/jgoggins)
26
24
 
27
- > OK chefspec is my new best friend. Delightful few hours working with it. - [Michael Ivey](https://twitter.com/ivey)
25
+ > OK ChefSpec is my new best friend. Delightful few hours working with it. - [Michael Ivey](https://twitter.com/ivey)
28
26
 
29
27
  **Chat with us - [#chefspec](irc://irc.freenode.net/chefspec) on Freenode**
30
28
 
31
29
 
32
30
  Important Notes
33
31
  ---------------
34
- - **ChefSpec 3 requires Chef 11+! Please use the 2.x series for Chef 9 & 10 compatibility.**
35
- - **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' documentation!**
32
+ - **ChefSpec 3.0+ requires Ruby 1.9 or higher!**
33
+ - **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!**
36
34
  - **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).**
37
- - **ChefSpec 3.0 requires Ruby 1.9 or higher!**
38
-
39
- If you are migrating from ChefSpec v2.0.0, you should require the deprecations module after requiring `chefspec`:
40
-
41
- ```ruby
42
- # spec_helper.rb
43
- require 'chefspec'
44
- require 'chefspec/deprecations'
45
- ```
46
-
47
- After you have converted your specs, you can safely remove the deprecations module.
35
+ - **ChefSpec aims to maintain compatability 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.
48
36
 
49
37
 
50
38
  Writing a Cookbook Example
@@ -63,7 +51,7 @@ the associated ChefSpec test might look like:
63
51
  require 'chefspec'
64
52
 
65
53
  describe 'example::default' do
66
- let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
54
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
67
55
 
68
56
  it 'installs foo' do
69
57
  expect(chef_run).to install_package('foo')
@@ -107,23 +95,23 @@ RSpec.configure do |config|
107
95
  end
108
96
  ```
109
97
 
110
- Values specified at the initialization of the `Runner` merge and take precedence over the global settings:
98
+ Values specified at the initialization of a "Runner" merge and take precedence over any global settings:
111
99
 
112
100
  ```ruby
113
101
  # Override only the operating system version (platform is still "ubuntu" from above)
114
- ChefSpec::Runner.new(version: '10.04')
102
+ ChefSpec::SoloRunner.new(version: '10.04')
115
103
 
116
104
  # Use a different operating system platform and version
117
- ChefSpec::Runner.new(platform: 'centos', version: '5.4')
105
+ ChefSpec::SoloRunner.new(platform: 'centos', version: '5.10')
118
106
 
119
107
  # Specify a different cookbook_path
120
- ChefSpec::Runner.new(cookbook_path: '/var/my/other/path', role_path: '/var/my/roles')
108
+ ChefSpec::SoloRunner.new(cookbook_path: '/var/my/other/path', role_path: '/var/my/roles')
121
109
 
122
110
  # Add debug log output
123
- ChefSpec::Runner.new(log_level: :debug).converge(described_recipe)
111
+ ChefSpec::SoloRunner.new(log_level: :debug).converge(described_recipe)
124
112
  ```
125
113
 
126
- **NOTE** You do not _need_ to specify a platform and version. However, some cookbooks may rely on [Ohai](http://github.com/opscode/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).
114
+ **NOTE** You do not _need_ to specify a platform and version to use ChefSpec. However, some cookbooks may rely on [Ohai](http://github.com/opscode/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).
127
115
 
128
116
  ### Berkshelf
129
117
  If you are using Berkshelf, simply require `chefspec/berkshelf` in your `spec_helper` after requiring `chefspec`:
@@ -169,7 +157,7 @@ cookbook 'name_of_your_cookbook', path: '.'
169
157
 
170
158
  Running Specs
171
159
  -------------
172
- ChefSpec is actually a very large RSpec extension, so you can run your tests using the RSpec CLI:
160
+ ChefSpec is actually an RSpec extension, so you can run your tests using the RSpec CLI:
173
161
 
174
162
  ```bash
175
163
  $ rspec
@@ -192,7 +180,7 @@ ChefSpec asserts that resource actions have been performed. In general, ChefSpec
192
180
  require 'chefspec'
193
181
 
194
182
  describe 'example::default' do
195
- let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
183
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
196
184
 
197
185
  it 'does something' do
198
186
  expect(chef_run).to ACTION_RESOURCE(NAME)
@@ -206,13 +194,15 @@ where:
206
194
  - _RESOURCE_ - the name of the resource (e.g. `package`)
207
195
  - _NAME_ - the name attribute for the resource (e.g. `apache2`)
208
196
 
197
+ **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.
198
+
209
199
  Here's a more concrete example:
210
200
 
211
201
  ```ruby
212
202
  require 'chefspec'
213
203
 
214
204
  describe 'example::default' do
215
- let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
205
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
216
206
 
217
207
  it 'does something' do
218
208
  expect(chef_run).to install_package('apache2')
@@ -228,7 +218,7 @@ To test that a resource action is performed with a specific set of attributes, y
228
218
  require 'chefspec'
229
219
 
230
220
  describe 'example::default' do
231
- let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
221
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
232
222
 
233
223
  it 'does something' do
234
224
  expect(chef_run).to modify_group('docker').with(members: ['vagrant'])
@@ -318,7 +308,7 @@ Node attribute can be set when creating the `Runner`. The initializer yields a b
318
308
  ```ruby
319
309
  describe 'example::default' do
320
310
  let(:chef_run) do
321
- ChefSpec::Runner.new do |node|
311
+ ChefSpec::SoloRunner.new do |node|
322
312
  node.set['cookbook']['attribute'] = 'hello'
323
313
  end.converge(described_recipe)
324
314
  end
@@ -331,7 +321,7 @@ ChefSpec provides mocked automatic Ohai data using [fauxhai](https://github.com/
331
321
  ```ruby
332
322
  describe 'example::default' do
333
323
  let(:chef_run) do
334
- ChefSpec::Runner.new do |node|
324
+ ChefSpec::SoloRunner.new do |node|
335
325
  node.automatic['memory']['total'] = '512kB'
336
326
  end.converge(described_recipe)
337
327
  end
@@ -344,7 +334,7 @@ To set an attribute within a specific test, set the attribute in the `it` block
344
334
 
345
335
  ```ruby
346
336
  describe 'example::default' do
347
- let(:chef_run) { ChefSpec::Runner.new } # Notice we don't converge here
337
+ let(:chef_run) { ChefSpec::SoloRunner.new } # Notice we don't converge here
348
338
 
349
339
  it 'performs the action' do
350
340
  chef_run.node.set['cookbook']['attribute'] = 'hello'
@@ -355,19 +345,20 @@ describe 'example::default' do
355
345
  end
356
346
  ```
357
347
 
358
- Using Chef Zero
359
- ---------------
360
- By default, ChefSpec runs in Chef Solo mode. As of ChefSpec v3.1.0, you can ask ChefSpec to create an in-memory Chef Server during testing using [ChefZero](https://github.com/jkeiser/chef-zero). This is especially helpful if you need to support searching or data bags.
348
+ Using a Chef Server
349
+ -------------------
350
+ 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.
361
351
 
362
- To use the ChefSpec server, simply require the module in your `spec_helper`:
352
+ To use the ChefSpec server, simply replace `ChefSpec::SoloRunner` with `ChefSpec::ServerRunner`:
363
353
 
364
- ```ruby
365
- # spec_helper.rb
366
- require 'chefspec'
367
- require 'chefspec/server'
354
+ ```diff
355
+ describe 'example::default' do
356
+ - let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
357
+ + let(:chef_run) { ChefSpec::ServerRunner.converge(described_recipe) }
358
+ end
368
359
  ```
369
360
 
370
- 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 the ChefSpec server.
361
+ 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.
371
362
 
372
363
  ### DSL
373
364
  The ChefSpec server includes a collection of helpful DSL methods for populating data into the Chef Server.
@@ -375,58 +366,68 @@ The ChefSpec server includes a collection of helpful DSL methods for populating
375
366
  Create a client:
376
367
 
377
368
  ```ruby
378
- ChefSpec::Server.create_client('my_client', { admin: true })
369
+ ChefSpec::ServerRunner.new do |node, server|
370
+ server.create_client('my_client', { admin: true })
371
+ end
379
372
  ```
380
373
 
381
374
  Create a data bag (and items):
382
375
 
383
376
  ```ruby
384
- ChefSpec::Server.create_data_bag('my_data_bag', {
385
- 'item_1' => {
386
- 'password' => 'abc123'
387
- },
388
- 'item_2' => {
389
- 'password' => 'def456'
390
- }
391
- })
377
+ ChefSpec::ServerRunner.new do |node, server|
378
+ server.create_data_bag('my_data_bag', {
379
+ 'item_1' => {
380
+ 'password' => 'abc123'
381
+ },
382
+ 'item_2' => {
383
+ 'password' => 'def456'
384
+ }
385
+ })
386
+ end
392
387
  ```
393
388
 
394
389
  Create an environment:
395
390
 
396
391
  ```ruby
397
- ChefSpec::Server.create_environment('my_environment', { description: '...' })
392
+ ChefSpec::ServerRunner.new do |node, server|
393
+ server.create_environment('my_environment', { description: '...' })
394
+ end
398
395
  ```
399
396
 
400
397
  Create a node:
401
398
 
402
399
  ```ruby
403
- ChefSpec::Server.create_node('my_node', { run_list: ['...'] })
400
+ ChefSpec::ServerRunner.new do |node, server|
401
+ server.create_node('my_node', { run_list: ['...'] })
402
+ end
404
403
  ```
405
404
 
406
- You may also be interested in 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:
405
+ Note: the current "node" is always uploaded to the server.
406
+
407
+ 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:
407
408
 
408
409
  ```ruby
409
410
  www = stub_node(platform: 'ubuntu', version: '12.04') do |node|
410
411
  node.set['attribute'] = 'value'
411
412
  end
412
413
 
413
- # `www` is now a local Chef::Node object you can use in your test. To push this
414
- # node to the server, call `create_node`:
414
+ # `www` is now a local Chef::Node object you can use in your test. To publish
415
+ # this node to the server, call `create_node`:
415
416
 
416
- ChefSpec::Server.create_node(www)
417
+ ChefSpec::ServerRunner.new do |node, server|
418
+ server.create_node(www)
419
+ end
417
420
  ```
418
421
 
419
422
  Create a role:
420
423
 
421
424
  ```ruby
422
- ChefSpec::Server.create_role('my_role', { default_attributes: {} })
423
-
424
- # The role now exists on the Chef Server, you can add it to a node's run_list
425
- # by adding it to the `converge` block:
426
- let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe, 'role[my_role]') }
425
+ ChefSpec::ServerRunner.new do |node, server|
426
+ server.create_role('my_role', { default_attributes: {} })
427
+ end
427
428
  ```
428
429
 
429
- **NOTE** The ChefSpec server is empty at the start of each example to avoid interdependent tests. You can use `before` blocks to load data before each test.
430
+ **NOTE** The ChefSpec server is empty at the start of each example to avoid interdependent tests.
430
431
 
431
432
 
432
433
  Stubbing
@@ -456,7 +457,7 @@ Just like the error message says, you must stub the command result. This can be
456
457
 
457
458
  ```ruby
458
459
  describe 'example::default' do
459
- let(:chef_run) { ChefSpec::Runner.new }
460
+ let(:chef_run) { ChefSpec::SoloRunner.new }
460
461
 
461
462
  before do
462
463
  stub_command("grep /tmp/foo.txt text").and_return(true)
@@ -466,7 +467,7 @@ end
466
467
 
467
468
  ```ruby
468
469
  describe 'example::default' do
469
- let(:chef_run) { ChefSpec::Runner.new }
470
+ let(:chef_run) { ChefSpec::SoloRunner.new }
470
471
 
471
472
  before do
472
473
  stub_command("grep /tmp/foo.txt text") { rand(50)%2 == 0 }
@@ -501,7 +502,7 @@ Just like the error message says, you must stub the result of the `data_bag` cal
501
502
 
502
503
  ```ruby
503
504
  describe 'example::default' do
504
- let(:chef_run) { ChefSpec::Runner.new }
505
+ let(:chef_run) { ChefSpec::SoloRunner.new }
505
506
 
506
507
  before do
507
508
  stub_data_bag('users').and_return([])
@@ -511,7 +512,7 @@ end
511
512
 
512
513
  ```ruby
513
514
  describe 'example::default' do
514
- let(:chef_run) { ChefSpec::Runner.new }
515
+ let(:chef_run) { ChefSpec::SoloRunner.new }
515
516
 
516
517
  before do
517
518
  stub_data_bag('users').and_return(['svargo', 'francis'])
@@ -551,7 +552,7 @@ Just like the error message says, you must stub the search result. This can be d
551
552
 
552
553
  ```ruby
553
554
  describe 'example::default' do
554
- let(:chef_run) { ChefSpec::Runner.new }
555
+ let(:chef_run) { ChefSpec::SoloRunner.new }
555
556
 
556
557
  before do
557
558
  stub_search(:node, 'name:hello').and_return([])
@@ -561,7 +562,7 @@ end
561
562
 
562
563
  ```ruby
563
564
  describe 'example::default' do
564
- let(:chef_run) { ChefSpec::Runner.new }
565
+ let(:chef_run) { ChefSpec::SoloRunner.new }
565
566
 
566
567
  before do
567
568
  stub_search(:node, 'name:hello') { (ruby_code) }
@@ -569,6 +570,7 @@ describe 'example::default' do
569
570
  end
570
571
  ```
571
572
 
573
+
572
574
  Reporting
573
575
  ---------
574
576
  ChefSpec can generate a report of resources read over resources tested.
@@ -665,7 +667,7 @@ If you want to mock out `node.chef_environment`, you'll need to use RSpec mocks/
665
667
 
666
668
  ```ruby
667
669
  let(:chef_run) do
668
- ChefSpec::Runner.new do |node|
670
+ ChefSpec::SoloRunner.new do |node|
669
671
  # Create a new environment (you could also use a different :let block or :before block)
670
672
  env = Chef::Environment.new
671
673
  env.name 'staging'
@@ -694,7 +696,9 @@ In order to run the actions exposed by your LWRP, you have to explicitly tell th
694
696
  require 'chefspec'
695
697
 
696
698
  describe 'foo::default' do
697
- let(:chef_run) { ChefSpec::Runner.new(step_into: ['my_lwrp']).converge('foo::default') }
699
+ let(:chef_run) do
700
+ ChefSpec::SoloRunner.new(step_into: ['my_lwrp']).converge('foo::default')
701
+ end
698
702
 
699
703
  it 'installs the foo package through my_lwrp' do
700
704
  expect(chef_run).to install_package('foo')
@@ -799,13 +803,13 @@ ChefSpec also provides a helper method to define a method on the Chef runner for
799
803
 
800
804
  ```ruby
801
805
  # matchers.rb
802
- ChefSpec::Runner.define_runner_method :my_custom_resource
806
+ ChefSpec.define_matcher :my_custom_resource
803
807
  ```
804
808
 
805
809
  And then in your spec suite, you can obtain the custom resource for assertions:
806
810
 
807
811
  ```ruby
808
- let(:chef_run) { ChefSpec::Runner.new('...') }
812
+ let(:chef_run) { ChefSpec::SoloRunner.converge('...') }
809
813
 
810
814
  it 'notifies the thing' do
811
815
  custom = chef_run.my_custom_resource('name')
@@ -845,7 +849,7 @@ Relevant File Content:
845
849
  This output is automatically silenced when using RSpec's `raise_error` matcher:
846
850
 
847
851
  ```ruby
848
- let(:chef_run) { ChefSpec::Runner.new.converge('cookbook::recipe') }
852
+ let(:chef_run) { ChefSpec::SoloRunner.converge('cookbook::recipe') }
849
853
 
850
854
  it 'raises an error' do
851
855
  expect {
@@ -857,7 +861,7 @@ end
857
861
  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.
858
862
 
859
863
  ```ruby
860
- let(:chef_run) { ChefSpec::Runner.new.converge('cookbook::recipe') }
864
+ let(:chef_run) { ChefSpec::SoloRunner.converge('cookbook::recipe') }
861
865
 
862
866
  it 'raises an error' do
863
867
  expect {
@@ -868,7 +872,7 @@ end
868
872
 
869
873
  Testing Roles
870
874
  -------------
871
- Even though ChefSpec is cookbook-centric, you can still converge multiple recipes and roles in a single `ChefSpec::Runner` instance. Given a cookbook "bacon" with a default recipe:
875
+ Even though ChefSpec is cookbook-centric, you can still converge multiple recipes and roles in a single `ChefSpec::SoloRunner` instance. Given a cookbook "bacon" with a default recipe:
872
876
 
873
877
  ```ruby
874
878
  # cookbooks/bacon/recipes/default.rb
@@ -896,10 +900,10 @@ run_list([
896
900
  ])
897
901
  ```
898
902
 
899
- You can test that the role is appropriately applied by telling the `ChefSpec::Runner` to converge on the _role_ instead of a recipe:
903
+ You can test that the role is appropriately applied by telling the `ChefSpec::SoloRunner` to converge on the _role_ instead of a recipe:
900
904
 
901
905
  ```ruby
902
- let(:chef_run) { ChefSpec::Runner.new.converge('role[breakfast]') }
906
+ let(:chef_run) { ChefSpec::SoloRunner.converge('role[breakfast]') }
903
907
  ```
904
908
 
905
909
  Assert that the run_list is properly expanded:
@@ -923,7 +927,7 @@ end
923
927
 
924
928
  # - OR -
925
929
 
926
- ChefSpec::Runner.new(role_path: '/var/my/roles') # local setting
930
+ ChefSpec::SoloRunner.new(role_path: '/var/my/roles') # local setting
927
931
  ```
928
932
 
929
933
 
@@ -931,21 +935,14 @@ Faster Specs
931
935
  ------------
932
936
  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.
933
937
 
934
- 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). Just require the cacher module in your spec helper.
935
-
936
- ```ruby
937
- # spec_helper.rb
938
- require 'chefspec/cacher'
939
- ```
940
-
941
- Next, convert all your `let` blocks to `cached`:
938
+ 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`:
942
939
 
943
940
  ```ruby
944
941
  # before
945
- let(:chef_run) { ChefSpec::Runner.new }
942
+ let(:chef_run) { ChefSpec::SoloRunner.new }
946
943
 
947
944
  # after
948
- cached(:chef_run) { ChefSpec::Runner.new }
945
+ cached(:chef_run) { ChefSpec::SoloRunner.new }
949
946
  ```
950
947
 
951
948
  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).