Forum: RSpec expecting one of two conditions

40a3939023ef722e64e4c255d6d5bcd9?d=identicon&s=25 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
This topic is locked and can not be replied to.