0

This problem arises when you:

  1. Write a library cookbook (i.e. it has no recipes apart from a no-op default.rb)
  2. Create a test cookbook under test/fixtures/cookbooks/ to exercise the library. That is test/fixtures/cookbooks/test/recipes/system.rb
  3. Write a ChefSpec spec that describe 'test::system'
  4. 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.

Hedgehog
  • 5,487
  • 4
  • 36
  • 43

1 Answers1

1

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.

suites:
  - name: default
    provisioner:
      policyfile_path: policies/kitchen.rb
Andy Foster
  • 237
  • 2
  • 11