couchdb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +47 -0
- data/Rakefile +48 -0
- data/lib/couchdb.rb +12 -0
- data/lib/couchdb/collection.rb +121 -0
- data/lib/couchdb/database.rb +57 -0
- data/lib/couchdb/design.rb +57 -0
- data/lib/couchdb/design/view.rb +37 -0
- data/lib/couchdb/document.rb +127 -0
- data/lib/couchdb/row.rb +22 -0
- data/lib/couchdb/server.rb +42 -0
- data/spec/acceptance/database_spec.rb +56 -0
- data/spec/acceptance/document_spec.rb +78 -0
- data/spec/acceptance/server_spec.rb +43 -0
- data/spec/acceptance/views_spec.rb +49 -0
- data/spec/lib/couchdb/collection_spec.rb +121 -0
- data/spec/lib/couchdb/database_spec.rb +138 -0
- data/spec/lib/couchdb/design/view_spec.rb +89 -0
- data/spec/lib/couchdb/design_spec.rb +99 -0
- data/spec/lib/couchdb/document_spec.rb +322 -0
- data/spec/lib/couchdb/row_spec.rb +56 -0
- data/spec/lib/couchdb/server_spec.rb +87 -0
- data/spec/spec_helper.rb +5 -0
- metadata +137 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
|
2
|
+
|
3
|
+
describe CouchDB::Row do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@database = mock CouchDB::Database
|
7
|
+
@hash = {
|
8
|
+
"id" => "test id",
|
9
|
+
"key" => "test key",
|
10
|
+
"value" => "test value",
|
11
|
+
"doc" => {
|
12
|
+
"_id" => "test doc id",
|
13
|
+
"name" => "test doc name"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
@row = described_class.new @database, @hash
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "initialize" do
|
20
|
+
|
21
|
+
it "should assign the database" do
|
22
|
+
@row.database.should == @database
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should assign the id" do
|
26
|
+
@row.id.should == "test id"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should assign the key" do
|
30
|
+
@row.key.should == "test key"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should assign the id" do
|
34
|
+
@row.value.should == "test value"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "document" do
|
40
|
+
|
41
|
+
it "should return a document" do
|
42
|
+
@row.document.should be_instance_of(CouchDB::Document)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return a document with the right database" do
|
46
|
+
@row.document.database.should == @database
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a document with the right properties" do
|
50
|
+
@row.document.id.should == "test doc id"
|
51
|
+
@row.document["name"].should == "test doc name"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
|
2
|
+
|
3
|
+
describe CouchDB::Server do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
Transport::JSON.stub(:request)
|
7
|
+
@server = CouchDB::Server.new "host", 1234
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "initialize" do
|
11
|
+
|
12
|
+
it "should set the host" do
|
13
|
+
@server.host.should == "host"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set the port" do
|
17
|
+
@server.port.should == 1234
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "==" do
|
23
|
+
|
24
|
+
it "should be true when comparing two equal servers" do
|
25
|
+
@server.should == described_class.new("host", 1234)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be false when comparing two different servers" do
|
29
|
+
@server.should_not == described_class.new("other", 1234)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "information" do
|
35
|
+
|
36
|
+
it "should request server information" do
|
37
|
+
Transport::JSON.should_receive(:request).with(
|
38
|
+
:get,
|
39
|
+
"http://host:1234/",
|
40
|
+
:expected_status_code => 200
|
41
|
+
).and_return("result")
|
42
|
+
@server.information.should == "result"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "statistics" do
|
48
|
+
|
49
|
+
it "should request server statistics" do
|
50
|
+
Transport::JSON.should_receive(:request).with(
|
51
|
+
:get,
|
52
|
+
"http://host:1234/_stats",
|
53
|
+
:expected_status_code => 200
|
54
|
+
).and_return("result")
|
55
|
+
@server.statistics.should == "result"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "database_names" do
|
61
|
+
|
62
|
+
it "should request the names of all databases" do
|
63
|
+
Transport::JSON.should_receive(:request).with(
|
64
|
+
:get,
|
65
|
+
"http://host:1234/_all_dbs",
|
66
|
+
:expected_status_code => 200
|
67
|
+
).and_return("result")
|
68
|
+
@server.database_names.should == "result"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "uuids" do
|
74
|
+
|
75
|
+
it "should request a given number of uuids" do
|
76
|
+
Transport::JSON.should_receive(:request).with(
|
77
|
+
:get,
|
78
|
+
"http://host:1234/_uuids",
|
79
|
+
:expected_status_code => 200,
|
80
|
+
:parameters => { :count => 3 }
|
81
|
+
).and_return({ "uuids" => "result" })
|
82
|
+
@server.uuids(3).should == "result"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: couchdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "Philipp Br\xC3\xBCll"
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-07 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: transport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 1
|
32
|
+
version: 1.0.1
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
version: "2"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: reek
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 2
|
59
|
+
version: "1.2"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
description: A straight-forward client for CouchDB REST API. The resources exposed by the API are simply wrapped into classes.
|
63
|
+
email: b.phifty@gmail.com
|
64
|
+
executables: []
|
65
|
+
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
extra_rdoc_files:
|
69
|
+
- README.rdoc
|
70
|
+
files:
|
71
|
+
- README.rdoc
|
72
|
+
- LICENSE
|
73
|
+
- Rakefile
|
74
|
+
- lib/couchdb/server.rb
|
75
|
+
- lib/couchdb/design/view.rb
|
76
|
+
- lib/couchdb/design.rb
|
77
|
+
- lib/couchdb/database.rb
|
78
|
+
- lib/couchdb/row.rb
|
79
|
+
- lib/couchdb/collection.rb
|
80
|
+
- lib/couchdb/document.rb
|
81
|
+
- lib/couchdb.rb
|
82
|
+
- spec/lib/couchdb/design/view_spec.rb
|
83
|
+
- spec/lib/couchdb/collection_spec.rb
|
84
|
+
- spec/lib/couchdb/row_spec.rb
|
85
|
+
- spec/lib/couchdb/document_spec.rb
|
86
|
+
- spec/lib/couchdb/database_spec.rb
|
87
|
+
- spec/lib/couchdb/server_spec.rb
|
88
|
+
- spec/lib/couchdb/design_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/acceptance/document_spec.rb
|
91
|
+
- spec/acceptance/database_spec.rb
|
92
|
+
- spec/acceptance/views_spec.rb
|
93
|
+
- spec/acceptance/server_spec.rb
|
94
|
+
has_rdoc: true
|
95
|
+
homepage: http://github.com/phifty/couchdb
|
96
|
+
licenses: []
|
97
|
+
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: couchdb
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: A straight-forward client for CouchDB REST API.
|
126
|
+
test_files:
|
127
|
+
- spec/lib/couchdb/design/view_spec.rb
|
128
|
+
- spec/lib/couchdb/collection_spec.rb
|
129
|
+
- spec/lib/couchdb/row_spec.rb
|
130
|
+
- spec/lib/couchdb/document_spec.rb
|
131
|
+
- spec/lib/couchdb/database_spec.rb
|
132
|
+
- spec/lib/couchdb/server_spec.rb
|
133
|
+
- spec/lib/couchdb/design_spec.rb
|
134
|
+
- spec/acceptance/document_spec.rb
|
135
|
+
- spec/acceptance/database_spec.rb
|
136
|
+
- spec/acceptance/views_spec.rb
|
137
|
+
- spec/acceptance/server_spec.rb
|