spec/ruco/file_store_spec.rb in ruco-0.2.0.beta2 vs spec/ruco/file_store_spec.rb in ruco-0.2.0.beta3
- old
+ new
@@ -14,10 +14,14 @@
`rm -rf #{@folder}`
end
let(:store){ Ruco::FileStore.new(@folder, :keep => 3) }
+ it "can get unstored stuff" do
+ store.get('xxx').should == nil
+ end
+
it "can store stuff" do
store.set('xxx', 1)
store.get('xxx').should == 1
end
@@ -38,7 +42,48 @@
store.set('zzz', 1)
mark_all_as_old
store.set('zzz', 1)
store.set('zzz', 1)
store.get('xxx').should == 1
+ end
+
+ it "can cache" do
+ store.cache('x'){ 1 }.should == 1
+ store.cache('x'){ 2 }.should == 1
+ end
+
+ it "can cache false" do
+ store.cache('x'){ false }.should == false
+ store.cache('x'){ 2 }.should == false
+ end
+
+ it "does not cache nil" do
+ store.cache('x'){ nil }.should == nil
+ store.cache('x'){ 2 }.should == 2
+ end
+
+ it "can delete" do
+ store.set('x', 1)
+ store.set('y', 2)
+ store.delete('x')
+ store.get('x').should == nil
+ store.get('y').should == 2
+ end
+
+ it "can delete uncached" do
+ store.set('x', 1)
+ store.delete('z')
+ store.get('x').should == 1
+ store.get('z').should == nil
+ end
+
+ it "can clear" do
+ store.set('x', 1)
+ store.clear
+ store.get('x').should == nil
+ end
+
+ it "can clear unstored" do
+ store.clear
+ store.get('x').should == nil
end
end