diff --git a/lib/pry/default_commands/find_method.rb b/lib/pry/default_commands/find_method.rb index f7b9cf78..f14f69e1 100644 --- a/lib/pry/default_commands/find_method.rb +++ b/lib/pry/default_commands/find_method.rb @@ -90,9 +90,7 @@ class Pry # @yieldparam klazz Each class/module in the namespace. # def recurse_namespace(klass, done={}, &block) - if done[klass] || !(Module === klass) - return - end + return if !(Module === klass) || done[klass] done[klass] = true diff --git a/test/test_default_commands/test_find_method.rb b/test/test_default_commands/test_find_method.rb index c19efbce..5ca40bd5 100644 --- a/test/test_default_commands/test_find_method.rb +++ b/test/test_default_commands/test_find_method.rb @@ -35,7 +35,15 @@ unless Pry::Helpers::BaseHelpers.mri_18? mock_pry("find-method timothy MyKlass").should.not =~ /MyKlass.*?goodbye/m end end - + + it "should work with badly behaved constants" do + MyKlass::X = Object.new + def (MyKlass::X).hash + raise "mooo" + end + + mock_pry("find-method -c timothy MyKlass").should =~ /MyKlass.*?hello/m + end end Object.remove_const(:MyKlass)