[rspec-users] expecting one of two conditions

Fearless Fool lists at ruby-forum.com
Sat Mar 9 23:20:15 UTC 2013


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

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list