Hi Martin,

Thanks for that. It worked a treat.

I just did some simple validation in the end.

     yaml_object = YAML.load(content)
     expect(yaml_object.length).to be > 0

I validate the content elsewhere but this is just an a basic check that 
it's able to parse it. I have been using regexp to validate the content up 
to now so I suppose I could move to using this yaml module to check that as 
well.

john

On Tuesday, 10 November 2015 12:02:09 UTC, Martin Alfke wrote:
>
> Hi, 
> On 06 Nov 2015, at 14:38, choffee <[email protected] <javascript:>> wrote: 
>
> > I have a define which takes a yaml file as a parameter and want to check 
> that my template creates valid yaml. 
> > 
> > I am currently using regexp to test bits of it like so 
> > 
> >   should contain_mydefine('foo').with_yaml_content(/---\s+-part1/m) 
>
> You can directly access the content attribute: 
>
> content = catalogue.resource(‘mydefine', 
> ‘foo').send(:parameters)[:content] 
>
> Then you can use default spec matchers for checking what is in local 
> variable content. 
> I am unsure how to check for valid yaml. 
>
> Best, 
> Martin 
>
>
>
> > 
> > It would be nice to be able to do 
> > 
> >   should contain_mydefine('foo').with_yaml_content.valid_yaml() 
> > 
> > Is there a simple way to check this? 
> > 
> > As an alternative, if I assign the yaml to a local available is there a 
> way in rspec to check that value? 
> > 
> > Thanks 
> > 
> > john 
> > 
> > -- 
> > 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] <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/79782f5f-f006-4094-a29e-3414ea7ba5c8%40googlegroups.com.
>  
>
> > 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3d644c62-1fa3-42c0-80af-5e639e52e0b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to