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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -