Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

"undefined method `parameters' for nil:NilClass" error in rspec-puppet

$
0
0
Hi, I have below manifests for firewall module class mod_firewalld { firewalld::service { 'tsm': short => "storage manag", description => "backup", ports => [ { port => "4335_7542", protocol => "tcp", }, { port => "4353_0120", protocol => "tcp", }, { port => "2345_4343", protocol => "tcp", },], }-> firewalld::service { 'scom': short => "SCOM", description => "back scom port", ports => [ { port => "22", protocol => "tcp", }, { port => "5676", protocol => "tcp", },], } Below is the defined class define firewalld::service( $short = '', $description = '', $ports = [], $modules = [], $destination = {}, ) { file { "/etc/services/${name}.xml": content => template('tem_name/service.xml.erb'), owner => root, group => root, mode => '0644', require => Package['firewalld'], notify => Service['firewalld'], } } I tried below rspec-puppet describe 'firewalld::service', :type => 'define' do let(:title) { 'undefined' } firewalld_srvcs = { 'tsm' => { 'short' => 'storage manag', 'description' => 'backup', 'ports' => [{ 'port' => "4335_7542", 'protocol' => "tcp", }, { 'port' => "4353_0120", 'protocol' => "tcp", }, { 'port' => "2345_4343", 'protocol' => "tcp", },], 'modules' => [], 'destination' => {}, }, 'test2' => { short => "SCOM", description => "back scom port", ports => [ { port => "22", protocol => "tcp", }, { port => "5676", protocol => "tcp", },], } firewalld_srvcs.each do|title,value| context title do let(:title) { title } let(:params) {{ 'short' => value['short'], 'description' => value['description'], 'ports' => value['ports'], }} it { should contain_file("etc/services/#{title}.xml").with( 'owner' => 'root', 'group' => 'root', 'mode' => '0644', 'require' => 'Package[firewalld]', 'notify' => 'Service[firewalld]', )} end end it 'should generate valid content for tsm.xml' do content = catalogue.resource('file', 'etc/services/tsm.xml').send(:parameters)[:content] content.should match('storage managbackup') end end but when I run test case it failed with below error message Failure/Error: content = catalogue.resource('file', '/etc/services/tsm.xml').send(:parameters)[:content] NoMethodError: undefined method `parameters' for nil:NilClass # ./spec/defines/firewalld_def_spec.rb:180:in `block (2 levels) in '

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>