diff --git a/lib/pry/wrapped_module.rb b/lib/pry/wrapped_module.rb index 266db281..fc265a39 100644 --- a/lib/pry/wrapped_module.rb +++ b/lib/pry/wrapped_module.rb @@ -121,7 +121,11 @@ class Pry # Is this a singleton class? # @return [Boolean] def singleton_class? - wrapped != Pry::Method.safe_send(wrapped, :ancestors).first + if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?) + Pry::Method.safe_send(wrapped, :singleton_class?) + else + wrapped != Pry::Method.safe_send(wrapped, :ancestors).first + end end # Is this strictly a module? (does not match classes) diff --git a/spec/commands/ls_spec.rb b/spec/commands/ls_spec.rb index d051389c..52385fb1 100644 --- a/spec/commands/ls_spec.rb +++ b/spec/commands/ls_spec.rb @@ -161,12 +161,12 @@ describe "ls" do describe "grep" do it "should reduce the number of outputted things" do - pry_eval("ls -c").should =~ /ArgumentError/ - pry_eval("ls -c --grep Run").should.not =~ /ArgumentError/ + pry_eval("ls -c Object").should =~ /ArgumentError/ + pry_eval("ls -c Object --grep Run").should.not =~ /ArgumentError/ end it "should still output matching things" do - pry_eval("ls -c --grep Run").should =~ /RuntimeError/ + pry_eval("ls -c Object --grep Run").should =~ /RuntimeError/ end end