summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-30 18:56:59 +0900
committerGitHub <[email protected]>2017-08-30 18:56:59 +0900
commit71357ff1d8bd6ec0b3e7cce364c2513d6d3f7a77 (patch)
tree0311111f9c5352e4b7174467aad8bb9febe9d0e9 /test
parentfe3227cd5c7e3a05923eb9e430cc60c6808759bb (diff)
parentbf32265743b92f51482f7fca7212535d40a7cf3c (diff)
downloadmruby-71357ff1d8bd6ec0b3e7cce364c2513d6d3f7a77.tar.gz
mruby-71357ff1d8bd6ec0b3e7cce364c2513d6d3f7a77.zip
Merge pull request #3801 from christopheraue/assert_raise_refactoring
Allowed to pass multiple exceptions to assert_raise
Diffstat (limited to 'test')
-rw-r--r--test/assert.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/assert.rb b/test/assert.rb
index 6760ae0a7..fb7ae9ab8 100644
--- a/test/assert.rb
+++ b/test/assert.rb
@@ -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"