I have a class which looks like
class addon {
case $::operatingsystem {
'windows': {
Dsc_xfirewall {
dsc_ensure => 'Present',
}
}
'RedHat': {
}
default: { warning "OS : ${::operatingsystem} is not (yet) supported" }
}
}
and I would like my test to look like
describe 'addon', :type => :class do
os = 'windows'
let(:facts) {{:operatingsystem => os}}
describe os do
it {
is_expected.to contain_class('addon').with(
{
:Dsc_xfirewall => {
:dsc_ensure => 'Present',
}
}
)
}
end
end
The catalog compiles correctly, the is_expected.to compile is removed for clarity. However I can't seem to get this to work: dsc_xfirewall is nil, if I try Dsc_xfirewall same story and if try
contains_dsc_xfirewall
I get an error that dsc_firewall is not a valid define. Does anyone have any ideas how I can better structure my test? Before anyone points out that if the catalog compiles correctly I don't need this test, I know that; this is just a cooked down version of something more complex.
My question is therefore: what does the test have to look like to check that the class contains dsc_xfirewall and that all the parameters are set correctly?