Hi Justin,

I think you could add an expectation on the `scope` object to check for the
method call. The puppetlabs_spec_helper gem (which is pulled in by
rspec-puppet) exposes this (
https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb#L10),
so I think you could do something like this:

    scope.expects(:function_alert).with("dummy-operating-system not
supported yet")

That might not be the exact solution but I think that you'll want to look
at adding expectations to the scope to get this done.


On Fri, Mar 1, 2013 at 7:13 AM, <[email protected]> wrote:

> I am writing rspec tests for my modules and have not been able to figure
> out how to test that a function (alert/fail specifically) has been called.
> For example:
>
>   case $::operatingsystem {
>
>     'Debian','Ubuntu': {
>       class { 'sensu::repo::apt': ensure => $ensure, repo => $repo }
>     }
>
>     'Fedora','RedHat','CentOS': {
>       class { 'sensu::repo::yum': ensure => $ensure }
>     }
>
>     default: { alert("${::operatingsystem} not supported yet") }
>
>   }
>
> I'd like to be able to verify unsupported operating systems are correctly
> flagged.  I haven't been able to find the answer with google and everyone
> in #puppet that has responded wasn't sure.
>
> Thanks,
> Justin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Adrien Thebo | Puppet Labs

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to