spec/integration/ripple/associations_spec.rb in ripple-0.8.0 vs spec/integration/ripple/associations_spec.rb in ripple-0.8.1

- old
+ new

@@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. require File.expand_path("../../../spec_helper", __FILE__) describe "Ripple Associations" do + require 'support/test_server' + before :all do - Object.module_eval do + Object.module_eval do class User include Ripple::Document one :profile many :addresses property :email, String, :presence => true @@ -35,29 +37,29 @@ property :kind, String, :presence => true embedded_in :user end end end - + before :each do @user = User.new(:email => 'riak@ripple.com') @profile = Profile.new(:name => 'Ripple') @billing = Address.new(:street => '123 Somewhere Dr', :kind => 'billing') @shipping = Address.new(:street => '321 Anywhere Pl', :kind => 'shipping') @friend1 = User.create(:email => "friend@ripple.com") @friend2 = User.create(:email => "friend2@ripple.com") end - + it "should save one embedded associations" do @user.profile = @profile @user.save @found = User.find(@user.key) @found.profile.name.should == 'Ripple' @found.profile.should be_a(Profile) @found.profile.user.should == @found end - + it "should save many embedded associations" do @user.addresses << @billing << @shipping @user.save @found = User.find(@user.key) @found.addresses.count.should == 2 @@ -69,11 +71,11 @@ @ship.user.should == @found @bill.should be_a(Address) @ship.should be_a(Address) end - it "should save a many linked association" do + it "should save a many linked association" do @user.friends << @friend1 << @friend2 @user.save @user.should_not be_new_record @found = User.find(@user.key) @found.friends.map(&:key).should include(@friend1.key) @@ -85,17 +87,17 @@ @user.save @user.should_not be_new_record @found = User.find(@user.key) @found.emergency_contact.key.should == @friend1.key end - + after :each do User.destroy_all end after :all do Object.send(:remove_const, :User) Object.send(:remove_const, :Profile) Object.send(:remove_const, :Address) end - + end