Permalink
Browse files

Updating inspection formatting

  • Loading branch information...
1 parent 1d6dbe3 commit 338126fe83cc6db4c82a27ef3f40786897a0c439 @durran durran committed Dec 26, 2009
Showing with 14 additions and 1 deletion.
  1. +2 −1 lib/mongoid/document.rb
  2. +12 −0 spec/integration/mongoid/document_spec.rb
View
3 lib/mongoid/document.rb
@@ -192,7 +192,8 @@ def initialize(attrs = {})
# Returns the class name plus its attributes.
def inspect
- "#{self.class.name} : #{@attributes.inspect}"
+ attrs = @attributes.map { |key, value| "#{key}: #{value}" } * ", "
+ "#<#{self.class.name} #{attrs}>"
end
# Returns true is the +Document+ has not been persisted to the database,
View
12 spec/integration/mongoid/document_spec.rb
@@ -190,6 +190,18 @@
end
+ describe "#inspect" do
+
+ before do
+ @person = Person.new
+ end
+
+ it "returns a pretty string of class name and attributes" do
+ @person.inspect.should == "#<Person _id: #{@person.id}, age: #{@person.age}>"
+ end
+
+ end
+
describe "#paginate" do
before do

0 comments on commit 338126f

Please sign in to comment.