diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 14:53:19 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 14:53:19 +0000 |
commit | d46cd5cfd6524cdc4a38d7dca9f65a9db0b5b15d (patch) | |
tree | 76d434f150050503729b05f8830e592994b58c55 /test/ruby | |
parent | 03da71a9ae194cb2b47318b85b47c6b1001fe1b0 (diff) |
missed at r45748.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/envutil.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 948cbc25bc..cacb609a18 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -375,6 +375,29 @@ eom assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0") end + def assert_raise_with_message(exception, expected, msg = nil, &block) + case expected + when String + assert = :assert_equal + when Regexp + assert = :assert_match + else + raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}" + end + + ex = assert_raise(exception, *msg) {yield} + msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"} + + if assert == :assert_equal + assert_equal(expected, ex.message, msg) + else + msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp ex.message}" } + assert expected =~ ex.message, msg + block.binding.eval("proc{|_|$~=_}").call($~) + end + ex + end + def assert_file AssertFile end |