Ask Your Question

issue with assigning parameter variable in rspec-puppet

asked 2015-07-31 08:02:21 -0600

Chutki gravatar image

updated 2015-07-31 08:03:14 -0600


I have below manifests to install packages

$pckg = [

  package { $pckg : ensure => latest }

but when I apply the in rspec-puppet getting error spec/classes/pack_spec.rb

let(:params) {{ :pckg => 'package1' }}

  it { should contain_package(pckg).with_ensure('latest')}

getting below error



  1) pack should contain Package[package1] with ensure => "latest"
     Failure/Error: it { should contain_package(pckg).with_ensure('latest')}
       Invalid parameter pckg on Class[pack] at line 3 on node 
     # ./spec/classes/pack_spec.rb:9

why I am unable to pass parameter variable "pckg"

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-07-31 17:11:51 -0600

GregLarkin gravatar image

The params hash is only for defining values of class parameters, not variable values inside of a class.

edit flag offensive delete link more


Thanks or the update. but how we can assign varialbe in rspec-puppet

Chutki gravatar imageChutki ( 2015-08-03 11:26:49 -0600 )edit

I don't see a way to do it in the rspec language.

GregLarkin gravatar imageGregLarkin ( 2015-08-03 15:01:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-07-31 08:02:21 -0600

Seen: 499 times

Last updated: Jul 31 '15