spec/storage_spec.rb in anemone-0.6.1 vs spec/storage_spec.rb in anemone-0.7.0
- old
+ new
@@ -1,9 +1,9 @@
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'
-%w[pstore tokyo_cabinet mongodb redis].each { |file| require "anemone/storage/#{file}.rb" }
+%w[pstore tokyo_cabinet kyoto_cabinet sqlite3 mongodb redis].each { |file| require "anemone/storage/#{file}.rb" }
module Anemone
describe Storage do
it "should have a class method to produce a Hash" do
@@ -23,10 +23,18 @@
store = Anemone::Storage.TokyoCabinet(test_file)
store.should be_an_instance_of(Anemone::Storage::TokyoCabinet)
store.close
end
+ it "should have a class method to produce a SQLite3" do
+ test_file = 'test.db'
+ Anemone::Storage.should respond_to(:SQLite3)
+ store = Anemone::Storage.SQLite3(test_file)
+ store.should be_an_instance_of(Anemone::Storage::SQLite3)
+ store.close
+ end
+
it "should have a class method to produce a MongoDB" do
Anemone::Storage.should respond_to(:MongoDB)
store = Anemone::Storage.MongoDB
store.should be_an_instance_of(Anemone::Storage::MongoDB)
store.close
@@ -103,10 +111,16 @@
merged = @store.merge! hash
hash.each { |key, value| @store[key].url.to_s.should == key }
merged.should === @store
end
+
+ it "should correctly deserialize nil redirect_to when loading" do
+ @page.redirect_to.should be_nil
+ @store[@url] = @page
+ @store[@url].redirect_to.should be_nil
+ end
end
describe PStore do
it_should_behave_like "storage engine"
@@ -139,9 +153,50 @@
end
it "should raise an error if supplied with a file extension other than .tch" do
lambda { Anemone::Storage.TokyoCabinet('test.tmp') }.should raise_error(RuntimeError)
end
+ end
+
+ describe KyotoCabinet do
+ it_should_behave_like "storage engine"
+
+ before(:each) do
+ @test_file = 'test.kch'
+ File.delete @test_file rescue nil
+ @store = Anemone::Storage.KyotoCabinet(@test_file)
+ end
+
+ after(:each) do
+ @store.close
+ end
+
+ after(:all) do
+ File.delete @test_file rescue nil
+ end
+
+ it "should raise an error if supplied with a file extension other than .kch" do
+ lambda { Anemone::Storage.KyotoCabinet('test.tmp') }.should raise_error(RuntimeError)
+ end
+ end
+
+ describe SQLite3 do
+ it_should_behave_like "storage engine"
+
+ before(:each) do
+ @test_file = 'test.db'
+ File.delete @test_file rescue nil
+ @store = Anemone::Storage.SQLite3(@test_file)
+ end
+
+ after(:each) do
+ @store.close
+ end
+
+ after(:all) do
+ File.delete @test_file rescue nil
+ end
+
end
describe Storage::MongoDB do
it_should_behave_like "storage engine"