Tests for a typename
provider live at spec/unit/puppet/typename_spec.rb
and their corresponding fixture (starting file) under spec/fixture/unit/puppet/typename/
.
Use an rspec context section per fixture and have multiple examples within the section using it.
Tests use real resources which are applied via the AugeasSpec::Fixtures::apply
method to a temporary file created from the original fixture. Once applied, the temporary file is tested using one of two methods:
aug_open
helper) and perform match/get queries to test particular features of the tree.{ }
syntax and use augparse
or augparse_filter
helpers to compare the file against the expected tree.The latter will be much easier and more robust as it will compare all aspects of the tree, while the first might be needed for some edge cases (empty files etc).
See also this writeup on testing techniques for Puppet providers using Augeas which shows this process for augeasproviders.
Execute rake spec
in the root directory to run all tests.
After applying the resource, there are a few ways we could test the results of the file.
Install bundler and run bundle install
to get all gems required for development or see the contents of Gemfile.
Please send pull requests via GitHub, or patches via git send-email to the author.