1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Avoid loop in weird method locator

This commit is contained in:
Juan Barreneche 2015-03-17 18:46:45 -03:00
parent 5eb4e23dd8
commit c2ed9ec135
2 changed files with 25 additions and 1 deletions

View file

@ -104,8 +104,10 @@ class Pry
# TODO: Fix up the exception handling so we don't need a bare rescue # TODO: Fix up the exception handling so we don't need a bare rescue
if normal_method?(guess) if normal_method?(guess)
return guess return guess
else elsif guess != guess.super
guess = guess.super guess = guess.super
else
break
end end
end end

View file

@ -41,6 +41,27 @@ describe "whereami" do
Object.remove_const(:Cor) Object.remove_const(:Cor)
end end
if RUBY_VERSION > "2.0.0"
it 'should work with prepended methods' do
module Cor2
def blimey!
super
end
end
class Cor
prepend Cor2
def blimey!
pry_eval(binding, 'whereami').should =~ /Cor2[#]blimey!/
end
end
Cor.new.blimey!
Object.remove_const(:Cor)
Object.remove_const(:Cor2)
end
end
it 'should work in BasicObjects' do it 'should work in BasicObjects' do
cor = Class.new(BasicObject) do cor = Class.new(BasicObject) do
def blimey! def blimey!
@ -230,4 +251,5 @@ describe "whereami" do
it "should work inside an object" do it "should work inside an object" do
expect(pry_eval(Object.new, 'whereami')).to match(/Inside #<Object/) expect(pry_eval(Object.new, 'whereami')).to match(/Inside #<Object/)
end end
end end