Show method docs for Foo() and class docs for Foo

This commit is contained in:
Danielle Sucher 2013-09-06 14:58:12 -07:00
parent a67bf8b3b8
commit 858f7d3b88
2 changed files with 10 additions and 4 deletions

View File

@ -119,10 +119,10 @@ class Pry
return nil if str.to_s.empty?
obj = case str
when /::(?:\S+)\Z/
Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target)
when /\S+\(\)\z/
Pry::Method.from_str(str.sub(/\(\)\z/, ''),target) || Pry::WrappedModule.from_str(str, target)
else
Pry::Method.from_str(str,target) || Pry::WrappedModule.from_str(str, target)
Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target)
end
lookup_super(obj, super_level)

View File

@ -244,8 +244,14 @@ describe Pry::CodeObject do
Object.remove_method(:ClassyWassy)
end
it 'should look up methods before classes (at top-level)' do
it 'should look up classes before methods (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy", @p)
m.is_a?(Pry::WrappedModule).should == true
m.source.should =~ /piggy/
end
it 'should look up methods before classes when ending in () (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy()", @p)
m.is_a?(Pry::Method).should == true
m.source.should =~ /ducky/
end