1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Handle weird objects that return nil on inspect

This commit is contained in:
Mike Dvorkin 2010-10-12 22:52:53 -07:00
parent c05a6abad7
commit 75700ea330
2 changed files with 13 additions and 1 deletions

View file

@ -140,7 +140,7 @@ class AwesomePrint
# Catch all method to format an arbitrary object. # Catch all method to format an arbitrary object.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def awesome_self(object, appear = {}) def awesome_self(object, appear = {})
colorize(object.inspect << appear[:with].to_s, appear[:as] || declassify(object)) colorize(object.inspect.to_s << appear[:with].to_s, appear[:as] || declassify(object))
end end
# Dispatcher that detects data nesting and invokes object-aware formatter. # Dispatcher that detects data nesting and invokes object-aware formatter.

View file

@ -405,4 +405,16 @@ EOS
end end
#------------------------------------------------------------------------------
describe "Misc" do
it "handle weird objects that return nil on inspect" do
weird = Class.new do
def inspect
nil
end
end
weird.new.ai(:plain => true).should == ''
end
end
end end