summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpag <rpag@singletonclass.com>2015-01-14 11:39:10 +0000
committerrpag <rpag@singletonclass.com>2015-01-14 11:39:10 +0000
commitcc263124de5d174eb4ca6a872798e028d4afd70e (patch)
tree486db0d743866ac71f0e188f35c61e0d87df510d
parente4aa4da07ebcd2f95ff0392eb73d13776f026675 (diff)
downloadpry-basicobj-inspect.tar.gz
add tests that cover Object subclassesbasicobj-inspect
-rw-r--r--spec/color_printer_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/color_printer_spec.rb b/spec/color_printer_spec.rb
index 9b073a6a..78fa6f2f 100644
--- a/spec/color_printer_spec.rb
+++ b/spec/color_printer_spec.rb
@@ -12,6 +12,37 @@ describe Pry::ColorPrinter do
end
end
+ describe 'Object subclass' do
+ before do
+ class ObjectF < Object
+ def inspect
+ 'foo'
+ end
+ end
+
+ class ObjectG < Object
+ def inspect
+ raise
+ end
+ end
+ end
+
+ after do
+ Object.send :remove_const, :ObjectF
+ Object.send :remove_const, :ObjectG
+ end
+
+ it 'prints a string' do
+ Pry::ColorPrinter.pp(ObjectF.new, io)
+ expect(str).to eq('foo')
+ end
+
+ it 'prints a string, even when an exception is raised' do
+ Pry::ColorPrinter.pp(ObjectG.new, io)
+ expect(str).to match(/\A#<ObjectG:0x\w+>\z/)
+ end
+ end
+
describe 'BasicObject' do
it 'prints a string' do
Pry::ColorPrinter.pp(BasicObject.new, io)