spec/bag_spec.rb in nano-store-0.4.3 vs spec/bag_spec.rb in nano-store-0.5.0
- old
+ new
@@ -14,11 +14,10 @@
NanoStore.shared_store = nil
end
it "should add objects to bag" do
bag = Bag.bag
- NanoStore.shared_store.addObject(bag, error:nil)
# use << method to add object to bag
page = Page.new
page.text = "Hello"
page.index = 1
@@ -39,11 +38,10 @@
bag.changed?.should.be.false
end
it "should delete object from bag" do
bag = Bag.bag
- NanoStore.shared_store.addObject(bag, error:nil)
# use << method to add object to bag
page = Page.new
page.text = "Hello"
page.index = 1
@@ -65,17 +63,31 @@
it "should add bag to store" do
before_count = NanoStore.shared_store.bags.count
bag = Bag.bag
- NanoStore.shared_store.addObject(bag, error:nil)
# use << method to add object to bag
page = Page.new
page.text = "Hello"
page.index = 1
bag << page
bag.save
NanoStore.shared_store.bags.count.should.be == before_count + 1
+ end
+
+ describe "#to_a" do
+ it "convert a bag to array" do
+ bag = Bag.bag
+ bag << Page.new(:text => "1", :index => 1)
+ bag << Page.new(:text => "2", :index => 2)
+
+ bag.to_a.is_a?(Array).should.be.true
+ bag.to_a.size.should == 2
+ bag.to_a[0].text.should == "1"
+ bag.to_a[1].text.should == "2"
+ bag.save
+ bag.to_a.size.should == 2
+ end
end
end
\ No newline at end of file