Sha256: 08e63a538c2364c3e260f55e902a2accbeb70f288836cc4321e8922a0626debb

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe "references" do

  it "should handle complex transitions" do

    @vegetable.foods.count.should == 0
    @fruit.foods.count.should == 0
    @onion.category.should be_nil

    @vegetable.foods << @onion

    @vegetable.foods.count.should == 1
    @vegetable.foods.first.should == @onion
    @fruit.foods.count.should == 0
    @onion.category.should == @vegetable

    @fruit.foods << @onion

    @vegetable.foods.count.should == 0
    @fruit.foods.count.should == 1
    @fruit.foods.first.should == @onion
    @onion.category.should == @fruit

    @onion.category = nil

    @vegetable.foods.count.should == 0
    @fruit.foods.count.should == 0
    @onion.category.should be_nil

    @onion.category = @vegetable

    @vegetable.foods.count.should == 1
    @vegetable.foods.first.should == @onion
    @fruit.foods.count.should == 0
    @onion.category.should == @vegetable

    @vegetable.foods = [ @apple, @lemon, @lemon ]
    @vegetable.foods << @apple
    @vegetable.foods.count.should == 2
    @vegetable.foods.should be_include @apple
    @vegetable.foods.should be_include @lemon
    @apple.category.should == @vegetable
    @lemon.category.should == @vegetable
    @onion.category.should == nil

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blendris-1.2 spec/ref_spec.rb
blendris-1.1 spec/ref_spec.rb
blendris-1.0 spec/ref_spec.rb
blendris-0.6 spec/ref_spec.rb