diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index fd7b1e7f..e5a4599d 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -351,7 +351,7 @@ class Pry # @param [Object] target The object to get a `Binding` object for. # @return [Binding] The `Binding` object. def self.binding_for(target) - if target.is_a?(Binding) + if Binding === target target else if TOPLEVEL_BINDING.eval('self') == target diff --git a/test/test_default_commands/test_cd.rb b/test/test_default_commands/test_cd.rb new file mode 100644 index 00000000..c1774e7a --- /dev/null +++ b/test/test_default_commands/test_cd.rb @@ -0,0 +1,16 @@ +require 'helper' + +describe 'Pry::DefaultCommands::CD' do + describe 'cd' do + # Regression test for ticket #516. + #it 'should be able to cd into the Object BasicObject.' do + # mock_pry('cd BasicObject.new').should.not =~ /\Aundefined method `__binding__'/ + #end + + # Regression test for ticket #516 + # Possibly move higher up. + it 'should not fail with undefined BasicObject#is_a?' do + mock_pry('cd BasicObject.new').should.not =~ /undefined method `is_a\?'/ + end + end +end