Created
March 27, 2012 17:05
-
-
Save ktkaushik/2218004 to your computer and use it in GitHub Desktop.
Specs for testing MongoDB's Embedded and Referenced association with Mongoid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Client do | |
context "With valid client info" do | |
context "Associations" do | |
it "should embed many projects" do | |
association = Client.relations['projects'] | |
association.klass.should == Project | |
association.relation.should == Mongoid::Relations::Embedded::Many | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Developer do | |
describe "With valid Developer information" do | |
context "Checking Mongoid's Referenced association between project and developer" do | |
it "should be referenced in a project" do | |
association = Developer.associations['project'] | |
association.klass.should == Project | |
association.relation.should == Mongoid::Relations::Referenced::In | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Project do | |
describe "With valid Project information" do | |
context "Checking Mongoid's embedded association between project and client" do | |
it "should be embedded in a client" do | |
association = Project.associations['client'] | |
association.klass.should == Client | |
association.relation.should == Mongoid::Relations::Embedded::In | |
end | |
it "should reference many developers" do | |
association = Project.associations['developers'] | |
association.klass.should == Developer | |
association.relation.should == Mongoid::Relations::Referenced::Many | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Models specs for Embedded and Referenced association in MongoDB using Mongoid.
A Client
embeds_many :projects
Project is
embedded_in :client
whereas a Project
references_many :developers
and aDeveloper is
referenced_in :project