Skip to content

Commit

Permalink
add test for Storage.KyotoCabinet
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskite committed Jan 20, 2012
1 parent b9b041a commit 7ef8836
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Gemfile.lock
test.db
test.tch
test.kch
*.kch
rdoc
6 changes: 2 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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|
Expand All @@ -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'
Expand Down
5 changes: 3 additions & 2 deletions anemone.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
83 changes: 54 additions & 29 deletions spec/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ef8836

Please sign in to comment.