puppet rspec fails when using stdlib getvar

80 views
Skip to first unread message

Werner Dijkerman

unread,
Jun 7, 2014, 3:11:41 PM6/7/14
to puppet...@googlegroups.com
Hi there,

I'm busy with writing rspec tests for my zabbix module. But I've got one problem.
Within my 'define' I have the following:

  $include_dir = getvar('zabbix::params::agent_include')

  file { "${include_dir}/${name}.conf":
    ensure  => present,
    owner   => 'zabbix',
    group   => 'zabbix',
    mode    => '0755',
    source  => $source,
  }

With this as my spec.rb file:
describe 'zabbix::userparameters' do
  let :facts do
    {
      :osfamily               => 'RedHat',
      :operatingsystem        => 'RedHat',
      :operatingsystemrelease => '6.5',
      :architecture           => 'x86_64',
      :lsbdistid              => 'RedHat',
      :concat_basedir         => '/tmp'
    }
  end
  let(:title) { 'mysql' }

  let(:params) { { :source => 'puppet:///modules/zabbix/mysqld.conf' } }
  it { should contain_file('/etc/zabbix/zabbix_agentd.d/mysql.conf').with_ensure('present') }
end

When I run rake spec, I've got the following message:

Failures:

  1) zabbix::userparameters should contain File[/etc/zabbix/zabbix_agentd.d/mysql.conf] with ensure => "present"
     Failure/Error: it { should contain_file('/etc/zabbix/zabbix_agentd.d/mysql.conf').with_ensure('present') }
       expected that the catalogue would contain File[/etc/zabbix/zabbix_agentd.d/mysql.conf]
     # ./spec/defines/userparameters_spec.rb:18:in `block (2 levels) in <top (required)>'

Finished in 0.26529 seconds
1 example, 1 failure
 
What am I missing..  ?
How do I set this 'include_dir' ?

Thanks in advance.
Kind regards,

Werner

Garrett Honeycutt

unread,
Jun 8, 2014, 12:54:14 PM6/8/14
to puppet...@googlegroups.com
Hi Werner,

You do not actually need to use getvar() as the following should work.

$include_dir = $zabbix::params::agent_include

If you could send a link to your module, I'd be happy to have a look.

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Werner Dijkerman

unread,
Jun 9, 2014, 3:50:22 AM6/9/14
to puppet...@googlegroups.com
Hi Garrett,

Thanks for your answer.
This is de link:

https://github.com/dj-wasabi/puppet-zabbix/blob/master/manifests/userparameters.pp

Kind regards,
Werner
Reply all
Reply to author
Forward
0 new messages