Commit bf322657 authored by Christopher Aue's avatar Christopher Aue

Allowed to pass multiple exceptions to assert_raise

parent fe3227cd
...@@ -143,17 +143,19 @@ def assert_not_include(collection, obj, msg = nil) ...@@ -143,17 +143,19 @@ def assert_not_include(collection, obj, msg = nil)
assert_false(collection.include?(obj), msg, diff) assert_false(collection.include?(obj), msg, diff)
end end
def assert_raise(exc, msg = nil) def assert_raise(*exc)
return true unless $mrbtest_assert return true unless $mrbtest_assert
$mrbtest_assert_idx += 1 $mrbtest_assert_idx += 1
msg = (exc.last.is_a? String) ? exc.pop : nil
begin begin
yield yield
msg ||= "Expected to raise #{exc} but nothing was raised." msg ||= "Expected to raise #{exc} but nothing was raised."
diff = nil diff = nil
$mrbtest_assert.push [$mrbtest_assert_idx, msg, diff] $mrbtest_assert.push [$mrbtest_assert_idx, msg, diff]
false false
rescue exc rescue *exc
true true
rescue Exception => e rescue Exception => e
msg ||= "Expected to raise #{exc}, not" msg ||= "Expected to raise #{exc}, not"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment