Sha256: 2a4dff4019069f2fc65845eb5905d3884e7fc587ebf67dea19724222abbc2fb0
Contents?: true
Size: 1.53 KB
Versions: 7
Compression:
Stored size: 1.53 KB
Contents
describe "Associations" do before do MotionPrime::Store.connect end after do MotionPrime::Store.shared_store.clear end describe "#bag" do it "adds a attr reader to the class" do todo = Todo.create(:title => "Today Tasks") todo.items.is_a?(MotionPrime::Bag).should == true todo.items.size.should == 0 end it "adds a attr writer to the class that can take an Array" do todo = Todo.create(:title => "Today Tasks") todo.items = [TodoItem.new(:text => "Hi"), TodoItem.new(:text => "Foo"), TodoItem.new(:text => "Bar")] todo.items.is_a?(MotionPrime::Bag).should == true todo.items.size.should == 3 end it "adds a writer to the class that can take a Bag" do todo = Todo.create(:title => "Today Tasks") todo.items = MotionPrime::Bag.bag todo.items.is_a?(MotionPrime::Bag).should == true todo.items.size.should == 0 end end describe "#save" do it "save a model also saves associated bags" do todo = Todo.create(:title => "Today Tasks") todo.items = [TodoItem.new(:text => "Hi"), TodoItem.new(:text => "Foo"), TodoItem.new(:text => "Bar")] todo.items.is_a?(MotionPrime::Bag).should == true todo.save todo = Todo.find(:title => "Today Tasks").first todo.should.not.be.nil todo.items.is_a?(MotionPrime::Bag).should == true todo.items.key.should == todo.items.key todo.items.size.should == 3 todo.items.to_a.each do |item| item.is_a?(TodoItem).should.be.true end end end end
Version data entries
7 entries across 7 versions & 1 rubygems