ruby - Using external variable in rspec-puppet test -


have stuck using variable in rspec. here params.pp

case $::osfamily{   debian: {     $ssh_daemon = "ssh"   }   redhat: {     $ssh_daemon = "sshd"   } 

in rspec test need use variable $ssh_daemon this:

it { should contain_service("${ssh_daemon}").with(   :ensure => 'running',   :enable => 'true', )} 

here ssh.pp file

service { "${ssh_daemon}":   ensure => running,   enable => true, } 

how can write variable ($ssh_daemon) test work?

you can mocking facter output.

something like:

context 'service on debian'   let(:facts) { { :osfamily => 'debian' } }   { should contain_service("ssh") } end  context 'service on redhat'   let(:facts) { { :osfamily => 'redhat' } }   { should contain_service("sshd") } end 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -