Is it a good idea to create helper ruby modules to be required by rspec-puppet tests?
I intend to do some changes in a number of templates for puppetlabs-apache module, and there will be an identical section repeated in all templates (in fact, included by a helper template, but this is irrelevant here). The rspec-puppet test for the classes which use these templates will, then have redundant code to test this content.
In order not to repeat code, I thought of creating a helper module with the redundant logic and requiring it in each spec test.
It would look kinda like:
# /spec/classes/mod/mod_helper_spec.rb def repeated_content (Whatever redundant stuff) end
# /spec/classes/mod/*_spec.rb require './mod_helper_spec.rb' (specifics for the tested class) repeated_content(params) (specifics for the tested class)
My question is: is this a Good Idea? The obvious intent is to DRY (don't repeat yourself) the test code, but I wonder if I'm adding more complexity than spec tests should have.
I read here and here about using this techique in plain Ruby rspec, but found no reference about this in rspec-puppet.