Sha256: f69adc4e66a4f336b78161ddf4eba2cfa873ce5500a3bbe5596db5e5bb233227
Contents?: true
Size: 1.24 KB
Versions: 27
Compression:
Stored size: 1.24 KB
Contents
require File.join(File.dirname(__FILE__), "/../../../spec_helper.rb") describe Mongoid::Associations::Factory do describe "#create" do before do @document = Person.new end context "when type is has_many" do it "returns a HasManyAssociationProxy" do association = Mongoid::Associations::Factory.create(:has_many, :addresses, @document) association.should be_a_kind_of(Mongoid::Associations::HasManyAssociation) end end context "when type is has_one" do it "returns a HashOneAssociationProxy" do association = Mongoid::Associations::Factory.create(:has_one, :name, @document) association.should be_a_kind_of(Mongoid::Associations::HasOneAssociation) end end context "when type is belongs_to" do it "returns a BelongsToAssociationProxy" do association = Mongoid::Associations::Factory.create(:belongs_to, :person, @document) association.should be_a_kind_of(Mongoid::Associations::BelongsToAssociation) end end context "when type is invalid" do it "raises an InvalidAssociationError" do lambda { Mongoid::Associations::Factory.create(:something, :person, @document) }.should raise_error end end end end
Version data entries
27 entries across 27 versions & 1 rubygems