it {
should contain_package('foo').with ( {
'provider' => nil,
})
}
On 18/04/14 12:37, Remi Ferrand wrote:
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
<http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#undef>>
--
Andreas <http://blog.andreas-haerter.com
<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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/2e2b712e-cf4a-46be-941b-3303efa5d551%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/2e2b712e-cf4a-46be-941b-3303efa5d551%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________
Next Events:
Linux Training | https://www.open-future.be/linux-training-5-till-9th-may
Puppet Introduction Course |
https://www.open-future.be/puppet-introduction-course-12th-may
Puppet Fundamentals Training |
https://www.open-future.be/puppet-fundamentals-training-13-till-15th-may
Zabbix Certified Specialist |
https://www.open-future.be/zabbix-certified-specialist-training-19-till-21th-may
Zabbix Certified Professional |
https://www.open-future.be/zabbix-certified-professional-training-22-till-23rd-may
Subscribe to our newsletter | http://eepurl.com/BUG8H
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/53510EE8.5080401%40open-future.be.
For more options, visit https://groups.google.com/d/optout.