Forum: RSpec expecting one of two conditions

Posted by Fearless Fool (fearless_fool)
on 2013-03-10 00:20
I'm expecting my_test to raise one error or another, but since I'm
pulling data from a db, I don't know which error it will be.  Is there a
better way to write this?

expect { my_test }.to raise_error { |error|
  error.should satisfy {|e|
    e.instance_of?(OneError) || e.instance_of?(OtherError)
  }
}

?

I'm not complaining, mind you -- I'm really impressed that RSpec lets me
test for such specific pathology!  I'm just wondering if there's another
matcher that won't be quite so verbose.

- ff
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.