If you are using Bundler to manage the gems in your
module or control repository (highly recommended), you should add rspec-puppet
to your Gemfile
and then run bundle install
.
Alternatively, you can install rspec-puppet using gem
.
rspec-puppet needs to have Puppet installed on the host in order to operate, but does not have it specified in the gem as dependency as Puppet can be installed as a native package or gem.
If you do not have Puppet installed, you’ll need to do so now. If you are using
Bundler to manage the gems in your module or control
repository, you should add Puppet to your Gemfile
and then run bundle
install
.
The above snippet will allow you to specify a Puppet version to use in the
PUPPET_GEM_VERSION
environment variable. This is a common pattern that you
will find in many open source modules that support multiple Puppet versions.
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 require.
Create a spec
directory inside your module
Puppet expects to be able to read a default manifest file (usually
manifests/site.pp
), so a blank one needs to be created.
RSpec needs to be configured to use rspec-puppet, which is done in the
spec/spec_helper.rb
file which should be created now with the following
content.
Optionally, if you are using Rake to automate
tasks in your module, you can add a spec
task to your Rakefile
.
Coming soon!