Is there a standard pattern for writing spec tests for a puppet module, that correctly creates the custom facts that are required by the modules that the tested module includes?
I have a module whose class includes puppetlabs/mongodb, which uses the custom fact ::root_home (which is created by puppetlabs/stdlib).
Looking at the test code for mongodb, (in particular spec_helper_local.rb), I see code that creates the :root_home fact for testing.
But, in my own module, unless I do something to create that fact in my own test code, my test fails with "Evaluation Error: Unknown variable," which makes perfect since since nothing in the test suite is creating that fact.
Now I could just create the fact in the spec_helper_local.rb file for my module, but that just kicks the problem upstairs to whoever includes my module in theirs.
How should I deal with this? Has anyone already written code that recursively descends into included modules and creates the required facts for testing?
letblock inside the test spec itself. There is no optimal way of doing this as far as I know, which is what you want. - Matt Schuchard