mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
:undefined when key type is not specified, test
This commit is contained in:
parent
cf2839c0d7
commit
75c6868e45
2 changed files with 15 additions and 1 deletions
|
@ -44,7 +44,7 @@ module AwesomePrintMongoMapper
|
|||
return object.inspect if !defined?(ActiveSupport::OrderedHash) || !object.respond_to?(:keys)
|
||||
|
||||
data = object.keys.inject(ActiveSupport::OrderedHash.new) do |hash, c|
|
||||
hash[c.first] = c.last.type.to_s.underscore.intern
|
||||
hash[c.first] = (c.last.type || "undefined").to_s.underscore.intern
|
||||
hash
|
||||
end
|
||||
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
||||
|
|
|
@ -38,6 +38,20 @@ class User < Object {
|
|||
"last_name" => :string,
|
||||
"first_name" => :string
|
||||
}
|
||||
EOS
|
||||
end
|
||||
|
||||
it "should print for a class when type is undefined" do
|
||||
class Chamelion
|
||||
include MongoMapper::Document
|
||||
key :last_attribute
|
||||
end
|
||||
|
||||
@ap.send(:awesome, Chamelion).should == <<-EOS.strip
|
||||
class Chamelion < Object {
|
||||
"_id" => :object_id,
|
||||
"last_attribute" => :undefined
|
||||
}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue