Skip to content

Instantly share code, notes, and snippets.

@alexmchale
Created February 10, 2010 03:18
Show Gist options
  • Save alexmchale/299990 to your computer and use it in GitHub Desktop.
Save alexmchale/299990 to your computer and use it in GitHub Desktop.
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment