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

Merge branch 'show-get'

This commit is contained in:
Conrad Irwin 2013-12-11 08:45:55 -08:00
commit 2a2db1a9d6
2 changed files with 15 additions and 0 deletions

View file

@ -47,6 +47,9 @@ class Pry
elsif name.to_s =~ /(.+)\#(\S+)\Z/
context, meth_name = $1, $2
from_module(target.eval(context), meth_name, target)
elsif name.to_s =~ /(.+)(\[\])\Z/
context, meth_name = $1, $2
from_obj(target.eval(context), meth_name, target)
elsif name.to_s =~ /(.+)(\.|::)(\S+)\Z/
context, meth_name = $1, $3
from_obj(target.eval(context), meth_name, target)

View file

@ -68,6 +68,18 @@ describe Pry::Method do
meth.name.should == "hello"
end
it 'should take care of corner cases like mongo[] e.g Foo::Bar.new[]- issue 998' do
klass = Class.new { def []; :hello; end }
meth = Pry::Method.from_str("klass.new[]", Pry.binding_for(binding))
meth.name.should == "[]"
end
it 'should take care of cases like $ mongo[] - issue 998' do
f = Class.new { def []; :hello; end }.new
meth = Pry::Method.from_str("f[]", Pry.binding_for(binding))
meth.name.should == "[]"
end
it 'should look up instance methods using klass.meth#method syntax' do
klass = Class.new { def self.meth; Class.new; end }
meth = Pry::Method.from_str("klass.meth#initialize", Pry.binding_for(binding))