Hi
I have below manifests
class module::script1 inherits module::script2 {
service { 'foo':
ensure => $::ensure,
enable => $::enable,
}}
class module::script2 {
$ensure = hiera("ensure::$::operatingsystemmajrelease")
$enable = hiera("enable::$::operatingsystemmajrelease")
}
I wrote below rspec-puppet test case
describe 'module::script1' do
let(:facts) {{ :operatingsystemmajrelease => '7' }}
let(:hiera_config) { 'spec/fixtures/hiera.yaml' }
hiera = Hiera.new({ :config => 'spec/fixtures/hiera.yaml' })
enb = hiera.lookup('ensure::7',nil,nil)
val = hiera.lookup('enable::7',nil,nil)
it { should contain_service('foo').with(
'ensure' => enb,
'enable' => val,
)}
end
end
I get below error when I test
1) puppet::client puppet client test case should contain Service[foo] with ensure => "enabled", enable => "true"
Failure/Error: )}
expected that the catalogue would contain Service[foo] with ensure set to "enabled" but it is set to nil, and parameter enable set to "true"
but it is set to nil
Diff:
@@ -1,4 +1 @@
-enabled
-
-true
My doubt is, how we can pass "$::ensure" and "$::enable" in rspec-puppet.
↧