1 require File.join( File.dirname(__FILE__), "..", "spec_helper" )
6 DataMapper.auto_migrate!
10 describe "associations" do
11 it "should have many (0..*) states" do
12 @country.should respond_to(:states)
13 @country.states.each do |state|
14 state.country.should == @country
18 it "should have many (0..*) provinces (alias for states)" do
19 @country.should respond_to(:provinces)
23 it "should be valid when all attributes are supplied" do
24 Country.gen.should be_valid
27 it "should have a name field" do
28 Country.create(Country.gen_attrs.except(:name)).should_not be_valid
31 it "should have a unique name field" do
32 Country.create(Country.gen_attrs.merge(:name => @country.name)).should_not be_valid