bolt icon indicating copy to clipboard operation
bolt copied to clipboard

Add a way to mock a Puppet/Bolt function while testing a plan with BoltSpec

Open jay7x opened this issue 1 year ago • 2 comments

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..

jay7x avatar Apr 04 '24 22:04 jay7x

Thanks this has been requested before. https://github.com/puppetlabs/bolt/issues/1812

donoghuc avatar Apr 04 '24 22:04 donoghuc

Ouch.. maybe better to reopen that one and close this then..

jay7x avatar Apr 04 '24 22:04 jay7x