Stubbing extdata in puppet spec tests

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 MODULENAME/spec/spec_helper.rb

Puppet.settings[:confdir] = "spec/fixtures"

Next I told puppet where to find the stub extlookup data in the file spec/fixtures/manifests/site.pp

$extlookup_datadir = 'spec/fixtures/extlookup'
$extlookup_precedence = ['common']

And finally inspec/fixtures/extlookup/common.csv I added the stub csv data:


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.