From f6520da3e1ce2770e4974ff92097528ec59946fa Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 2 Nov 2011 16:13:32 -0700 Subject: [PATCH] Fix Class/Module confusion --- lib/pry/method.rb | 2 +- test/test_default_commands/test_ls.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pry/method.rb b/lib/pry/method.rb index 96ac7289..ff62ebc8 100644 --- a/lib/pry/method.rb +++ b/lib/pry/method.rb @@ -132,7 +132,7 @@ class Pry # This is required to introspect methods on objects like Net::HTTP::Get that # have overridden the `method` method. def safe_send(obj, method, *args, &block) - (Class === obj ? Class : Object).instance_method(method).bind(obj).call(*args, &block) + (Module === obj ? Module : Object).instance_method(method).bind(obj).call(*args, &block) end # Get the singleton classes of superclasses that could define methods on diff --git a/test/test_default_commands/test_ls.rb b/test/test_default_commands/test_ls.rb index c7b2b765..8eb9c942 100644 --- a/test/test_default_commands/test_ls.rb +++ b/test/test_default_commands/test_ls.rb @@ -81,6 +81,12 @@ describe "ls" do end end + describe "when inside Modules" do + it "should still work" do + mock_pry("cd Module.new{ def foobie; end }", "ls -M").should =~ /foobie/ + end + end + describe "constants" do it "should show constants defined on the current module" do mock_pry("class TempFoo1; BARGHL = 1; end", "ls TempFoo1").should =~ /BARGHL/