I was also wondering how to do this, If anyone has the answer, I'll be glad to know it !
Thanks RĂ©mi On Saturday, July 20, 2013 12:20:20 AM UTC+2, Andreas Haerter wrote: > > Hi all, > > is there a way to pass the Puppets undef [1] value as parameter? I got a > module with a package_provider parameter, allowing the user two things: > 1. specify a specific package provider to use; 2. pass "undef" to let > Puppet decide which provider to use instead of the module. > > Something like: > > > class example( > > $package_provider = $example::params::package_provider, > > ) inherits example::params { > > > > [...] > > > > package { 'foobar' > > ensure => 'present', > > provider => $package_provider, > > } > > } > > > Now I want to test if passing undef works: > > > context 'with parameter(s): package_provider => undef' do > > let(:params) {{ > > :package_provider => [WAY-TO-PASS-UNDEF-HERE], > > }} > > > > it 'contains a package with parameter(s): provider => unset' do > > should contain_package('blueprint').with({ > > 'provider' => [WAY-TO-CHECK-FOR-UNDEF-HERE, > > }) > > end > > end > > > > But my test doesn't work. What I tried so far is: > > 1) undef (results in RSpec/Ruby parsing error) > > context 'with parameter(s): foo => undef' do > > let(:params) {{ > > :foo => undef, > > }} > > > > [...] > > end > > 2) :undef (results in Puppet error: "Syntax error at':'; expected '}'" ) > > context 'with parameter(s): foo => undef' do > > let(:params) {{ > > :foo => :undef, > > }} > > > > [...] > > end > > 3) nil (does not result in an Puppet or Ruby error, but the > .with_foo(nil) or .without_foo matchers do not seem to work as the > string "nil" was passed tho puppet > > context 'with parameter(s): foo => undef' do > > let(:params) {{ > > :foo => nil, > > }} > > > > [...] > > end > > Any hints? Thanks in advance :-) > > > [1] > < > http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#undef> > > > -- > Andreas <http://blog.andreas-haerter.com> > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/2e2b712e-cf4a-46be-941b-3303efa5d551%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.