Hi everyone,

thanks all for your answers but i'm starting to think that there is way to
pass puppet "undef" value from a rspec test...
If anybody has the solution to fix this test suite (
https://github.com/riton/puppetrspec) please tell me; otherwise I'll have
to rewrite my manifests and replace the puppet "undef" value with a simple
"undef" string where it is possible...

It doesn't have the same meaning but it can help me moving on with my test
suite.

Thaks.

RĂ©mi


On Tue, Apr 22, 2014 at 12:57 PM, Nan Liu <nan....@gmail.com> wrote:

> On Tue, Apr 22, 2014 at 4:34 AM, Remi Ferrand <
> remi.mathieu.ferr...@gmail.com> wrote:
>
>> Hi Nan,
>>
>> thanks for your answer.
>> With this modification:
>>
>> diff --git a/spec/classes/puppetrspec_spec.rb
>> b/spec/classes/puppetrspec_spec.rb
>> index 9d06d79..80fae58 100644
>> --- a/spec/classes/puppetrspec_spec.rb
>> +++ b/spec/classes/puppetrspec_spec.rb
>> @@ -22,7 +22,7 @@ describe 'puppetrspec', :type => :class do
>>      context 'with ensure undef' do
>>
>>          let :params do {
>> -            :ensure     => '# WHAT SHOULD WE USE HERE TO PASS PUPPET
>> undef VALUE ?#'
>> +            :ensure     =>  :undef
>>          } end
>>
>>          it 'should have File with ensure absent' do
>>
>>
>> it fails with this error:
>>
>> % rake spec
>> /usr/bin/ruby -S rspec spec/classes/puppetrspec_spec.rb --color
>> .F
>>
>> Failures:
>>
>>   1) puppetrspec with ensure undef should have File with ensure absent
>>      Failure/Error: should contain_file(filename).with_ensure('absent')
>>      Puppet::Error:
>>        Could not parse for environment production: Syntax error at ':';
>> expected '}' at line 4 on node ...
>>      # ./spec/classes/puppetrspec_spec.rb:30
>>
>> Finished in 1.51 seconds
>> 2 examples, 1 failure
>>
>> Failed examples:
>>
>> rspec ./spec/classes/puppetrspec_spec.rb:29 # puppetrspec with ensure
>> undef should have File with ensure absent
>>
>>
>> Same error with this modification:
>>
>> diff --git a/spec/classes/puppetrspec_spec.rb
>> b/spec/classes/puppetrspec_spec.rb
>> index 9d06d79..63faa11 100644
>> --- a/spec/classes/puppetrspec_spec.rb
>> +++ b/spec/classes/puppetrspec_spec.rb
>> @@ -21,9 +21,9 @@ describe 'puppetrspec', :type => :class do
>>
>>      context 'with ensure undef' do
>>
>> -        let :params do {
>> -            :ensure     => '# WHAT SHOULD WE USE HERE TO PASS PUPPET
>> undef VALUE ?#'
>> -        } end
>> +        let(:params) {{
>> +            :ensure     =>  :undef
>> +        }}
>>
>>
>> If you have any other idea, let me know :-)
>>
>
> So internally it appears to be :undef, and I thought that would work for
> rspec, but clearly not.
>
> https://github.com/puppetlabs/puppet/blob/master/spec/unit/parser/ast/leaf_spec.rb#L101
>
> Trying to set it to Puppet::Parser::AST::Undef resulted in the wrong
> behavior with "if $var {...}". I may have mixed this up with a puppet
> function where I needed to return undef. I guess I shouldn't count on my
> memory at this hour of the day.
>
> Nan
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Puppet Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/puppet-users/6nL2eROH8is/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CACqVBqBGogT4Fig6fsH5drRjyRPyJcTmnkxBYh2gSOYyfutaUg%40mail.gmail.com<https://groups.google.com/d/msgid/puppet-users/CACqVBqBGogT4Fig6fsH5drRjyRPyJcTmnkxBYh2gSOYyfutaUg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMTZwM%2B%2BWXCWeijX%3DRJs%3DVoeRs7apQY4CypePLGp%2B1mJQZ9aoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to