I am testing a resource and I want to check it has exactly the right number of parameters, but one of them is a require, which I haven't figured out how to match in a with. I test that the relationship is correct using that_requires. My current test looks like
context 'xldeploy_environment_member' do
env = "Environments/#{company_short}/#{environment_short}/#{sn_environment}"
name = "#{env}/#{website}"
dict = "#{env}/dict.#{website}"
infhost = "Infrastructure/IIS/#{hostname}"
it { is_expected.to contain_xldeploy_environment_member(name).with({
:id => name,
:ensure => 'present',
:env => name,
:dictionaries => [dict],
:members => ["#{infhost}/#{website}", infhost],
}.merge($xldeploy_defaults))}
it { is_expected.to contain_xldeploy_environment_member(name).that_requires(
"Xldeploy_ci[#{name}]")
}
end
but I would like to replace the with with an only_with, as the with would allow extra parameters to be added without a corresponding test. If there were a parameter_count check like there is a resource_count check I could use that. Does rspec-puppet support matching on regexes so that I can check that the parameter is there? I'm not interested in the actual content, as that is tested by the that_requires.
Yes, Rspec-puppet supports regexps, and if you want to say "require anything" in conjunction with
only_withyou could write: