Sha256: 7c356b7bd8098498f017aebd88e2a9285dd0a066cd7811ad377b125c81de185f

Contents?: true

Size: 668 Bytes

Versions: 15

Compression:

Stored size: 668 Bytes

Contents

require "spec_helper"

describe Mongoid::Factory do

  describe ".build" do

    context "when the _type attribute is present" do

      before do
        @attributes = { "_type" => "Person", "title" => "Sir" }
      end

      it "instantiates based on the type" do
        person = Mongoid::Factory.build(Person, @attributes)
        person.title.should == "Sir"
      end
    end

    context "when _type is not preset" do

      before do
        @attributes = { "title" => "Sir" }
      end

      it "instantiates based on the type" do
        person = Mongoid::Factory.build(Person, @attributes)
        person.title.should == "Sir"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
mongoid-locomotive-2.0.0.beta9 spec/unit/mongoid/factory_spec.rb
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/factory_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/factory_spec.rb
mongoid-1.2.14 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.13 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.12 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.11 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.10 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.9 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.8 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.7 spec/unit/mongoid/factory_spec.rb
mongoid-pre-2.0.0.pre spec/unit/mongoid/factory_spec.rb
mongoid-1.2.6 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.5 spec/unit/mongoid/factory_spec.rb
mongoid-1.2.4 spec/unit/mongoid/factory_spec.rb