Merge pull request #1811 from pry/redefined-respond-to-fix
core_extensions: make '__binding__' work with redefined #respond_to?
This commit is contained in:
commit
d9650b2cdb
|
@ -87,7 +87,7 @@ class Object
|
|||
return class_eval("binding")
|
||||
end
|
||||
|
||||
unless respond_to?(:__pry__)
|
||||
unless self.class.method_defined?(:__pry__)
|
||||
# The easiest way to check whether an object has a working singleton class
|
||||
# is to try and define a method on it. (just checking for the presence of
|
||||
# the singleton class gives false positives for `true` and `false`).
|
||||
|
|
|
@ -250,4 +250,10 @@ describe 'cd' do
|
|||
it 'should be able to cd into the Object BasicObject' do
|
||||
expect { @t.eval 'cd BasicObject.new' }.to_not raise_error
|
||||
end
|
||||
|
||||
# https://github.com/pry/pry/issues/1596
|
||||
it "can cd into objects that redefine #respond_to? to return true" do
|
||||
expect { @t.eval('cd Class.new { def respond_to?(m) true end }.new') }
|
||||
.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue