A template for Chef Cookbooks. Includes three gems: chefspec, fauxhai, and librarian-chef.
- Clone this repo using
git clone git://github.com/Lytro/chef_cookbook_template.git YOUR_COOKBOOK_NAME
- Search and replace "chef_cookbook_template" with the name of your cookbook (preserve case if you want to be fancy)
- Update the maintainer and maintainer_email in
metadata.rb
- Update YOUR_COMPANY_NAME towards the top of
recipes/default.rb
- Start TDD-ing your cookbook!
- If you want your specs to run against dependent cookbooks:
- add them to the
Cheffile
- install them via
librarian-chef install
- open
spec/spec_helper.rb
, then delete lines 11-13, 21 and 22, and uncomment lines 23 and 24.
- add them to the
- If you want to stub out dependent cookbooks and included recipes:
- open
spec/spec_helper.rb
and delete lines 22-24.
- open
- If you don't have dependent cookbooks, then:
- open
spec/spec_helper.rb
and delete lines 11-13 and 22-24.
- open
Note that when using ChefSpec and loading dependent cookbooks, you will be loading any cookbooks in directories parallel to the current cookbook. This is because of the way Chef Solo works. In order to test cookbooks in isolation, you must move them into their own directory. See chefspec/chefspec#78.