1 require File.join( File.dirname(__FILE__), "..", "spec_helper" )
5 DataMapper.auto_migrate!
8 describe "associations" do
9 it "should belong to a shipping_info" do
10 shipping_info = ShippingInfo.gen
11 weight = Weight.gen(:shipping_info => shipping_info)
12 weight.shipping_info = shipping_info
13 weight.should be_valid
15 weight = Weight.create(Weight.gen_attrs.except(:shipping_info))
16 weight.shipping_info.should be_nil
17 weight.should be_valid
21 it "should require a min_weight, max_weight, and price" do
22 weight = Weight.create(Weight.gen_attrs.except(:min_weight))
23 weight.should_not be_valid
24 weight.errors.should include(:min_weight)
26 weight = Weight.create(Weight.gen_attrs.except(:max_weight))
27 weight.should_not be_valid
28 weight.errors.should include(:max_weight)
30 weight = Weight.create(Weight.gen_attrs.except(:price))
31 weight.should_not be_valid
32 weight.errors.should include(:price)