spec/collection_spec.rb in kissifer-hash-persistent-0.2.1 vs spec/collection_spec.rb in kissifer-hash-persistent-0.2.2
- old
+ new
@@ -181,10 +181,31 @@
CollectedResource.find("fred").delete
CollectedResource.find("barney").delete
CollectionFoo.find("the_basis").should == nil
end
+
+ it "should be helpful and derefence its keys when asked" do
+ CollectionFoo.persist_to({}, "")
+ CollectedResource.persist_to({}, "")
+
+ CollectionFoo.attach(CollectedResource, :basis)
+ resource_1 = CollectedResource.new
+ resource_1.basis = "the_basis"
+ resource_1.key = "fred"
+ resource_1.save
+
+ CollectionFoo.find("the_basis").collected_resources.should == [resource_1]
+
+ resource_2 = CollectedResource.new
+ resource_2.basis = "the_basis"
+ resource_2.key = "barney"
+ resource_2.save
+
+ CollectionFoo.find("the_basis").collected_resources.should == [resource_1, resource_2]
+
+ end
end
context "(concurrent access)" do
it "should be careful when creating and updating the collection resources"
# Cases to cover here...