expect{ some_method(params) }.to raise_error(APIException)
if you use TestUnit this should work (source)
assert_raises(APIException) { some_method(params) }
To test the exception message as well use the following:
exception = assert_raises(Exception) { whatever.merge }
assert_equal( "message", exception.message )