Ruby requires that any object passed to raise must be an exception class or
object:

2.4.3 :001 > raise Object.newTypeError: exception class/object expected
        from (irb):1:in `raise'
        from (irb):1
        from /Users/myron/.rvm/rubies/ruby-2.4.3/bin/irb:11:in `<main>'

As such, there’s no way to RSpec to be able to raise an arbitrary object.

Myron
​

On Wed, Apr 11, 2018 at 12:43 PM, Asher Shockley <daemon.shock...@gmail.com>
wrote:

> Is it possible to have a mocked method raise a mocked object instead of a
> real instance of Exception?
>
> https://gist.github.com/david-shockley-beeline/
> 008ea9122e62b051b3614d07a36fae23
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rspec+unsubscr...@googlegroups.com.
> To post to this group, send email to rspec@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/rspec/76d123cf-1fe0-4d88-b0fd-47a856253c22%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/76d123cf-1fe0-4d88-b0fd-47a856253c22%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 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rspec+unsubscr...@googlegroups.com.
To post to this group, send email to rspec@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CADUxQmv5n_2fYTHRtQpy9%3Dxeom1Cj8Mb4kUS7kQsx-a%3DM01hEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to