Allowed to pass multiple exceptions to assert_raise

This commit is contained in:
Christopher Aue
2017-08-30 11:03:51 +02:00
parent fe3227cd5c
commit bf32265743
+4 -2
View File
@@ -143,17 +143,19 @@ def assert_not_include(collection, obj, msg = nil)
assert_false(collection.include?(obj), msg, diff)
end
def assert_raise(exc, msg = nil)
def assert_raise(*exc)
return true unless $mrbtest_assert
$mrbtest_assert_idx += 1
msg = (exc.last.is_a? String) ? exc.pop : nil
begin
yield
msg ||= "Expected to raise #{exc} but nothing was raised."
diff = nil
$mrbtest_assert.push [$mrbtest_assert_idx, msg, diff]
false
rescue exc
rescue *exc
true
rescue Exception => e
msg ||= "Expected to raise #{exc}, not"