On Wed, Jul 26, 2017 at 11:59 AM, James Perry <jjperr...@gmail.com> wrote:

> Can anyone assist my confusion on how to use is_expected.to
> compile.and_raise(Puppet::Error, /some error/)?
>
> I have a class where I have fail('some error') and it is only calls class
> ABC if parameters A=1, B=2, C=3, which I am using to test this
> functionality out.
>
> If I have fail('some error') in class ABC, then all the RSPEC tests, but
> ones where classes aren't included, all fail. If I comment it out all of my
> tests pass but the one where I had compile.and_raise(/some error/).
>
> What is the proper way to cause a failure condition to be tested /
> verified in RSPEC? Am I failing the wrong way?
>
> Also why would this break the majority of the tests just by having fail in
> a child class?
>
> Thanks for everyone's continuing help here.
>

If I'm understanding you correctly, rspec is doing what it should and
pointing out that your code isn't working as expected. If your code calls
fail(), then the catalog fails to compile. The only appropriate rspec
matcher in that case is and_raise_error. Any other test is going to fail
because there's no catalog to check.

> --
> 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 puppet-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-dev/bfb280a9-b6a8-4725-817f-75385d785d1b%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-dev/bfb280a9-b6a8-4725-817f-75385d785d1b%40googlegroups.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 Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CAHTHiAHLh4Eaxv_L7o_VHiJXrgbi8D6%2BA3%3DU2hWf3MQAsfgjpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to