I recently ran into a situation with puppet where I needed to write unit tests for a module which had embedded extdata calls. Since I don’t particularly care what the value is, just that the data is getting in the right place, this is pretty easy to stub out in rspec
First I made sure that the following was added to
Puppet.settings[:confdir] = "spec/fixtures"
Next I told puppet where to find the stub extlookup data in the file
$extlookup_datadir = 'spec/fixtures/extlookup' $extlookup_precedence = ['common']
And finally in
spec/fixtures/extlookup/common.csv I added the stub csv data:
key1,bogon key2,bogon key3,bogon
That was sufficient to appease the extlookup calls and allow me to test the parts of the module I was actually concerned about.
I hope this helps someone other than me.