Sha256: 4635dc8fec40262e120a6770de4e8974c71333e34f9a574d31c483b3c8850de0

Contents?: true

Size: 1.91 KB

Versions: 41

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

module MongoModel
  specs_for(Document, EmbeddedDocument) do
    describe "#inspect" do
      context "on base class" do
        it "should return class name" do
          described_class.inspect.should == described_class.name
        end
      end
      
      context "on subclasses" do
        context "without properties" do
          define_class(:TestDocument, described_class)
      
          it "should return class name" do
            TestDocument.inspect.should == 'TestDocument()'
          end
        end
      
        context "with properties" do
          define_class(:TestDocument, described_class) do
            property :name, String
            property :age, Integer
          end
        
          it "should return class name and property definitions" do
            TestDocument.inspect.should == 'TestDocument(name: String, age: Integer)'
          end
        end
      end
    end
  end
  
  specs_for(Document) do
    describe "#inspect" do
      context "on subclass instances" do
        define_class(:TestDocument, Document) do
          property :name, String
          property :age, Integer
        end
      
        subject { TestDocument.new(:id => 'abc-123', :name => 'Doc name', :age => 54) }
  
        it "should return class name and property values" do
          subject.inspect.should == '#<TestDocument id: abc-123, name: "Doc name", age: 54>'
        end
      end
    end
  end
  
  specs_for(EmbeddedDocument) do
    describe "#inspect" do
      context "on subclass instances" do
        define_class(:TestDocument, EmbeddedDocument) do
          property :name, String
          property :age, Integer
        end
      
        subject { TestDocument.new(:name => 'Doc name', :age => 54) }
  
        it "should return class name and property values" do
          subject.inspect.should == '#<TestDocument name: "Doc name", age: 54>'
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
mongomodel-0.4.6 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.5 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.4 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.3 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.2 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.1 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.4.0 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.6 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.5 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.4 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.3 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.2 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.1 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.3.0 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.20 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.19 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.18 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.17 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.16 spec/mongomodel/concerns/pretty_inspect_spec.rb
mongomodel-0.2.15 spec/mongomodel/concerns/pretty_inspect_spec.rb