spec/dynamoid/associations/belongs_to_spec.rb in dynamoid-0.2.0 vs spec/dynamoid/associations/belongs_to_spec.rb in dynamoid-0.3.0

- old
+ new

@@ -3,15 +3,21 @@ describe "Dynamoid::Associations::BelongsTo" do context 'has many' do before do @subscription = Subscription.create + @camel_case = CamelCase.create end - it 'determins nil if it has no associated record' do + it 'determines nil if it has no associated record' do @subscription.magazine.should be_nil end + + it 'determines target association correctly' do + @camel_case.magazine.send(:target_association).should == :camel_cases + end + it 'delegates equality to its source record' do @magazine = @subscription.magazine.create @subscription.magazine.should == @magazine @@ -20,10 +26,15 @@ it 'associates has_many automatically' do @magazine = @subscription.magazine.create @magazine.subscriptions.size.should == 1 @magazine.subscriptions.should include @subscription + + @magazine = Magazine.create + @user = @magazine.owner.create + @user.books.size.should == 1 + @user.books.should include @magazine end it 'behaves like the object it is trying to be' do @magazine = @subscription.magazine.create @@ -34,10 +45,11 @@ end context 'has one' do before do @sponsor = Sponsor.create + @subscription = Subscription.create end it 'determins nil if it has no associated record' do @sponsor.magazine.should be_nil end @@ -51,8 +63,11 @@ it 'associates has_one automatically' do @magazine = @sponsor.magazine.create @magazine.sponsor.size.should == 1 @magazine.sponsor.should == @sponsor + + @user = @subscription.customer.create + @user.monthly.should == @subscription end end end