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:
parent
c05a6abad7
commit
75700ea330
2 changed files with 13 additions and 1 deletions
|
@ -140,7 +140,7 @@ class AwesomePrint
|
|||
# Catch all method to format an arbitrary object.
|
||||
#------------------------------------------------------------------------------
|
||||
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
|
||||
|
||||
# Dispatcher that detects data nesting and invokes object-aware formatter.
|
||||
|
|
|
@ -405,4 +405,16 @@ EOS
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue