diff options
| author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 06:32:24 +0000 |
|---|---|---|
| committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 06:32:24 +0000 |
| commit | 20d4a375e2df9bde23b027581099ca5c8515950d (patch) | |
| tree | e21bb20156fbf9780c0fa1aa188446afafa541cc /test/ruby/envutil.rb | |
| parent | a2542330283e668c518dc9fc1c044959ed1cdc2a (diff) | |
merge revision(s) 43682,43727,43752,43759: [Backport #9560]
* lib/delegate.rb (Delegator#send): override to get rid of global function interference.
[Fixes GH-449]
* lib/delegate.rb (Delegator#send): separate from method_missing so
that super calls proper method.
* lib/delegate.rb (Delegator#method_missing): try private methods defined in
Kernel after the target. [Fixes GH-449]
* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
* lib/delegate.rb (DelegateClass#__getobj__): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/envutil.rb')
| -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..cfc16d1d86 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -379,6 +379,29 @@ eom AssertFile 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 + class << (AssertFile = Struct.new(:message).new) include Assertions def assert_file_predicate(predicate, *args) |
