Beaker is a test framework created by Puppetlabs to run tests against puppet modules on real servers (vm, containers whatever) and test that they do what they say they should do.
Installing beaker is usually done by adding a few lines to the Gemfile:
group :acceptance do
Next we need to add node descriptions providing information on operating system and releases to run tests on. These are placed into the spec/acceptance/nodesets/ folder.
You must have at least a default.yml in the nodesets folder inside your acceptance folder. You can have different yaml files for different platforms you wish to test against.
Role of spec helper in spec/acceptance/nodesets/ folder:
The spec helper does the tasks needed in order to prepare your SUT (system under test). This might include installing puppet, installing your puppet module dependencies, etc..
The filename is important, it must end in _spec.rb in order for the test harness to detect it. You can see that there are many matchers you can use to run pretty much any kind of test you can think of.
bundle exec rake acceptance
This command will spin up your described servers in nodesets, install your puppet modules and dependencies, and test your assertions.
They will may be slow, but they can be very helpful, and potentially the only way to really test functionality of a puppet module in an end-to-end way.
Puppet is a system configuration management tool. Unit tests can only go so far to make sure the compiled catalog is “correct”. Puppet acceptance tests can help you go 100% and ensure that your module literally does what it says it does by running tests against actual systems, files, packages, and services.