Expecting one of two conditions


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