Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add test for Storage.KyotoCabinet

  • Loading branch information...
commit 7ef8836b4daa2efd36995f8baba3568d97fe1627 1 parent b9b041a
@chriskite authored
Showing with 61 additions and 36 deletions.
  1. +2 −1  .gitignore
  2. +2 −4 Rakefile
  3. +3 −2 anemone.gemspec
  4. +54 −29 spec/storage_spec.rb
View
3  .gitignore
@@ -2,4 +2,5 @@
Gemfile.lock
test.db
test.tch
-test.kch
+*.kch
+rdoc
View
6 Rakefile
@@ -1,6 +1,5 @@
-require 'rubygems'
-require 'rake'
require 'rspec/core/rake_task'
+require 'rake/rdoctask'
desc "Run all specs"
RSpec::Core::RakeTask.new(:rspec) do |spec|
@@ -14,8 +13,7 @@ end
task :default => :rspec
-require 'rdoc/task'
-RDoc::Task.new do |rdoc|
+Rake::RDocTask.new(:rdoc) do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
View
5 anemone.gemspec
@@ -14,8 +14,9 @@ spec = Gem::Specification.new do |s|
s.add_dependency("nokogiri", ">= 1.3.0")
s.add_dependency("robots", ">= 0.7.2")
- s.add_development_dependency "rake", ">=0.8.7"
- s.add_development_dependency "rspec", ">=2.6.0"
+ s.add_development_dependency "rake", ">=0.9.2"
+ s.add_development_dependency "rdoc", ">=3.12"
+ s.add_development_dependency "rspec", ">=2.8.0"
s.add_development_dependency "fakeweb", ">=1.3.0"
s.add_development_dependency "redis", ">=2.2.0"
s.add_development_dependency "mongo", ">=1.3.1"
View
83 spec/storage_spec.rb
@@ -6,45 +6,70 @@
module Anemone
describe Storage do
- it "should have a class method to produce a Hash" do
- Anemone::Storage.should respond_to(:Hash)
- Anemone::Storage.Hash.should be_an_instance_of(Hash)
+ describe ".Hash" do
+ it "returns a Hash adapter" do
+ Anemone::Storage.Hash.should be_an_instance_of(Hash)
+ end
end
- it "should have a class method to produce a PStore" do
- test_file = 'test.pstore'
- Anemone::Storage.should respond_to(:PStore)
- Anemone::Storage.PStore(test_file).should be_an_instance_of(Anemone::Storage::PStore)
+ describe ".PStore" do
+ it "returns a PStore adapter" do
+ test_file = 'test.pstore'
+ Anemone::Storage.PStore(test_file).should be_an_instance_of(Anemone::Storage::PStore)
+ end
end
- it "should have a class method to produce a TokyoCabinet" do
- test_file = 'test.tch'
- Anemone::Storage.should respond_to(:TokyoCabinet)
- store = Anemone::Storage.TokyoCabinet(test_file)
- store.should be_an_instance_of(Anemone::Storage::TokyoCabinet)
- store.close
+ describe ".TokyoCabinet" do
+ it "returns a TokyoCabinet adapter" do
+ test_file = 'test.tch'
+ store = Anemone::Storage.TokyoCabinet(test_file)
+ store.should be_an_instance_of(Anemone::Storage::TokyoCabinet)
+ store.close
+ end
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
+ describe ".KyotoCabinet" do
+ context "when the file is specified" do
+ it "returns a KyotoCabinet adapter using that file" do
+ test_file = 'test.kch'
+ store = Anemone::Storage.KyotoCabinet(test_file)
+ store.should be_an_instance_of(Anemone::Storage::KyotoCabinet)
+ store.close
+ end
+ end
+
+ context "when no file is specified" do
+ it "returns a KyotoCabinet adapter using the default filename" do
+ store = Anemone::Storage.KyotoCabinet
+ store.should be_an_instance_of(Anemone::Storage::KyotoCabinet)
+ store.close
+ end
+ end
+ end
+
+ describe ".SQLite3" do
+ it "returns a SQLite3 adapter" do
+ test_file = 'test.db'
+ store = Anemone::Storage.SQLite3(test_file)
+ store.should be_an_instance_of(Anemone::Storage::SQLite3)
+ store.close
+ end
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
+ describe ".MongoDB" do
+ it "returns a MongoDB adapter" do
+ store = Anemone::Storage.MongoDB
+ store.should be_an_instance_of(Anemone::Storage::MongoDB)
+ store.close
+ end
end
- it "should have a class method to produce a Redis" do
- Anemone::Storage.should respond_to(:Redis)
- store = Anemone::Storage.Redis
- store.should be_an_instance_of(Anemone::Storage::Redis)
- store.close
+ describe ".MongoDB" do
+ it "returns a Redis adapter" do
+ store = Anemone::Storage.Redis
+ store.should be_an_instance_of(Anemone::Storage::Redis)
+ store.close
+ end
end
module Storage
Please sign in to comment.
Something went wrong with that request. Please try again.