leanback 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +65 -14
- data/README.md +465 -33
- data/Rakefile +8 -17
- data/VERSION +1 -1
- data/leanback.gemspec +26 -85
- data/lib/leanback.rb +129 -587
- data/spec/leanback_spec.rb +356 -0
- metadata +40 -117
- data/Changelog.rdoc +0 -146
- data/documentation/static/2011/11/20/i-moved-leanback-documentation/index.html +0 -180
- data/documentation/static/2011/11/20/index.html +0 -146
- data/documentation/static/2011/11/index.html +0 -146
- data/documentation/static/2011/index.html +0 -146
- data/documentation/static/2013/06/02/index.html +0 -146
- data/documentation/static/2013/06/02/released-leanback-v0-3-4/index.html +0 -180
- data/documentation/static/2013/06/09/index.html +0 -146
- data/documentation/static/2013/06/09/released-leanback-v0-4-0/index.html +0 -179
- data/documentation/static/2013/06/index.html +0 -158
- data/documentation/static/2013/index.html +0 -158
- data/documentation/static/author/admin/index.html +0 -175
- data/documentation/static/basic-couchdb-operations/index.html +0 -259
- data/documentation/static/category/uncategorized/index.html +0 -170
- data/documentation/static/couchdb-configuration/index.html +0 -189
- data/documentation/static/couchdb-security/index.html +0 -218
- data/documentation/static/count-by-multiple-documents/index.html +0 -221
- data/documentation/static/count-documents-by-key/index.html +0 -177
- data/documentation/static/css/2c-l-fixed.css +0 -1
- data/documentation/static/css/2c-l-fixed.dev.css +0 -62
- data/documentation/static/css/2c-r-fixed.css +0 -1
- data/documentation/static/css/2c-r-fixed.dev.css +0 -60
- data/documentation/static/css/3c-c-fixed.css +0 -1
- data/documentation/static/css/3c-c-fixed.dev.css +0 -84
- data/documentation/static/css/3c-l-fixed.css +0 -1
- data/documentation/static/css/3c-l-fixed.dev.css +0 -61
- data/documentation/static/css/3c-r-fixed.css +0 -1
- data/documentation/static/css/3c-r-fixed.dev.css +0 -62
- data/documentation/static/css/holy-grail-fluid.css +0 -5
- data/documentation/static/css/plugins.css +0 -5
- data/documentation/static/css/print.css +0 -5
- data/documentation/static/css/screen.css +0 -1
- data/documentation/static/design-documents-and-permanent-views/index.html +0 -454
- data/documentation/static/error-handling/index.html +0 -157
- data/documentation/static/find-document-by-multiple-keys/index.html +0 -269
- data/documentation/static/find-documents-by-key/index.html +0 -243
- data/documentation/static/index.html +0 -161
- data/documentation/static/leanback/index.html +0 -130
- data/documentation/static/leanback/installation/index.html +0 -119
- data/documentation/static/setting-the-bind_address-port/index.html +0 -151
- data/documentation/static/style.css +0 -16
- data/spec/admin_party/database_spec.rb +0 -400
- data/spec/no_admin_party/cloudant_spec.rb +0 -365
- data/spec/no_admin_party/database_spec.rb +0 -491
- data/spec/no_admin_party/non_admin_user_spec.rb +0 -67
- data/test/helper.rb +0 -18
- data/test/main.rb +0 -295
- data/test/my_view.json +0 -8
- data/test/my_views.json +0 -8
- data/test/start.json +0 -8
- data/test/test_leanback.rb +0 -319
- data/test/view_age.json +0 -8
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Theme Name: Hybrid
|
3
|
-
* Theme URI: http://themehybrid.com/themes/hybrid
|
4
|
-
* Description: A user-friendly, search-engine optimized parent theme, featuring 15 custom page templates and multiple widget-ready areas, allowing you to create any type of site you want.
|
5
|
-
* Version: 1.0
|
6
|
-
* Author: Justin Tadlock
|
7
|
-
* Author URI: http://justintadlock.com
|
8
|
-
* Tags: theme-options, threaded-comments, sticky-post, microformats, translation-ready, rtl-language-support, one-column, two-columns, three-columns, fixed-width
|
9
|
-
* License: GNU General Public License v2.0
|
10
|
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11
|
-
*
|
12
|
-
* Copyright (c) 2008 - 2011 Justin Tadlock. All rights reserved.
|
13
|
-
* http://justintadlock.com
|
14
|
-
*/
|
15
|
-
|
16
|
-
html,body,div,span,object,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;background:transparent;border:none;text-decoration:none}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}b,i,hr,u,center,menu,layer,s,strike,font,xmp{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;font-weight:normal;font-style:normal;background:transparent;border:none;text-decoration:none}body{line-height:24px;font-family:Georgia,Times,"Times New Roman",serif;color:#333;background:#fff}h1,h2,h3,h4,h5,h6{font-style:normal;font-weight:normal;margin:0 0 21px 0}h1{font-size:1.8em}h2{font-size:1.7em}h3{font-size:1.55em}h4{font-size:1.4em}h5{font-size:1.25em}h6{font-size:1.1em}p{margin:0 0 21px 0}ol,ul{list-style:none}ul{list-style:disc;margin:0 0 21px 2.5em}ol{list-style-type:decimal;margin:0 0 21px 3em}ol ol{list-style:upper-roman}ol ol ol{list-style:lower-roman}ol ol ol ol{list-style:upper-alpha}ol ol ol ol ol{list-style:lower-alpha}ul ul,ol ol,ul ol,ol ul{margin-bottom:0}dl{margin:0 0 18px 3px}dl dt{font-weight:bold;margin:12px 0 0 0}dl dd{margin:6px 0 0 1.5em}strong{font-weight:bold}strong strong{font-weight:normal}em,cite{font-style:italic}em em,cite cite{font-style:normal}abbr{cursor:help}acronym{text-transform:uppercase;border-bottom:1px dashed #666;cursor:help}big{font-size:120%}small,sup,sub{font-size:80%}sup{vertical-align:baseline;position:relative;bottom:0.3em}sub{vertical-align:baseline;position:relative;top:0.3em}address{font-style:italic;margin:0 0 21px 0}li address,dd address{margin:0}blockquote{margin:0 2.5em;font-style:normal}blockquote em,blockquote cite{font-style:italic}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}a{cursor:pointer}a img{border:none}pre{overflow:auto;font:.9em Monaco,monospace,Courier,"Courier New";line-height:21px;margin-bottom:21px;padding:9px}code{font:.9em Monaco,monospace,Courier,"Courier New"}pre code{font-size:1em}ins,dfn{font-style:italic;text-decoration:none;border-bottom:1px solid #666}del,s,strike{text-decoration:line-through}object{margin-bottom:21px}input,textarea{font-size:1em;padding:3px}input[type="submit"]{cursor:pointer}:focus{outline:none}form label{cursor:pointer}option{padding:1px 3px}table{border-collapse:collapse;border-spacing:0;margin-bottom:21px}th,td{text-align:left}hr{height:1px;margin-bottom:21px;background:#333}img.wp-smiley{max-height:12px;margin:0;padding:0;border:none}.gallery{display:block;text-align:center;margin-bottom:21px}.alignleft,.left{float:left;margin-right:15px}.alignright,.right{float:right;margin-left:15px}.aligncenter,.center{display:block;margin:0 auto 21px auto}.alignnone,.block{clear:both;margin:0 0 21px 0}.clear{clear:both}img.alignleft,img.alignright{display:inline}blockquote.alignleft,blockquote.alignright{width:33%}#body-container{overflow:hidden;width:960px;margin:0 auto}#container{overflow:hidden;float:left;width:960px}.content{overflow:hidden;float:left;width:620px}.no-widgets .content,.no-default-widgets .content{width:960px}#primary{position:relative;float:right;width:300px}#secondary{position:relative;clear:right;float:right;width:300px}#subsidiary{overflow:hidden}#subsidiary .widget{overflow:hidden;float:left;width:300px;margin:0 20px 0 0}#footer-container{clear:both;overflow:hidden}#footer{clear:both;overflow:hidden}div.menu ul{margin:0;padding:0;list-style:none;line-height:1.0}div.menu ul ul{position:absolute;top:-999em;width:10em}div.menu ul ul li{width:100%}div.menu li:hover{visibility:inherit}div.menu li{float:left;position:relative}div.menu a{display:block;position:relative}div.menu li:hover ul,li.sfHover ul{left:0;top:2em;z-index:99}div.menu li:hover li ul,li.sfHover li ul{top:-999em}div.menu li li:hover ul,li li.sfHover ul{left:10em;top:0}div.menu li li:hover li ul,li li.sfHover li ul{top:-999em}div.menu li li li:hover ul,li li li.sfHover ul{left:10em;top:0}.gallery{display:block;clear:both;overflow:hidden;margin:0 auto}.gallery .gallery-row{display:block;clear:both;overflow:hidden;margin:0}.gallery .gallery-item{overflow:hidden;float:left;margin:0;text-align:center;list-style:none;padding:0}.gallery .gallery-item .gallery-icon img{width:auto;max-width:89%;height:auto;padding:1%;margin:0 auto}.gallery-caption{margin-left:0}.gallery .col-0{width:100%}.gallery .col-1{width:100%}.gallery .col-2{width:50%}.gallery .col-3{width:33.33%}.gallery .col-4{width:25%}.gallery .col-5{width:20%}.gallery .col-6{width:16.66%}.gallery .col-7{width:14.28%}.gallery .col-8{width:12.5%}.gallery .col-9{width:11.11%}.gallery .col-10{width:10%}.gallery .col-11{width:9.09%}.gallery .col-12{width:8.33%}.gallery .col-13{width:7.69%}.gallery .col-14{width:7.14%}.gallery .col-15{width:6.66%}.gallery .col-16{width:6.25%}.gallery .col-17{width:5.88%}.gallery .col-18{width:5.55%}.gallery .col-19{width:5.26%}.gallery .col-20{width:5%}.gallery .col-21{width:4.76%}.gallery .col-22{width:4.54%}.gallery .col-23{width:4.34%}.gallery .col-24{width:4.16%}.gallery .col-25{width:4%}.gallery .col-26{width:3.84%}.gallery .col-27{width:3.7%}.gallery .col-28{width:3.57%}.gallery .col-29{width:3.44%}.gallery .col-30{width:3.33%}.sticky,.bypostauthor{}body{font:normal normal normal 15px/21px Georgia,Times,"Times New Roman",serif;color:#000}#body-container{margin:90px auto 21px auto}a{color:#21759b;text-decoration:none}a:visited{color:#551a8b}a:hover,a:active{color:#d54e21;text-decoration:underline}h1,h2,h3,h4,h5,h6{font-family:Arial,Verdana,sans-serif;color:#000;font-weight:bold}h1{font-size:24px}h2{font-size:21px}h3{font-size:19px}h4{font-size:17px}h5{font-size:15px}h6{font-size:13px}ul{list-style:square}blockquote{font-style:italic;color:#555}blockquote blockquote{color:#777}blockquote em{font-style:normal}pre{padding:9px;background:#f9f9f9;border:1px solid #ccc}code{padding:0 3px;background:#eee}pre code{background:transparent}table{width:100%;border-collapse:separate;border-top:1px solid #ccc;border-left:1px solid #ccc}caption{font-size:.9em;font-style:italic;text-align:right}td,th{padding:3px 6px;border-bottom:1px solid #ccc;border-right:1px solid #ccc}th{background:#eee}.drop-cap{float:left;margin:3px 3px 0 0;font:normal normal normal 47px/35px "Warnock Pro","Goudy Old Style",Palatino,"Book Antiqua",Georgia,serif;color:#333}.note{padding:6px 9px;background:#eee;border:1px solid #ccc}.warning,.alert{padding:6px 9px;background:#fffbbc;border:1px solid #E6DB55}.error{padding:6px 9px;background:#ffebe8;border:1px solid #C00}.download{padding:6px 9px;background:#e7f7d3;border:1px solid #6c3}.breadcrumb{margin:0 0 30px 0;font-size:.9em;font-style:italic;color:#666}.breadcrumb a{color:#111;text-decoration:none}.breadcrumb a:hover{color:#d54e21;text-decoration:underline}.hentry img{max-width:610px;height:auto;padding:4px;border:1px solid #ccc}.no-widgets .hentry img{max-width:950px}img.alignleft,img.alignright{margin-bottom:10px}.thumbnail{float:left;width:100px;height:100px;margin:5px 15px 10px 0}img.wp-smiley{max-width:12px;padding:0;background:transparent;border:none}.wp-caption{max-width:616px;margin-top:6px;padding:6px 1px 3px 1px;border:1px solid #ccc;text-align:center}.wp-caption .wp-caption-text{margin:0;padding:0 5px;text-align:right;font-size:.9em;font-style:italic;color:#666}.wp-caption img{max-width:604px;margin:0 auto;padding:0;border:1px solid #666}.no-widgets .wp-caption{max-width:956px}.no-widgets .wp-caption img{max-width:946px}.gallery img{border:1px solid #ccc}.avatar{float:left;width:100px;height:100px;margin:5px 15px 0 0;padding:4px;border:1px solid #ccc}#header{margin:0 0 40px 0}#site-title{font:normal normal bold 35px/35px Arial,Verdana,sans-serif;margin:0 0 10px 0}#site-title a{color:#000}#site-description{font:normal normal normal 16px/20px Georgia,Times,"Times New Roman",serif;margin:0;color:#666}#primary-menu,#navigation{overflow:visible;height:34px;margin:0 0 60px 0;z-index:100}#primary-menu li,#page-nav li{margin-right:15px}#primary-menu li li,#page-nav li li{margin-right:0}#primary-menu li a,#page-nav li a{padding:8px 15px 8px 15px;color:#111;background:#fff;border:1px solid #ccc}#primary-menu li:hover ul,#primary-menu li.sfHover ul,#page-nav li:hover ul,#page-nav li.sfHover ul{top:32px}#primary-menu li li a,#page-nav li li a{border-top:none;margin-right:0}#primary-menu li ul,#page-nav li ul{background:#fff;border-top:1px solid #ccc}#primary-menu li li:hover ul,#primary-menu li li.sfHover ul,#primary-menu li li li:hover ul,#primary-menu li li li.sfHover ul,#page-nav li li:hover ul,#page-nav li li.sfHover ul,#page-nav li li li:hover ul,#page-nav li li li.sfHover ul {top:-1px}#primary-menu li li li,#page-nav li li li{margin-left:-1px}#container{margin-bottom:21px}.content{margin:0 0 21px 0}.no-widgets .content,.page-template-no-widgets .content{width:960px}.hentry{overflow:hidden;margin:0 0 40px 0}.singular .hentry{margin:0}.loop-meta{overflow:hidden;margin:0 0 40px 0}.loop-title{font:normal normal bold 24px/24px Arial,Verdana,sans-serif}.entry-title{font:normal normal bold 24px/24px Arial,Verdana,sans-serif;margin:0 0 12px 0}.archive .entry-title,.search .entry-title{font-size:21px;margin:0 0 5px 0}.singular-page .entry-title,.singular-attachment .entry-title{margin:0 0 21px 0}.entry-title a{color:#000}.byline{margin:0 0 30px 0;font-style:italic;color:#666}.archive .byline,.search .byline{margin:0 0 5px 0}.entry-content{margin:0 0 10px 0}.entry-meta{clear:both;font-style:italic;color:#666}p.page-links,.comment-pagination{clear:both}.comment-pagination{margin-bottom:21px}p.page-links a,.comment-pagination .page-numbers{margin:0 3px;padding:3px 9px 3px 9px;border:1px solid #ccc}.navigation-links{margin-bottom:21px;font-style:italic}.navigation-links .previous{float:left;max-width:50%}.navigation-links .next{float:right;max-width:50%;text-align:right}.navigation-attachment{overflow:hidden}.widget{overflow:hidden;margin:0 0 15px 0;color:#464646}.widget a{color:#464646;text-decoration:underline}.widget a:hover{color:#d54e21;text-decoration:none}.widget-title{font-size:18px;color:#111}#utility-before-content,#utility-after-content,#utility-after-page,#utility-after-single{margin:0 0 21px 0;padding:20px 20px 0 20px;border:1px solid #ccc}#comments-template{clear:both}.comments-header{font-size:1.2em}.comments-closed{font-style:italic}ol.comment-list,ol.comment-list ol.children{list-style:none;margin:0 0 21px 0}li.comment,li li li.comment,li li li li li.comment,li li li li li li li.comment,li li li li li li li li li.comment,li.pingback,li.trackback{overflow:hidden;margin:0 0 21px 0;padding:21px 21px 0 21px;background:#fff;border:1px solid #ccc}li li.comment,li li li li.comment,li li li li li li.comment,li li li li li li li li.comment,li li li li li li li li li li.comment{background:#f9f9f9}#comments-template .avatar{width:40px;height:40px;float:left;margin-right:15px;padding:0;border:1px solid #666}.comment-meta{margin:10px 0 21px 0;font-size:13px;color:#666}.comment-author{font-size:15px;color:#000}.comment-reply-link,.permalink,.comment-edit-link{font-style:italic;color:#666}.comment-text{clear:left;margin:0 15px}.text-input{display:block;padding:3px 6px;width:97%}#comments-template label{font-size:.9em}textarea{width:98%}#submit{display:inline-block;margin-right:15px;padding:7px 15px 8px 15px;background:#fff;border:1px solid #ccc}#submit:hover{cursor:pointer;background:#f9f9f9}#footer-container{clear:both;margin:0 0 21px 0}#subsidiary{margin:0 0 21px 0}#footer{font-style:italic;color:#444}#footer .copyright{display:inline;float:left;margin-right:9px}.content{float:left;width:620px}#primary{float:right;width:300px}#secondary{clear:right;float:right;width:300px}
|
@@ -1,400 +0,0 @@
|
|
1
|
-
require 'spec_base.rb'
|
2
|
-
#ain't no party like an admin party
|
3
|
-
|
4
|
-
|
5
|
-
describe "CouchDB admin party " do
|
6
|
-
|
7
|
-
|
8
|
-
it "should create and delete a database" do
|
9
|
-
hash = Couchdb.create('staff')
|
10
|
-
hash.to_s.should == '{"ok"=>true}'
|
11
|
-
hash = Couchdb.all
|
12
|
-
hash.include?("staff").should == true
|
13
|
-
hash = Couchdb.delete 'staff'
|
14
|
-
hash.include?("staff").should == false
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should create a database add a finder method to it and then delete the database" do
|
18
|
-
Couchdb.create('mobsters')
|
19
|
-
hash = Couchdb.add_finder({:database => 'mobsters', :key => 'email'})
|
20
|
-
hash.include?("_design/email_finder").should == true
|
21
|
-
hash.include?("true").should == true
|
22
|
-
hash.include?("rev").should == true
|
23
|
-
|
24
|
-
doc = {:database => 'mobsters', :doc_id => '_design/email_finder'}
|
25
|
-
hash = Couchdb.view doc
|
26
|
-
hash["_id"].should == '_design/email_finder'
|
27
|
-
Couchdb.delete 'mobsters'
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
it "should create and view document doc" do
|
34
|
-
Couchdb.create('friends')
|
35
|
-
|
36
|
-
data = {:firstname => 'John',
|
37
|
-
:lastname =>'smith',
|
38
|
-
:phone => '202-234-1234',
|
39
|
-
:email =>'james@mail.com',
|
40
|
-
:age =>'34',
|
41
|
-
:gender =>'male'}
|
42
|
-
doc = {:database => 'friends', :doc_id => 'john', :data => data}
|
43
|
-
Couchdb.create_doc doc
|
44
|
-
|
45
|
-
doc = {:database => 'friends', :doc_id => 'john'}
|
46
|
-
hash = Couchdb.view doc
|
47
|
-
hash["_id"].should == 'john'
|
48
|
-
|
49
|
-
#view doc and return symbolized keys
|
50
|
-
doc = {:database => 'friends', :doc_id => 'john'}
|
51
|
-
hash = Couchdb.view(doc,'', {symbolize_keys: true})
|
52
|
-
hash.should include(data)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should count the lastnames named smith" do
|
56
|
-
count = Couchdb.count({:database => 'friends', :lastname => 'smith'})
|
57
|
-
count.should == 1
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should count lastnames named brown" do
|
61
|
-
count = Couchdb.count({:database => 'friends', :lastname => 'brown'})
|
62
|
-
count.should == 0
|
63
|
-
end
|
64
|
-
|
65
|
-
it "find items by key" do
|
66
|
-
docs = Couchdb.find_by({:database => 'friends', :lastname => 'smith'})
|
67
|
-
d = docs[0]
|
68
|
-
d["lastname"].should == "smith"
|
69
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => '_design/lastname_finder'})
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should find items by multiple keys" do
|
73
|
-
keys = {:gender => 'male',:age => '34'}
|
74
|
-
docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
|
75
|
-
d = docs[0]
|
76
|
-
d["age"].should == "34"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should find items by multiple keys using a single key" do
|
80
|
-
keys = {:lastname => 'smith'}
|
81
|
-
docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
|
82
|
-
d = docs[0]
|
83
|
-
d["lastname"].should == "smith"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should find items by multiple keys" do
|
87
|
-
keys = {:gender => 'male',:age => '40'}
|
88
|
-
docs = Couchdb.find_by_keys({:database => 'friends', :keys => keys})
|
89
|
-
docs.should == []
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should count items by multiple keys" do
|
93
|
-
keys = {:gender => 'male',:age => '34'}
|
94
|
-
count = Couchdb.count_by_keys({:database => 'friends', :keys => keys})
|
95
|
-
count.should == 1
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should count items by multiple keys" do
|
99
|
-
keys = {:gender => 'male',:age => '40'}
|
100
|
-
count = Couchdb.count_by_keys({:database => 'friends', :keys => keys})
|
101
|
-
count.should == 0
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
it "should query a permanent view that doesn't exist and handle exception" do
|
106
|
-
begin
|
107
|
-
view = { :database => "friends", :design_doc => 'more_views', :view => 'get_user_email'}
|
108
|
-
Couchdb.find view
|
109
|
-
rescue CouchdbException => e
|
110
|
-
e.to_s.should == "CouchDB: Error - not_found. Reason - missing"
|
111
|
-
e.error.should == "not_found"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should query a permanent view and create the view on the fly, if it doesn't already exist" do
|
116
|
-
view = {:database => 'friends',
|
117
|
-
:design_doc => 'my_views',
|
118
|
-
:view => 'get_emails',
|
119
|
-
:json_doc => '/home/obi/bin/leanback/test/my_view.json'}
|
120
|
-
|
121
|
-
docs = Couchdb.find_on_fly(view)
|
122
|
-
docs[0].include?("Email").should == true
|
123
|
-
docs[0].include?("Name").should == true
|
124
|
-
#verify that the view was created
|
125
|
-
doc = {:database => 'friends', :doc_id => '_design/my_views'}
|
126
|
-
hash = Couchdb.view doc
|
127
|
-
hash["_id"].should == '_design/my_views'
|
128
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => '_design/my_views'})
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should query a permanent view by key and create the view on the fly, if it doesn't already exist" do
|
132
|
-
view = { :database => 'friends',
|
133
|
-
:design_doc => 'the_view',
|
134
|
-
:view => 'age',
|
135
|
-
:json_doc => '/home/obi/bin/leanback/test/view_age.json'}
|
136
|
-
|
137
|
-
age = '34'
|
138
|
-
docs = Couchdb.find_on_fly(view,"",key = age)
|
139
|
-
docs[0].include?("age").should == true
|
140
|
-
d = docs[0]
|
141
|
-
d["age"].should == '34'
|
142
|
-
#verify that the view was created
|
143
|
-
doc = {:database => 'friends', :doc_id => '_design/the_view'}
|
144
|
-
hash = Couchdb.view doc
|
145
|
-
hash["_id"].should == '_design/the_view'
|
146
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => '_design/the_view'})
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should create a design doc/permanent view and query it" do
|
150
|
-
doc = { :database => 'friends', :design_doc => 'more_views', :json_doc => '/home/obi/bin/leanback/test/my_views.json' }
|
151
|
-
hash = Couchdb.create_design doc
|
152
|
-
hash["id"].should == '_design/more_views'
|
153
|
-
hash["ok"].should == true
|
154
|
-
|
155
|
-
view = { :database => "friends", :design_doc => 'more_views', :view => 'get_email'}
|
156
|
-
hash = Couchdb.find view
|
157
|
-
hash[0].has_key?("Firstname").should == true
|
158
|
-
hash[0].has_key?("Lastname").should == true
|
159
|
-
hash[0].has_key?("Email").should == true
|
160
|
-
|
161
|
-
doc = {:database => 'friends', :doc_id => '_design/more_views'}
|
162
|
-
hash = Couchdb.view doc
|
163
|
-
hash["_id"].should == '_design/more_views'
|
164
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => '_design/more_views'})
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should return a list of all databases in the system" do
|
168
|
-
databases = Couchdb.all
|
169
|
-
databases.include?("friends").should == true
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should create a document" do
|
173
|
-
data = {:firstname => 'Nancy', :lastname =>'Lee', :phone => '347-808-3734',:email =>'nancy@mail.com',:gender => 'female'}
|
174
|
-
doc = {:database => 'friends', :doc_id => 'Nancy', :data => data}
|
175
|
-
hash = Couchdb.create_doc doc
|
176
|
-
hash["id"].should == 'Nancy'
|
177
|
-
hash["ok"].should == true
|
178
|
-
|
179
|
-
doc = {:database => 'friends', :doc_id => 'Nancy'}
|
180
|
-
hash = Couchdb.view doc
|
181
|
-
hash["_id"].should == 'Nancy'
|
182
|
-
hash["firstname"].should == 'Nancy'
|
183
|
-
hash["lastname"].should == 'Lee'
|
184
|
-
hash["phone"].should == '347-808-3734'
|
185
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => 'Nancy'})
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should update the document" do
|
189
|
-
data = {:age => "41", :lastname => "Stevens" }
|
190
|
-
doc = { :database => 'friends', :doc_id => 'john', :data => data}
|
191
|
-
hash = Couchdb.update_doc doc
|
192
|
-
hash["id"].should == 'john'
|
193
|
-
hash["ok"].should == true
|
194
|
-
|
195
|
-
doc = {:database => 'friends', :doc_id => 'john'}
|
196
|
-
hash = Couchdb.view doc
|
197
|
-
hash["_id"].should == 'john'
|
198
|
-
hash["age"].should == '41'
|
199
|
-
hash["lastname"].should == 'Stevens'
|
200
|
-
Couchdb.delete_doc({:database => 'friends', :doc_id => 'john'})
|
201
|
-
end
|
202
|
-
|
203
|
-
|
204
|
-
it "should delete a document after creating it" do
|
205
|
-
data = {:firstname => 'Sun',
|
206
|
-
:lastname =>'Nova',
|
207
|
-
:phone => '212-234-1234',
|
208
|
-
:email =>'james@mail.com'}
|
209
|
-
|
210
|
-
doc = {:database => 'friends', :doc_id => 'Sun', :data => data}
|
211
|
-
Couchdb.create_doc doc
|
212
|
-
|
213
|
-
doc = {:database => 'friends', :doc_id => 'Sun'}
|
214
|
-
hash = Couchdb.delete_doc doc
|
215
|
-
hash["id"].should == 'Sun'
|
216
|
-
hash["ok"].should == true
|
217
|
-
begin
|
218
|
-
doc = {:database => 'friends', :doc_id => 'Sun'}
|
219
|
-
Couchdb.view doc
|
220
|
-
rescue CouchdbException => e
|
221
|
-
e.to_s.should == "CouchDB: Error - not_found. Reason - deleted"
|
222
|
-
e.error.should == "not_found"
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
it "should test finder options" do
|
228
|
-
|
229
|
-
Couchdb.create('fishes')
|
230
|
-
|
231
|
-
data = {:firstname => 'aaron', :gender =>'male', :age => '28', :salary => '50000'}
|
232
|
-
doc = {:database => 'fishes', :doc_id => 'aaron', :data => data}
|
233
|
-
Couchdb.create_doc doc
|
234
|
-
|
235
|
-
data_c = {:firstname => 'john', :gender =>'male', :age => '28', :salary => '60000'}
|
236
|
-
doc = {:database => 'fishes', :doc_id => 'john', :data => data_c}
|
237
|
-
Couchdb.create_doc doc
|
238
|
-
|
239
|
-
data = {:firstname => 'peter', :gender =>'male', :age => '45', :salary => '78000'}
|
240
|
-
doc = {:database => 'fishes', :doc_id => 'peter', :data => data}
|
241
|
-
Couchdb.create_doc doc
|
242
|
-
|
243
|
-
data = {:firstname => 'sam', :gender =>'male', :age => '28', :salary => '97000'}
|
244
|
-
doc = {:database => 'fishes', :doc_id => 'sam', :data => data}
|
245
|
-
Couchdb.create_doc doc
|
246
|
-
|
247
|
-
|
248
|
-
keys = {:age =>'28', :gender => 'male'}
|
249
|
-
hash = Couchdb.find_by_keys({:database => 'fishes', :keys => keys},'', options = {:limit => 2, :skip => 1})
|
250
|
-
h = hash[0]
|
251
|
-
h["firstname"].should == "john"
|
252
|
-
hash.length.should == 2
|
253
|
-
|
254
|
-
#return hash in symbolized keys for find_by_keys
|
255
|
-
hash = Couchdb.find_by_keys({:database => 'fishes', :keys => keys},'', options = {:limit => 2, :skip => 1, :symbolize_keys => true})
|
256
|
-
hash.first.should include(data_c)
|
257
|
-
|
258
|
-
#create the design doc to be queryed in the test
|
259
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'})
|
260
|
-
|
261
|
-
|
262
|
-
view = { :database => "fishes",
|
263
|
-
:design_doc => 'gender_finder',
|
264
|
-
:view => 'find_by_gender'}
|
265
|
-
|
266
|
-
hash = Couchdb.find view,"",key=nil, options = {:limit => 2, :skip => 1}
|
267
|
-
h = hash[0]
|
268
|
-
h["firstname"].should == "john"
|
269
|
-
hash.length.should == 2
|
270
|
-
|
271
|
-
#return results in symbolized keys
|
272
|
-
hash = Couchdb.find view,'',key=nil, options = {:limit => 2, :skip => 1, :symbolize_keys => true}
|
273
|
-
hash.first.should include(data_c)
|
274
|
-
|
275
|
-
#it should not return symbolized keys
|
276
|
-
hash = Couchdb.find view,'',key=nil, options = {:limit => 2, :skip => 1, :symbolize_keys => false}
|
277
|
-
hash.first.should_not include(data_c)
|
278
|
-
hash.first["firstname"].should == "john"
|
279
|
-
|
280
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},"",options = {:limit => 2, :skip => 1})
|
281
|
-
h = hash[0]
|
282
|
-
h["firstname"].should == "john"
|
283
|
-
hash.length.should == 2
|
284
|
-
|
285
|
-
#return symbolized results
|
286
|
-
hash = Couchdb.find_by({:database => 'fishes', :gender => 'male'},'',options = {:limit => 2, :skip => 1, :symbolize_keys => true})
|
287
|
-
hash.first.should include(data_c)
|
288
|
-
|
289
|
-
hash = Couchdb.find view,"",key='male', options = {:descending => true}
|
290
|
-
h = hash[0]
|
291
|
-
h["firstname"].should == "sam"
|
292
|
-
|
293
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},"", options = {:descending => true})
|
294
|
-
h = hash[0]
|
295
|
-
h["firstname"].should == "sam"
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
hash = Couchdb.find view,"",key='male', options = {:limit => 3}
|
300
|
-
hash.length.should == 3
|
301
|
-
|
302
|
-
hash = Couchdb.find view,"",key=nil, options = {:skip => 2}
|
303
|
-
h = hash[0]
|
304
|
-
h["firstname"].should == "peter"
|
305
|
-
hash.length.should == 2
|
306
|
-
|
307
|
-
hash = Couchdb.find view,"",key='male', options = {:descending => true,:limit => 1}
|
308
|
-
h = hash[0]
|
309
|
-
h["firstname"].should == "sam"
|
310
|
-
hash.length.should == 1
|
311
|
-
|
312
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},"", options = {:descending => true,:limit => 1})
|
313
|
-
h = hash[0]
|
314
|
-
h["firstname"].should == "sam"
|
315
|
-
hash.length.should == 1
|
316
|
-
|
317
|
-
Couchdb.find_by({:database => 'fishes', :salary => '5000'})
|
318
|
-
|
319
|
-
|
320
|
-
view = { :database => "fishes",
|
321
|
-
:design_doc => 'salary_finder',
|
322
|
-
:view => 'find_by_salary'}
|
323
|
-
|
324
|
-
hash = Couchdb.find view, "",key=nil, options = {:startkey => "3000", :endkey => "65000"}
|
325
|
-
h = hash[0]
|
326
|
-
h["firstname"].should == "aaron"
|
327
|
-
hash.length.should == 2
|
328
|
-
|
329
|
-
hash = Couchdb.find view, "",key=nil, options = {:startkey => "53000", :endkey => "99000",:limit => 2}
|
330
|
-
h = hash[0]
|
331
|
-
h["firstname"].should == "john"
|
332
|
-
hash.length.should == 2
|
333
|
-
|
334
|
-
Couchdb.find_by({:database => 'fishes', :salary => '5000'},"", options = {:startkey => "53000", :endkey => "99000",:limit => 2})
|
335
|
-
h = hash[0]
|
336
|
-
h["firstname"].should == "john"
|
337
|
-
hash.length.should == 2
|
338
|
-
|
339
|
-
view = {:database => 'fishes',
|
340
|
-
:design_doc => 'my_views',
|
341
|
-
:view => 'age_gender',
|
342
|
-
:json_doc => '/home/obi/bin/leanback/test/start.json'}
|
343
|
-
|
344
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"], :limit => 2}
|
345
|
-
|
346
|
-
hash = Couchdb.find_on_fly(view,"",key=nil, options)
|
347
|
-
h0 = hash[0]
|
348
|
-
h1 = hash[1]
|
349
|
-
h0["firstname"].should == "aaron"
|
350
|
-
h1["firstname"].should == "john"
|
351
|
-
hash.length.should == 2
|
352
|
-
|
353
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"], :skip => 1}
|
354
|
-
|
355
|
-
hash = Couchdb.find_on_fly(view,"",key=nil, options)
|
356
|
-
h0 = hash[0]
|
357
|
-
h1 = hash[1]
|
358
|
-
h0["firstname"].should == "john"
|
359
|
-
h1["firstname"].should == "sam"
|
360
|
-
hash.length.should == 2
|
361
|
-
|
362
|
-
|
363
|
-
#return results as symbolized keys
|
364
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"], :skip => 1,:symbolize_keys => true}
|
365
|
-
hash = Couchdb.find_on_fly(view,'',key=nil, options)
|
366
|
-
hash.first.should include(data_c)
|
367
|
-
|
368
|
-
|
369
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"]}
|
370
|
-
|
371
|
-
hash = Couchdb.find_on_fly(view,"",key=nil, options)
|
372
|
-
h0 = hash[0]
|
373
|
-
h1 = hash[1]
|
374
|
-
h0["firstname"].should == "aaron"
|
375
|
-
h1["firstname"].should == "john"
|
376
|
-
hash.length.should == 3
|
377
|
-
|
378
|
-
Couchdb.delete 'fishes'
|
379
|
-
end
|
380
|
-
|
381
|
-
#database: administration tasks
|
382
|
-
|
383
|
-
it "should set a config section, retrieve it and delete it" do
|
384
|
-
data = {:section => "sample_config_section",
|
385
|
-
:key => "sample_key",
|
386
|
-
:value => "sample_value"}
|
387
|
-
Couchdb.set_config data
|
388
|
-
|
389
|
-
data = {:section => "sample_config_section",
|
390
|
-
:key => "sample_key"}
|
391
|
-
|
392
|
-
Couchdb.get_config(data).should == "sample_value"
|
393
|
-
|
394
|
-
Couchdb.delete_config(data).should == "sample_value"
|
395
|
-
Couchdb.delete 'friends'
|
396
|
-
|
397
|
-
lambda {Couchdb.get_config(data)}.should raise_error(CouchdbException,"CouchDB: Error - not_found. Reason - unknown_config_value")
|
398
|
-
end
|
399
|
-
|
400
|
-
end
|
@@ -1,365 +0,0 @@
|
|
1
|
-
require 'spec_base.rb'
|
2
|
-
|
3
|
-
#a day in the life of a CouchDB admin user
|
4
|
-
Couchdb.address = "http://whisperservers.cloudant.com"
|
5
|
-
Couchdb.port = "80"
|
6
|
-
hash = Couchdb.login(username = ENV['CLOUDANT_USERNAME'],password =ENV['CLOUDANT_PASSWORD'])
|
7
|
-
@@auth_session = hash["AuthSession"]
|
8
|
-
|
9
|
-
|
10
|
-
describe "CouchDB " do
|
11
|
-
|
12
|
-
it "should create and delete a database" do
|
13
|
-
hash = Couchdb.create('employees',@@auth_session)
|
14
|
-
#hash.to_s.should == '{"ok"=>true}'
|
15
|
-
#hash = Couchdb.all
|
16
|
-
#hash.include?("employees").should == true
|
17
|
-
hash = Couchdb.delete 'employees',@@auth_session
|
18
|
-
#hash.include?("employees").should == false
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should create a database add a finder method to it and then delete the database" do
|
22
|
-
Couchdb.create('wiseguys',@@auth_session)
|
23
|
-
hash = Couchdb.add_finder({:database => 'wiseguys', :key => 'email'},@@auth_session)
|
24
|
-
hash.include?("_design/email_finder").should == true
|
25
|
-
hash.include?("true").should == true
|
26
|
-
hash.include?("rev").should == true
|
27
|
-
|
28
|
-
doc = {:database => 'wiseguys', :doc_id => '_design/email_finder'}
|
29
|
-
hash = Couchdb.view doc,@@auth_session
|
30
|
-
hash["_id"].should == '_design/email_finder'
|
31
|
-
Couchdb.delete 'wiseguys',@@auth_session
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should create and view document doc" do
|
35
|
-
Couchdb.create('contacts',@@auth_session)
|
36
|
-
data = {:firstname => 'John',
|
37
|
-
:lastname =>'smith',
|
38
|
-
:phone => '202-234-1234',
|
39
|
-
:email =>'james@mail.com',
|
40
|
-
:age =>'34',
|
41
|
-
:gender =>'male'}
|
42
|
-
doc = {:database => 'contacts', :doc_id => 'john', :data => data}
|
43
|
-
Couchdb.create_doc doc,@@auth_session
|
44
|
-
|
45
|
-
doc = {:database => 'contacts', :doc_id => 'john'}
|
46
|
-
hash = Couchdb.view doc,@@auth_session
|
47
|
-
hash["_id"].should == 'john'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should count the lastnames named smith" do
|
51
|
-
count = Couchdb.count({:database => 'contacts', :lastname => 'smith'},@@auth_session)
|
52
|
-
count.should == 1
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should count lastnames named brown" do
|
56
|
-
count = Couchdb.count({:database => 'contacts', :lastname => 'brown'},@@auth_session)
|
57
|
-
count.should == 0
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
it "find items by key" do
|
62
|
-
docs = Couchdb.find_by({:database => 'contacts', :lastname => 'smith'},@@auth_session)
|
63
|
-
d = docs[0]
|
64
|
-
d["lastname"].should == "smith"
|
65
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/lastname_finder'},@@auth_session)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should find items by multiple keys" do
|
69
|
-
keys = {:gender => 'male',:age => '34'}
|
70
|
-
docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
|
71
|
-
d = docs[0]
|
72
|
-
d["age"].should == "34"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should find items by multiple keys using a single key" do
|
76
|
-
keys = {:lastname => 'smith'}
|
77
|
-
docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
|
78
|
-
d = docs[0]
|
79
|
-
d["lastname"].should == "smith"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should find items by multiple keys" do
|
83
|
-
keys = {:gender => 'male',:age => '40'}
|
84
|
-
docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
|
85
|
-
docs.should == []
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should count items by multiple keys" do
|
89
|
-
keys = {:gender => 'male',:age => '34'}
|
90
|
-
count = Couchdb.count_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
|
91
|
-
count.should == 1
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should count items by multiple keys" do
|
95
|
-
keys = {:gender => 'male',:age => '40'}
|
96
|
-
count = Couchdb.count_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
|
97
|
-
count.should == 0
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
it "should query a permanent view that doesn't exist and handle exception" do
|
103
|
-
begin
|
104
|
-
view = { :database => "contacts", :design_doc => 'more_views', :view => 'get_user_email'}
|
105
|
-
Couchdb.find view,@@auth_session
|
106
|
-
rescue CouchdbException => e
|
107
|
-
e.to_s.should == "CouchDB: Error - not_found. Reason - missing"
|
108
|
-
e.error.should == "not_found"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should query a permanent view and create the view on the fly, if it doesn't already exist" do
|
113
|
-
view = {:database => 'contacts',
|
114
|
-
:design_doc => 'my_views',
|
115
|
-
:view => 'get_emails',
|
116
|
-
:json_doc => '/home/obi/bin/leanback/test/my_view.json'}
|
117
|
-
|
118
|
-
docs = Couchdb.find_on_fly(view,@@auth_session)
|
119
|
-
docs[0].include?("Email").should == true
|
120
|
-
docs[0].include?("Name").should == true
|
121
|
-
#verify that the view was created
|
122
|
-
doc = {:database => 'contacts', :doc_id => '_design/my_views'}
|
123
|
-
hash = Couchdb.view doc,@@auth_session
|
124
|
-
hash["_id"].should == '_design/my_views'
|
125
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/my_views'},@@auth_session)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should query a permanent view by key and create the view on the fly, if it doesn't already exist" do
|
129
|
-
view = { :database => 'contacts',
|
130
|
-
:design_doc => 'the_view',
|
131
|
-
:view => 'age',
|
132
|
-
:json_doc => '/home/obi/bin/leanback/test/view_age.json'}
|
133
|
-
|
134
|
-
age = '34'
|
135
|
-
docs = Couchdb.find_on_fly(view,@@auth_session,key = age)
|
136
|
-
docs[0].include?("age").should == true
|
137
|
-
d = docs[0]
|
138
|
-
d["age"].should == '34'
|
139
|
-
#verify that the view was created
|
140
|
-
doc = {:database => 'contacts', :doc_id => '_design/the_view'}
|
141
|
-
hash = Couchdb.view doc,@@auth_session
|
142
|
-
hash["_id"].should == '_design/the_view'
|
143
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/the_view'},@@auth_session)
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should create a design doc/permanent view and query it" do
|
147
|
-
doc = { :database => 'contacts', :design_doc => 'more_views', :json_doc => '/home/obi/bin/leanback/test/my_views.json' }
|
148
|
-
hash = Couchdb.create_design doc,@@auth_session
|
149
|
-
hash["id"].should == '_design/more_views'
|
150
|
-
hash["ok"].should == true
|
151
|
-
|
152
|
-
view = { :database => "contacts", :design_doc => 'more_views', :view => 'get_email'}
|
153
|
-
hash = Couchdb.find view,@@auth_session
|
154
|
-
hash[0].has_key?("Firstname").should == true
|
155
|
-
hash[0].has_key?("Lastname").should == true
|
156
|
-
hash[0].has_key?("Email").should == true
|
157
|
-
|
158
|
-
doc = {:database => 'contacts', :doc_id => '_design/more_views'}
|
159
|
-
hash = Couchdb.view doc,@@auth_session
|
160
|
-
hash["_id"].should == '_design/more_views'
|
161
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/more_views'},@@auth_session)
|
162
|
-
end
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
it "should create a document" do
|
167
|
-
data = {:firstname => 'Nancy', :lastname =>'Lee', :phone => '347-808-3734',:email =>'nancy@mail.com',:gender => 'female'}
|
168
|
-
doc = {:database => 'contacts', :doc_id => 'Nancy', :data => data}
|
169
|
-
hash = Couchdb.create_doc doc,@@auth_session
|
170
|
-
hash["id"].should == 'Nancy'
|
171
|
-
hash["ok"].should == true
|
172
|
-
|
173
|
-
doc = {:database => 'contacts', :doc_id => 'Nancy'}
|
174
|
-
hash = Couchdb.view doc,@@auth_session
|
175
|
-
hash["_id"].should == 'Nancy'
|
176
|
-
hash["firstname"].should == 'Nancy'
|
177
|
-
hash["lastname"].should == 'Lee'
|
178
|
-
hash["phone"].should == '347-808-3734'
|
179
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => 'Nancy'},@@auth_session)
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should update the document" do
|
183
|
-
data = {:age => "41", :lastname => "Stevens" }
|
184
|
-
doc = { :database => 'contacts', :doc_id => 'john', :data => data}
|
185
|
-
hash = Couchdb.update_doc doc,@@auth_session
|
186
|
-
hash["id"].should == 'john'
|
187
|
-
hash["ok"].should == true
|
188
|
-
|
189
|
-
doc = {:database => 'contacts', :doc_id => 'john'}
|
190
|
-
hash = Couchdb.view doc,@@auth_session
|
191
|
-
hash["_id"].should == 'john'
|
192
|
-
hash["age"].should == '41'
|
193
|
-
hash["lastname"].should == 'Stevens'
|
194
|
-
Couchdb.delete_doc({:database => 'contacts', :doc_id => 'john'},@@auth_session)
|
195
|
-
end
|
196
|
-
|
197
|
-
|
198
|
-
it "should delete a document after creating it" do
|
199
|
-
data = {:firstname => 'Sun',
|
200
|
-
:lastname =>'Nova',
|
201
|
-
:phone => '212-234-1234',
|
202
|
-
:email =>'james@mail.com'}
|
203
|
-
|
204
|
-
doc = {:database => 'contacts', :doc_id => 'Sun', :data => data}
|
205
|
-
Couchdb.create_doc doc,@@auth_session
|
206
|
-
|
207
|
-
doc = {:database => 'contacts', :doc_id => 'Sun'}
|
208
|
-
hash = Couchdb.delete_doc doc,@@auth_session
|
209
|
-
hash["id"].should == 'Sun'
|
210
|
-
hash["ok"].should == true
|
211
|
-
begin
|
212
|
-
doc = {:database => 'contacts', :doc_id => 'Sun'}
|
213
|
-
Couchdb.view doc,@@auth_session
|
214
|
-
rescue CouchdbException => e
|
215
|
-
e.to_s.should == "CouchDB: Error - not_found. Reason - deleted"
|
216
|
-
e.error.should == "not_found"
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should test finder options" do
|
221
|
-
|
222
|
-
Couchdb.create('fishes',@@auth_session)
|
223
|
-
|
224
|
-
data = {:firstname => 'aaron', :gender =>'male', :age => '28', :salary => '50000'}
|
225
|
-
doc = {:database => 'fishes', :doc_id => 'aaron', :data => data}
|
226
|
-
Couchdb.create_doc doc,@@auth_session
|
227
|
-
|
228
|
-
data = {:firstname => 'john', :gender =>'male', :age => '28', :salary => '60000'}
|
229
|
-
doc = {:database => 'fishes', :doc_id => 'john', :data => data}
|
230
|
-
Couchdb.create_doc doc,@@auth_session
|
231
|
-
|
232
|
-
data = {:firstname => 'peter', :gender =>'male', :age => '45', :salary => '78000'}
|
233
|
-
doc = {:database => 'fishes', :doc_id => 'peter', :data => data}
|
234
|
-
Couchdb.create_doc doc,@@auth_session
|
235
|
-
|
236
|
-
data = {:firstname => 'sam', :gender =>'male', :age => '28', :salary => '97000'}
|
237
|
-
doc = {:database => 'fishes', :doc_id => 'sam', :data => data}
|
238
|
-
Couchdb.create_doc doc,@@auth_session
|
239
|
-
|
240
|
-
|
241
|
-
keys = {:age =>'28', :gender => 'male'}
|
242
|
-
hash = Couchdb.find_by_keys({:database => 'fishes', :keys => keys},@@auth_session, options = {:limit => 2, :skip => 1})
|
243
|
-
h = hash[0]
|
244
|
-
h["firstname"].should == "john"
|
245
|
-
hash.length.should == 2
|
246
|
-
|
247
|
-
#create the design doc to be queryed in the test
|
248
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session)
|
249
|
-
|
250
|
-
|
251
|
-
view = { :database => "fishes",
|
252
|
-
:design_doc => 'gender_finder',
|
253
|
-
:view => 'find_by_gender'}
|
254
|
-
|
255
|
-
hash = Couchdb.find view,@@auth_session,key=nil, options = {:limit => 2, :skip => 1}
|
256
|
-
h = hash[0]
|
257
|
-
h["firstname"].should == "john"
|
258
|
-
hash.length.should == 2
|
259
|
-
|
260
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session,options = {:limit => 2, :skip => 1})
|
261
|
-
h = hash[0]
|
262
|
-
h["firstname"].should == "john"
|
263
|
-
hash.length.should == 2
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
hash = Couchdb.find view,@@auth_session,key='male', options = {:descending => true}
|
268
|
-
h = hash[0]
|
269
|
-
h["firstname"].should == "sam"
|
270
|
-
|
271
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session, options = {:descending => true})
|
272
|
-
h = hash[0]
|
273
|
-
h["firstname"].should == "sam"
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
hash = Couchdb.find view,@@auth_session,key='male', options = {:limit => 3}
|
278
|
-
hash.length.should == 3
|
279
|
-
|
280
|
-
hash = Couchdb.find view,@@auth_session,key=nil, options = {:skip => 2}
|
281
|
-
h = hash[0]
|
282
|
-
h["firstname"].should == "peter"
|
283
|
-
hash.length.should == 2
|
284
|
-
|
285
|
-
hash = Couchdb.find view,@@auth_session,key='male', options = {:descending => true,:limit => 1}
|
286
|
-
h = hash[0]
|
287
|
-
h["firstname"].should == "sam"
|
288
|
-
hash.length.should == 1
|
289
|
-
|
290
|
-
Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session, options = {:descending => true,:limit => 1})
|
291
|
-
h = hash[0]
|
292
|
-
h["firstname"].should == "sam"
|
293
|
-
hash.length.should == 1
|
294
|
-
|
295
|
-
Couchdb.find_by({:database => 'fishes', :salary => '5000'},@@auth_session)
|
296
|
-
|
297
|
-
|
298
|
-
view = { :database => "fishes",
|
299
|
-
:design_doc => 'salary_finder',
|
300
|
-
:view => 'find_by_salary'}
|
301
|
-
|
302
|
-
hash = Couchdb.find view, @@auth_session,key=nil, options = {:startkey => "3000", :endkey => "65000"}
|
303
|
-
h = hash[0]
|
304
|
-
h["firstname"].should == "aaron"
|
305
|
-
hash.length.should == 2
|
306
|
-
|
307
|
-
hash = Couchdb.find view, @@auth_session,key=nil, options = {:startkey => "53000", :endkey => "99000",:limit => 2}
|
308
|
-
h = hash[0]
|
309
|
-
h["firstname"].should == "john"
|
310
|
-
hash.length.should == 2
|
311
|
-
|
312
|
-
Couchdb.find_by({:database => 'fishes', :salary => ''},@@auth_session, options = {:startkey => "53000", :endkey => "99000",:limit => 2})
|
313
|
-
h = hash[0]
|
314
|
-
h["firstname"].should == "john"
|
315
|
-
hash.length.should == 2
|
316
|
-
|
317
|
-
view = {:database => 'fishes',
|
318
|
-
:design_doc => 'my_views',
|
319
|
-
:view => 'age_gender',
|
320
|
-
:json_doc => '/home/obi/bin/leanback/test/start.json'}
|
321
|
-
|
322
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"], :limit => 2}
|
323
|
-
|
324
|
-
hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
|
325
|
-
h0 = hash[0]
|
326
|
-
h1 = hash[1]
|
327
|
-
h0["firstname"].should == "aaron"
|
328
|
-
h1["firstname"].should == "john"
|
329
|
-
hash.length.should == 2
|
330
|
-
|
331
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"], :skip => 1}
|
332
|
-
|
333
|
-
hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
|
334
|
-
h0 = hash[0]
|
335
|
-
h1 = hash[1]
|
336
|
-
h0["firstname"].should == "john"
|
337
|
-
h1["firstname"].should == "sam"
|
338
|
-
hash.length.should == 2
|
339
|
-
|
340
|
-
|
341
|
-
options = {:startkey => ["28","male"], :endkey => ["28","male"]}
|
342
|
-
|
343
|
-
hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
|
344
|
-
h0 = hash[0]
|
345
|
-
h1 = hash[1]
|
346
|
-
h0["firstname"].should == "aaron"
|
347
|
-
h1["firstname"].should == "john"
|
348
|
-
hash.length.should == 3
|
349
|
-
|
350
|
-
Couchdb.delete 'fishes',@@auth_session
|
351
|
-
end
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
it "should delete the database" do
|
361
|
-
Couchdb.delete 'contacts',@@auth_session
|
362
|
-
end
|
363
|
-
|
364
|
-
|
365
|
-
end
|