Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Follow MRI r34582 as commit 51a1c39

* vm_method.c (rb_method_boundp):
  obj.respond_to?(:a_protected_method) should return false because
  calling a protected method may cause NoMethodError if called
  from outside the class inheritance tree.  Kernel#respond_to? is
  mostly used to test if it is safe to call a method, so the false
  positive should be avoided. [ruby-dev:40461] [ruby-dev:41739]
  [ruby-dev:41837]
  • Loading branch information...
commit aec50a8482eb6fb8ba2e7a6bbf9ae549111c9c52 1 parent 1911e03
@nurse nurse authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 library/weakref/send_spec.rb
View
15 library/weakref/send_spec.rb
@@ -27,9 +27,18 @@ class << self
wr.delegated_method.should == :result
end
- it "delegates to protected methods of the weakly-referenced object" do
- wr = WeakRef.new(WeakRefSpecs)
- wr.protected_method.should == :result
+ ruby_version_is ""..."2.0" do
+ it "delegates to protected methods of the weakly-referenced object" do
+ wr = WeakRef.new(WeakRefSpecs)
+ wr.protected_method.should == :result
+ end
+ end
+
+ ruby_version_is "2.0" do
+ it "delegates to protected methods of the weakly-referenced object" do
+ wr = WeakRef.new(WeakRefSpecs)
+ lambda { wr.protected_method }.should raise_error(NameError)
+ end
end
it "does not delegate to private methods of the weakly-referenced object" do
Please sign in to comment.
Something went wrong with that request. Please try again.