bolt
bolt copied to clipboard
Add a way to mock a Puppet/Bolt function while testing a plan with BoltSpec
Use Case
It'd be nice to mock a Puppet DSL function or a Puppet v4 Ruby API function while testing a plan with BoltSpec.
Describe the Solution You Would Like
Ideally it should be as clean as possible:
allow(<some Puppet object>).to receive(:function_name_to_mock).with(args).and_return(fake_result)
When testing a Puppet class/defined resource it's possible to workaround the issue with pre_condition.. but in BoltSpec I see no way to do this..
Describe Alternatives You've Considered
I can wrap a function call with a plan but it's too weird IMHO..
Thanks this has been requested before. https://github.com/puppetlabs/bolt/issues/1812
Ouch.. maybe better to reopen that one and close this then..