spec/admin_party/database_spec.rb in leanback-0.3.4 vs spec/admin_party/database_spec.rb in leanback-0.4.0
- old
+ new
@@ -62,10 +62,43 @@
d = docs[0]
d["lastname"].should == "smith"
Couchdb.delete_doc({:database => 'friends', :doc_id => '_design/lastname_finder'})
end
+it "should find items by multiple keys" do
+ keys = {:gender => 'male',:age => '34'}
+ docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
+ d = docs[0]
+ d["age"].should == "34"
+end
+
+it "should find items by multiple keys using a single key" do
+ keys = {:lastname => 'smith'}
+ docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
+ d = docs[0]
+ d["lastname"].should == "smith"
+end
+
+it "should find items by multiple keys" do
+ keys = {:gender => 'male',:age => '40'}
+ docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
+ docs.should == []
+end
+
+it "should count items by multiple keys" do
+ keys = {:gender => 'male',:age => '34'}
+ count = Couchdb.count_by_keys({:database => 'friends', :keys => keys})
+ count.should == 1
+end
+
+it "should count items by multiple keys" do
+ keys = {:gender => 'male',:age => '40'}
+ count = Couchdb.count_by_keys({:database => 'friends', :keys => keys})
+ count.should == 0
+end
+
+
it "should query a permanent view that doesn't exist and handle exception" do
begin
view = { :database => "friends", :design_doc => 'more_views', :view => 'get_user_email'}
Couchdb.find view
rescue CouchdbException => e
@@ -203,9 +236,16 @@
Couchdb.create_doc doc
data = {:firstname => 'sam', :gender =>'male', :age => '28', :salary => '97000'}
doc = {:database => 'fishes', :doc_id => 'sam', :data => data}
Couchdb.create_doc doc
+
+
+ keys = {:age =>'28', :gender => 'male'}
+ hash = Couchdb.find_by_keys({:database => 'fishes', :keys => keys},'', options = {:limit => 2, :skip => 1})
+ h = hash[0]
+ h["firstname"].should == "john"
+ hash.length.should == 2
#create the design doc to be queryed in the test
Couchdb.find_by({:database => 'fishes', :gender => 'male'})