Adds a method 'without' which accepts a list of
parameters that should not be defined in the resource.
Example:
it { should contain_service('keystone').without(
['restart', 'status']
)}
This commit adds a method 'with' that can be used
to test mulitple parameters/values with a single
method call
Example:
it do should contain_service('keystone').with(
'ensure' => 'running',
'enable' => 'true',
'hasstatus' => 'true',
'hasrestart' => 'true'
) end
It was created as a more condensed alternative to
chaining methods per parameter to validate.
Without this patch it is difficult to match portions of long strings
which are attribute values of resource parameters. For example, the
content parameter of a file resource with a multi-line template.
This patch makes it easier to match portions of the parameter's value by
passing a Regexp instance to the with_ catch all matcher.
The use case looks like:
describe 'with lsbmajdistrelease available' do
let(:facts) { @facter_facts.merge({'lsbmajdistrelease' => '6'}) }
it { should_not contain_file('puppetenterprise.repo').with_content(missing_content) }
it { should contain_package 'pe-ruby-devel' }
it do
should contain_file('puppetenterprise.repo').with_content(/baseurl=http/)
should contain_file('puppetenterprise.repo').with_content(/pe_base/)
should contain_file('puppetenterprise.repo').with_content(/pe_updates/)
should contain_file('puppetenterprise.repo').with_content(/pe_extras/)
end
end
This feature allows the same parameter to be matched multiple times using
multiple different regular expressions.
This patch also improves the error message by presenting the actual value in
the catalog when it does not match the expectation. This change applies to
both String and Regexp expectation matches.
The error output now looks like:
1) pe_devel on redhat el6 os families with lsbmajdistrelease available
Failure/Error: should contain_file('puppetenterprise.repo').with_content(/JEFF MCCUNE/)
expected that the catalogue would contain File[puppetenterprise.repo] with content \
matching `/JEFF MCCUNE/` but its value of `"# KERMIT FROG\n"` does not
Spec tests have been added to exercise the handling of Regexp instances.
Reviewed-by: Dan Bode
Previously boolean, hash, and array param
values were not supported for defined or classes.
Now, we are using inspect instead of to_s so they
will be returned as the correct reprentation of
their type to Puppet.
Reviewed-by: Matthaus Litteken <matthaus@puppetlabs.com>
Signed-off-by: Dan Bode <dan@puppetlabs.com>
In case it contains non-alpha-numerics.
Previously, you could not specify classes with
namespaces like: foo::bar
Reviewed-by: Dan Bode <dan@puppetlabs.com>
Signed-off-by: Matthaus Litteken <matthaus@puppetlabs.com>
Allows you to specify external dependencies
for classes/defines.
Reviewed-by: Dan Bode <dan@puppetlabs.com>
Signed-off-by: Matthaus Litteken <matthaus@puppetlabs.com>