diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-07 03:56:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-07 03:56:16 +0000 |
commit | 84833bd60a00a5f1078b3c3b54f0d0b1e44e0dea (patch) | |
tree | 113d5e5a5eac14acbc523805cf2b6151c2af92c8 /test | |
parent | a7d99c7490ecb35c38c6336e7ad44db9b678e83d (diff) | |
download | ruby-84833bd60a00a5f1078b3c3b54f0d0b1e44e0dea.tar.gz |
assert_not_respond_to private method
* test/lib/test/unit/assertions.rb (assert_not_respond_to): allow
private flag as well as assert_respond_to.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/test/unit/assertions.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb index c98e1ade58..ae8327f89a 100644 --- a/test/lib/test/unit/assertions.rb +++ b/test/lib/test/unit/assertions.rb @@ -376,6 +376,29 @@ EOT end # :call-seq: + # assert_not_respond_to( object, method, failure_message = nil ) + # + #Tests if the given Object does not respond to +method+. + # + #An optional failure message may be provided as the final argument. + # + # assert_not_respond_to("hello", :reverse) #Fails + # assert_not_respond_to("hello", :does_not_exist) #Succeeds + def assert_not_respond_to(obj, (meth, *priv), msg = nil) + unless priv.empty? + msg = message(msg) { + "Expected #{mu_pp(obj)} (#{obj.class}) to not respond to ##{meth}#{" privately" if priv[0]}" + } + return assert obj.respond_to?(meth, *priv), msg + end + #get rid of overcounting + if caller_locations(1, 1)[0].path.start_with?(MINI_DIR) + return unless obj.respond_to?(meth) + end + refute_respond_to(obj, meth, msg) + end + + # :call-seq: # assert_send( +send_array+, failure_message = nil ) # # Passes if the method send returns a true value. |