1 require File.join( File.dirname(__FILE__), "..", "spec_helper" )
5 DataMapper.auto_migrate!
9 describe "associations" do
10 it "should belong to a country" do
12 state.should respond_to(:country)
13 state.country.states.should include(state)
14 state.should respond_to(:country=)
15 state.should respond_to(:country_code)
20 State.auto_migrate! # clear db table
23 it "should have a composite key, made up of ISO 3166-1 alpha-2 country code
24 and state abbreviation" do
25 maine = State.new(:country_code => "US", :abbr => "ME", :name => "Maine")
26 alaska = State.new(:country_code => "US", :abbr => "AK", :name => "Alaska")
27 bremen = State.new(:country_code => "DE", :abbr => "HB", :name => "Bremen")
33 #State["US", "AK"] ## FIXME
34 alaska = State.get("US", "AK")
35 alaska.should_not be_nil
36 alaska.key.first.should == "US"
37 alaska.key.last.should == "AK"
38 alaska.name.should == "Alaska"
40 #bremen = State["DE", "HB"] ## FIXME
41 bremen = State.get("DE", "HB")
42 bremen.should_not be_nil
43 bremen.key.should == ["DE", "HB"]
44 bremen.name.should == "Bremen"