I have cookbooks that run shell commands (via execute or not_if
blocks), which ChefSpec predictably complains need to be stubbed. These
cookbooks are included in many places, and I wind up copy/pasting a stub
into a before block in the tests of many other cookbooks that include the
offending cookbook even as a dependency of a dependency of a dependency.
Can I somehow stub these shell commands right in the cookbook that issues
them, such that ChefSpec tests for any other cookbook will pick up the
stubs?
morning,
you can move the stubs in a helper module. and include that module via
rspec's configuration in your spec_helper. You can then choose to invoke
them before all or case by case basis,
e.g
happy testing,
ranjib
p.s. you can raise these questions in chef-testing mailing list or chefspec
github repo as well
I have cookbooks that run shell commands (via execute or not_if
blocks), which ChefSpec predictably complains need to be stubbed. These
cookbooks are included in many places, and I wind up copy/pasting a stub
into a before block in the tests of many other cookbooks that include the
offending cookbook even as a dependency of a dependency of a dependency.
Can I somehow stub these shell commands right in the cookbook that issues
them, such that ChefSpec tests for any other cookbook will pick up the
stubs?