spec/bin/store_spec.rb in bin-0.5 vs spec/bin/store_spec.rb in bin-0.6

- old
+ new

@@ -35,11 +35,22 @@ it "sets _id to key" do document['_id'].should == 'foo' end it "sets value key to value" do + store.read('foo').should == 'bar' + end + + it "should marshal value by default" do + document['value'].should == Marshal.dump('bar') + document['raw'].should be_false + end + + it "should be able to store in raw format" do + store.write('foo', 'bar', :raw => true) document['value'].should == 'bar' + document['raw'].should be_true end it "sets expires in to default if not provided" do document['expires_at'].to_i.should == (Time.now.utc + 1.year).to_i end @@ -52,15 +63,21 @@ describe "#read" do before(:each) do store.write('foo', 'bar') end + let(:document) { collection.find_one(:_id => 'foo') } it "returns nil for key not found" do store.read('non:existent:key').should be_nil end - it "returns value key value for key found" do + it "returns unmarshalled value key value for key found" do + store.read('foo').should == 'bar' + end + + it "returns raw value if document raw key is true" do + store.write('foo', 'bar', :raw => true) store.read('foo').should == 'bar' end it "returns nil for existing but expired key" do collection.save(:_id => 'foo', :value => 'bar', :expires_at => 5.seconds.ago) \ No newline at end of file