I' am trying to write ChefSpec tests for some of our Cookbooks. One of those is including a lot of other cookbooks, to setup an Jenkins CI Enviroment.
Iam wondering how other people are testing the included recepies. My "_spec.rb" looks like this in the moment (example to test, that jenkins master is included):
it 'includes the `jenkins` recipe' do
expect(chef_run).to include_recipe('jenkins::master')
end
Now the coverage goes down, because i am not testing the included cookbooks (they have there own chefspec tests).
If someone has an example or good ideas... would be great.
Ok found an Issu, looks like this is my "problem" with the CodeCoverage - iam on Windows: https://github.com/sethvargo/chefspec/issues/594
.. same issue under Ubuntu, no OSX to verify the issue (-:
If you only want to test the inclusion of an recipe from another cookbook, you can stub the include call.
It's documented with examples in the ChefSpec readme at https://github.com/sethvargo/chefspec#include_recipe
"Keep the resources from an included recipe from being loaded into the Chef run, but test that the recipe was included":