[rspec-users] Specifying a Celluloid actor is still alive without a negative error expectation

Andy Lindeman andy at andylindeman.com
Tue Aug 13 12:16:28 UTC 2013

On 08/13/2013 06:58 AM, Ash Moran wrote:
> Unfortunately, as the actor is running asynchronously, the example checks the actor's alive state before it completely dies. One way to approach this is to use Celluloid's actor guarantees and send it another message, which will be handled synchronously after the first is processed, and will raise a DeadActorError:
>     it "doesn't crash the actor" do
>       actor.method_that_raises_an_error rescue nil
>       expect {
>         actor.method_that_raises_an_error
>       }.to_not raise_error(Celluloid::DeadActorError)
>     end

The problem with not_to raise_error is that it's a tad confusing. It
could be interpreted either that you meant no error at all to be raised,
or an error to be raised but not of the given type.

I'd probably write it it as a positive:

    expect { actor.method_that_raises_an_error }.to

This will fail if the error ended up being a DeadActorError or if the
method wasn't called but didn't raise an error.

Does this help at all? I hope I understood you fully.

More information about the rspec-users mailing list