rspec-puppet ships with a small script that will automate the setup process for you by creating the various files and directories that rspec and rspec-puppet requires in order to function correctly.
First, create the directories that will contain your spec files
Puppet always expects to be able to read a site.pp file, so we’ll create a blank one for it to read when running the tests
In order for Puppet’s manifest autoloader to work correctly, it expects to find
your manifests under
<modulepath>/<your module name>/manifests/. If we just
set the modulepath to the root of your module, it will be missing
name> from the path, so we work around this by creating a directory under
spec/fixtures/modules and symlinking your module contents into it
Now, you need to configure rspec-puppet to use the fixtures we just set up.
spec/spec_helper.rb with the following contents
All that’s left is to create a Rakefile with a task to run the tests
You can see above how we told RSpec where to find our manifest and module directories, but there’s other things you can tell RSpec about your Puppet setup if necessary (you should only set these if your tests aren’t working correctly, for most setups the default values will suffice).
hiera.yamlfile, if you use Hiera.