Jacques Betancourt
Jacques Betancourt

Reputation: 2802

ChefSpec counting resources from included recipe

I have a Chef cookbook (cookbook_alpha::default) that includes another cookbook (cookbook_bravo::default) using include_recipe 'cookbook_bravo::default'.

When I'm testing cookbook_alpha using ChefSpec, all of the resources in cookbook_alpha are shown and are tested. But the resources (files, templates, users etc) in cookbook_bravo show up as Untouched resources in cookbook_alpha test run. cookbook_bravo has it's own test suites and is covered adequately and I see no need to write duplicate, additional specs in cookbook_alpha simply to cover the resources from cookbook_bravo that are already tested.

Upvotes: 0

Views: 189

Answers (1)

Roland
Roland

Reputation: 1426

Depending on your cookbook dependency manager (Berkshelf, Librarian, none) ChefSpec can determine, if a chef resource call is made outside or inside the current cookbook. (You still may have to stub calls to data bags and thinngs like file system checks in pre-conditionals (only_if, not_if)).

If you, for whatevery reasons, can't use any of the integration, you still can stub the include_recipe call as described in the ReadMe:

https://github.com/sethvargo/chefspec#include_recipe

hope this answers your question.

Upvotes: 0

Related Questions