This problem arises when you:
- Write a library cookbook (i.e. it has no recipes apart from a no-op default.rb)
- Create a
testcookbook undertest/fixtures/cookbooks/to exercise the library. That istest/fixtures/cookbooks/test/recipes/system.rb - Write a ChefSpec spec that
describe 'test::system' - Use Policyfiles rather than Berkshelf.
When using Berkshelf you would use group :integration do ... end to include the test cookbook only when running tests.
How do you write a Policyfile that only references the test cookbook when running tests?
Right now I have my policyfile always packaging the test cookbook. Not ideal but acceptable to get something that just works in a test environment. Not sustainable over the longer term.
Appreciate any hints, tips or incantations.
Create two Policyfiles.
One of them contains the recipes/attributes that you would run on a "real" node. The other contains what is needed to exercise the cookbook in test kitchen.
You can specify a Policyfile path in
kitchen.rb.