Flowdock
raise_error(error=Exception, message=nil, &block) public

With no args, matches if any error is raised. With a named error, matches only if that specific error is raised. With a named error and messsage specified as a String, matches only if both match. With a named error and messsage specified as a Regexp, matches only if both match. Pass an optional block to perform extra verifications on the exception matched

Examples

  lambda { do_something_risky }.should raise_error
  lambda { do_something_risky }.should raise_error(PoorRiskDecisionError)
  lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) { |error| error.data.should == 42 }
  lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, "that was too risky")
  lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, /oo ri/)

  lambda { do_something_risky }.should_not raise_error
  lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError)
  lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, "that was too risky")
  lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, /oo ri/)
Show source
Register or log in to add new notes.