couch-quilt 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/couch-quilt.gemspec +7 -2
- data/lib/couchquilt.rb +3 -0
- data/lib/couchquilt/core_ext/array.rb +37 -0
- data/lib/couchquilt/core_ext/hash.rb +43 -0
- data/lib/couchquilt/database.rb +68 -0
- data/lib/couchquilt/fs.rb +51 -83
- data/lib/couchquilt/mapper.rb +6 -42
- data/lib/couchquilt/version.rb +1 -1
- data/spec/couchquilt/core_ext_spec.rb +111 -0
- data/spec/couchquilt/fs_spec.rb +418 -207
- data/spec/couchquilt/mapper_spec.rb +0 -76
- data/spec/spec_helper.rb +2 -2
- metadata +9 -4
data/lib/couchquilt/mapper.rb
CHANGED
@@ -1,50 +1,16 @@
|
|
1
1
|
module Couchquilt
|
2
2
|
module Mapper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def map_json(json = {})
|
8
|
-
case json
|
9
|
-
when Hash
|
10
|
-
json.keys.sort.map { |k| name_for(k, json[k]) }
|
11
|
-
when Array
|
12
|
-
# using zip for backwards compatibily:
|
13
|
-
# in Ruby 1.9 (and 1.8.7) we could simply use
|
14
|
-
# json.each_with_index.map { |k,i| ... }
|
15
|
-
json.zip((0..json.size).to_a).map { |v,i| name_for(i, v) }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# recursively updates a part of a json hash from fs
|
20
|
-
def map_fs(json, keys = [], value = :empty)
|
21
|
-
return {} if keys.empty?
|
22
|
-
|
23
|
-
insert_as_array = keys.last =~ /.+\.array\Z/
|
24
|
-
key = key_for(keys.shift)
|
25
|
-
if keys.empty?
|
26
|
-
if value.nil? && json.is_a?(Hash)
|
27
|
-
json.delete key
|
28
|
-
elsif value.nil? && json.is_a?(Array)
|
29
|
-
json.delete_at key
|
30
|
-
elsif value == :empty && insert_as_array
|
31
|
-
json[key] = []
|
32
|
-
elsif value == :empty
|
33
|
-
json[key] = {}
|
34
|
-
else
|
35
|
-
json[key] = value
|
36
|
-
end
|
37
|
-
else
|
38
|
-
json[key] = map_fs(json[key], keys, value)
|
39
|
-
end
|
40
|
-
|
41
|
-
json
|
3
|
+
def to_parts(path = nil)
|
4
|
+
return [] unless path
|
5
|
+
parts = path.is_a?(Array) ? path.dup : path.split("/")
|
6
|
+
parts.map! { |p| key_for p }
|
42
7
|
end
|
43
8
|
|
44
9
|
# remove fs mapping extnames
|
45
10
|
# and converts array entry mappings
|
46
11
|
def key_for(name)
|
47
|
-
|
12
|
+
return name unless name.is_a?(String)
|
13
|
+
if name =~ /\A\d+i(\.js)?\z/
|
48
14
|
name.to_i
|
49
15
|
else
|
50
16
|
name.sub(/((\.(f|i|b))?\.js|\.html|\.array)\z/, "")
|
@@ -57,8 +23,6 @@ module Couchquilt
|
|
57
23
|
basename = key.is_a?(Integer) ? "%di" % key : key.to_s
|
58
24
|
|
59
25
|
case value
|
60
|
-
when Array
|
61
|
-
"#{basename}.array"
|
62
26
|
when Float
|
63
27
|
"#{basename}.f.js"
|
64
28
|
when Integer
|
data/lib/couchquilt/version.rb
CHANGED
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Hash and Array" do
|
4
|
+
describe "at_path" do
|
5
|
+
it "should retrieve top level" do
|
6
|
+
hash = { "a" => 1 }
|
7
|
+
hash.at_path("/").should == hash
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should retrieve value at top level" do
|
11
|
+
hash = { "a" => 1 }
|
12
|
+
hash.at_path("a").should == 1
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should retrieve value at nested level" do
|
16
|
+
hash = { "a" => { "b" => 1 } }
|
17
|
+
hash.at_path("a/b").should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should retrieve value at deep nested level" do
|
21
|
+
hash = { "a" => { "b" => { "c" => 1 } } }
|
22
|
+
hash.at_path("a/b/c").should == 1
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return nil if not present" do
|
26
|
+
hash = { "a" => { "c" => { "c" => 1 } } }
|
27
|
+
hash.at_path("a/b/c").should == nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return part of an array" do
|
31
|
+
hash = { "a" => [1] }
|
32
|
+
hash.at_path("a/0i").should == 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return part of a nested array" do
|
36
|
+
hash = { "a" => [ { "b" => 1 } ] }
|
37
|
+
hash.at_path("a/0i/b").should == 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "update_at_path" do
|
42
|
+
it "should insert value at top level" do
|
43
|
+
hash = { }
|
44
|
+
hash.update_at_path "a", 1
|
45
|
+
hash.should == { "a" => 1 }
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should insert value at nested level" do
|
49
|
+
hash = { }
|
50
|
+
hash.update_at_path "a/b", 1
|
51
|
+
hash.should == { "a" => { "b" => 1 } }
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should insert value at deep nested level" do
|
55
|
+
hash = { }
|
56
|
+
hash.update_at_path "a/b/c", 1
|
57
|
+
hash.should == { "a" => { "b" => { "c" => 1 } } }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "delete_at_path" do
|
62
|
+
it "should delete value at top level" do
|
63
|
+
hash = { "a" => 1, "b" => 1 }
|
64
|
+
hash.delete_at_path "a"
|
65
|
+
hash.should == { "b" => 1 }
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should delete value at nested level" do
|
69
|
+
hash = { "a" => { "b" => 1, "c" => 1 } }
|
70
|
+
hash.delete_at_path "a/b"
|
71
|
+
hash.should == { "a" => { "c" => 1 } }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "to_fs" do
|
76
|
+
it "should map string value" do
|
77
|
+
hash = { "key" => "value" }
|
78
|
+
hash.to_fs.should == ["key.js"]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should map integer value" do
|
82
|
+
hash = { "key" => 1 }
|
83
|
+
hash.to_fs.should == ["key.i.js"]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should map float value" do
|
87
|
+
hash = { "key" => 1.1 }
|
88
|
+
hash.to_fs.should == ["key.f.js"]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should map false value" do
|
92
|
+
hash = { "key" => false }
|
93
|
+
hash.to_fs.should == ["key.b.js"]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should map true value" do
|
97
|
+
hash = { "key" => true }
|
98
|
+
hash.to_fs.should == ["key.b.js"]
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should map hash value" do
|
102
|
+
hash = { "key" => {}}
|
103
|
+
hash.to_fs.should == ["key"]
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should map array value" do
|
107
|
+
hash = { "key" => []}
|
108
|
+
hash.to_fs.should == ["key"]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/spec/couchquilt/fs_spec.rb
CHANGED
@@ -35,476 +35,615 @@ describe Couchquilt::FS do
|
|
35
35
|
}
|
36
36
|
RestClient.put File.join(SERVER_NAME, TESTDB, @design_document["_id"]), @design_document.to_json
|
37
37
|
|
38
|
-
@quilt = Couchquilt::DebuggedFS.new(
|
38
|
+
@quilt = Couchquilt::DebuggedFS.new(SERVER_NAME)
|
39
39
|
end
|
40
40
|
|
41
41
|
after :all do
|
42
42
|
RestClient.delete(File.join(SERVER_NAME, TESTDB))
|
43
43
|
end
|
44
44
|
|
45
|
+
# /
|
45
46
|
describe "/" do
|
47
|
+
before do
|
48
|
+
@path = "/"
|
49
|
+
end
|
50
|
+
|
46
51
|
it "directory? should return true" do
|
47
|
-
@quilt.directory?(
|
52
|
+
@quilt.directory?(@path).should be_true
|
48
53
|
end
|
49
54
|
it "file? should return false" do
|
50
|
-
@quilt.file?(
|
55
|
+
@quilt.file?(@path).should be_false
|
51
56
|
end
|
52
57
|
it "contents should list databases" do
|
53
|
-
@quilt.contents(
|
58
|
+
@quilt.contents(@path).should include(TESTDB)
|
54
59
|
end
|
55
60
|
it "contents should include _uuids" do
|
56
|
-
@quilt.contents(
|
61
|
+
@quilt.contents(@path).should include("_uuids")
|
57
62
|
end
|
58
63
|
it "can_mkdir? should return false" do
|
59
|
-
@quilt.can_mkdir?(
|
64
|
+
@quilt.can_mkdir?(@path).should be_false
|
60
65
|
end
|
61
66
|
it "can_rmdir? should return false" do
|
62
|
-
@quilt.can_rmdir?(
|
67
|
+
@quilt.can_rmdir?(@path).should be_false
|
63
68
|
end
|
64
69
|
|
65
70
|
# /unknown_database
|
66
71
|
describe "unknown_database/" do
|
72
|
+
before do
|
73
|
+
@path = "/unknown_database"
|
74
|
+
end
|
75
|
+
|
67
76
|
it "directory? should return false" do
|
68
|
-
@quilt.directory?(
|
77
|
+
@quilt.directory?(@path).should be_false
|
69
78
|
end
|
70
79
|
it "file? should return false" do
|
71
|
-
@quilt.file?(
|
80
|
+
@quilt.file?(@path).should be_false
|
72
81
|
end
|
73
82
|
it "can_mkdir? should return true" do
|
74
|
-
@quilt.can_mkdir?(
|
83
|
+
@quilt.can_mkdir?(@path).should be_true
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
78
87
|
# /new_database
|
79
88
|
describe "#{TESTDB}-new/" do
|
80
89
|
before do
|
81
|
-
@
|
90
|
+
@path = "/#{TESTDB}-new"
|
82
91
|
end
|
83
92
|
|
84
93
|
it "mkdir should create database which touch _delete should remove" do
|
85
|
-
@quilt.directory?(
|
86
|
-
@quilt.mkdir(
|
87
|
-
@quilt.directory?(
|
88
|
-
@quilt.touch("
|
89
|
-
@quilt.directory?(
|
94
|
+
@quilt.directory?(@path).should be_false
|
95
|
+
@quilt.mkdir(@path).should be_true
|
96
|
+
@quilt.directory?(@path).should be_true
|
97
|
+
@quilt.touch("#{@path}/_delete").should be_true
|
98
|
+
@quilt.directory?(@path).should be_false
|
90
99
|
end
|
91
100
|
end
|
92
101
|
|
93
102
|
# /database_id
|
94
103
|
describe "database_id/" do
|
104
|
+
before do
|
105
|
+
@path = "/#{TESTDB}"
|
106
|
+
end
|
107
|
+
|
95
108
|
it "directory? should return true" do
|
96
|
-
@quilt.directory?(
|
109
|
+
@quilt.directory?(@path).should be_true
|
97
110
|
end
|
98
111
|
it "file? should return false" do
|
99
|
-
@quilt.file?(
|
112
|
+
@quilt.file?(@path).should be_false
|
100
113
|
end
|
101
114
|
it "contents should list documents" do
|
102
|
-
@quilt.contents(
|
115
|
+
@quilt.contents(@path).should == ["_design", "compact_running.b.js", "db_name.js", "disk_format_version.i.js", "disk_size.i.js", "doc_count.i.js", "doc_del_count.i.js", "document_id", "instance_start_time.js", "purge_seq.i.js", "update_seq.i.js"]
|
103
116
|
end
|
104
117
|
it "can_mkdir? should return false" do
|
105
|
-
@quilt.can_mkdir?(
|
118
|
+
@quilt.can_mkdir?(@path).should be_false
|
106
119
|
end
|
107
120
|
it "can_rmdir? should return false" do
|
108
|
-
@quilt.can_rmdir?(
|
121
|
+
@quilt.can_rmdir?(@path).should be_false
|
109
122
|
end
|
110
123
|
|
111
124
|
# /database_id/db_name.js
|
112
125
|
describe "db_name.js" do
|
126
|
+
before do
|
127
|
+
@path = "/#{TESTDB}/db_name.js"
|
128
|
+
end
|
129
|
+
|
113
130
|
it "directory? should return false" do
|
114
|
-
@quilt.directory?(
|
131
|
+
@quilt.directory?(@path).should be_false
|
115
132
|
end
|
116
133
|
it "file? should return true" do
|
117
|
-
@quilt.file?(
|
134
|
+
@quilt.file?(@path).should be_true
|
118
135
|
end
|
119
136
|
it "read_file should return contents" do
|
120
|
-
@quilt.read_file(
|
137
|
+
@quilt.read_file(@path).should == TESTDB
|
121
138
|
end
|
122
139
|
it "can_write? should return false" do
|
123
|
-
@quilt.can_write?(
|
140
|
+
@quilt.can_write?(@path).should be_false
|
124
141
|
end
|
125
142
|
it "can_delete? should return false" do
|
126
|
-
@quilt.can_delete?(
|
143
|
+
@quilt.can_delete?(@path).should be_false
|
127
144
|
end
|
128
145
|
end
|
129
146
|
|
130
147
|
# /database_id/doc_count.i.js
|
131
148
|
describe "doc_count.i.js" do
|
149
|
+
before do
|
150
|
+
@path = "/#{TESTDB}/doc_count.i.js"
|
151
|
+
end
|
152
|
+
|
132
153
|
it "directory? should return false" do
|
133
|
-
@quilt.directory?(
|
154
|
+
@quilt.directory?(@path).should be_false
|
134
155
|
end
|
135
156
|
it "file? should return true" do
|
136
|
-
@quilt.file?(
|
157
|
+
@quilt.file?(@path).should be_true
|
137
158
|
end
|
138
159
|
it "read_file should return contents" do
|
139
|
-
@quilt.read_file(
|
160
|
+
@quilt.read_file(@path).should == "2"
|
140
161
|
end
|
141
162
|
it "can_write? should return false" do
|
142
|
-
@quilt.can_write?(
|
163
|
+
@quilt.can_write?(@path).should be_false
|
143
164
|
end
|
144
165
|
it "can_delete? should return false" do
|
145
|
-
@quilt.can_delete?(
|
166
|
+
@quilt.can_delete?(@path).should be_false
|
146
167
|
end
|
147
168
|
end
|
148
169
|
|
149
170
|
# /database_id/unknown_document
|
150
171
|
describe "unknown_document/" do
|
172
|
+
before do
|
173
|
+
@path = "/#{TESTDB}/unknown_document"
|
174
|
+
end
|
175
|
+
|
151
176
|
it "directory? should return false" do
|
152
|
-
@quilt.directory?(
|
177
|
+
@quilt.directory?(@path).should be_false
|
153
178
|
end
|
154
179
|
it "file? should return false" do
|
155
|
-
@quilt.file?(
|
180
|
+
@quilt.file?(@path).should be_false
|
156
181
|
end
|
157
182
|
it "can_mkdir? should return true" do
|
158
|
-
@quilt.can_mkdir?(
|
183
|
+
@quilt.can_mkdir?(@path).should be_true
|
159
184
|
end
|
160
185
|
it "can_rmdir? should return false" do
|
161
|
-
@quilt.can_rmdir?(
|
186
|
+
@quilt.can_rmdir?(@path).should be_false
|
162
187
|
end
|
163
188
|
end
|
164
189
|
|
165
190
|
# /database_id/document_id
|
166
191
|
describe "document_id/" do
|
192
|
+
before do
|
193
|
+
@path = "/#{TESTDB}/document_id"
|
194
|
+
end
|
195
|
+
|
167
196
|
it "directory? should return true" do
|
168
|
-
@quilt.directory?(
|
197
|
+
@quilt.directory?(@path).should be_true
|
169
198
|
end
|
170
199
|
it "file? should return false" do
|
171
|
-
@quilt.file?(
|
200
|
+
@quilt.file?(@path).should be_false
|
172
201
|
end
|
173
202
|
it "contents should list documents content" do
|
174
|
-
@quilt.contents(
|
203
|
+
@quilt.contents(@path).should == ["_id.js", "_rev.js", "array", "boolean.b.js", "empty", "float.f.js", "integer.i.js", "name.js", "object"]
|
175
204
|
end
|
176
205
|
it "can_mkdir? should return false" do
|
177
|
-
@quilt.can_mkdir?(
|
206
|
+
@quilt.can_mkdir?(@path).should be_false
|
178
207
|
end
|
179
208
|
it "can_rmdir? should return false" do
|
180
|
-
@quilt.can_rmdir?(
|
209
|
+
@quilt.can_rmdir?(@path).should be_false
|
181
210
|
end
|
182
211
|
it "touch _delete should delete document" do
|
183
|
-
@quilt.touch("
|
184
|
-
@quilt.directory?(
|
212
|
+
@quilt.touch("#{@path}/_delete").should be_true
|
213
|
+
@quilt.directory?(@path).should be_false
|
185
214
|
end
|
186
215
|
|
187
216
|
# /database_id/document_id/unknown_attribute
|
188
217
|
describe "unknown_attribute/" do
|
218
|
+
before do
|
219
|
+
@path = "/#{TESTDB}/document_id/unknown_attribute"
|
220
|
+
end
|
221
|
+
|
189
222
|
it "directory? should return false" do
|
190
|
-
@quilt.directory?(
|
223
|
+
@quilt.directory?(@path).should be_false
|
191
224
|
end
|
192
225
|
it "file? should return false" do
|
193
|
-
@quilt.file?(
|
226
|
+
@quilt.file?(@path).should be_false
|
194
227
|
end
|
195
228
|
it "can_mkdir? should return true" do
|
196
|
-
@quilt.can_mkdir?(
|
229
|
+
@quilt.can_mkdir?(@path).should be_true
|
197
230
|
end
|
198
231
|
it "mkdir should update document while rmdir should reset it" do
|
199
|
-
@quilt.mkdir(
|
200
|
-
@quilt.directory?(
|
201
|
-
@quilt.rmdir(
|
202
|
-
@quilt.directory?(
|
232
|
+
@quilt.mkdir(@path).should be_true
|
233
|
+
@quilt.directory?(@path).should be_true
|
234
|
+
@quilt.rmdir(@path).should be_true
|
235
|
+
@quilt.directory?(@path).should be_false
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "0i.js" do
|
239
|
+
before do
|
240
|
+
@base_path = "/#{TESTDB}/document_id/unknown_attribute"
|
241
|
+
@path = "#{@base_path}/0i.js"
|
242
|
+
@quilt.mkdir(@base_path)
|
243
|
+
end
|
244
|
+
|
245
|
+
after do
|
246
|
+
@quilt.rmdir(@base_path)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "directory? should return true for base path" do
|
250
|
+
@quilt.directory?(@base_path).should be_true
|
251
|
+
end
|
252
|
+
it "directory? should return false" do
|
253
|
+
@quilt.directory?(@path).should be_false
|
254
|
+
end
|
255
|
+
it "file? should return false" do
|
256
|
+
@quilt.file?(@path).should be_false
|
257
|
+
end
|
258
|
+
it "can_write? should return true" do
|
259
|
+
@quilt.can_write?(@path).should be_true
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "write should change base path to array" do
|
263
|
+
before do
|
264
|
+
@quilt.write_to(@path, "value")
|
265
|
+
end
|
266
|
+
|
267
|
+
after do
|
268
|
+
@quilt.delete(@path)
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should be a file" do
|
272
|
+
@quilt.file?(@path).should be_true
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should be an array" do
|
276
|
+
couch = Couchquilt::CouchClient.new(SERVER_NAME)
|
277
|
+
doc = couch.get("/#{TESTDB}/document_id")
|
278
|
+
doc["unknown_attribute"].should be_an(Array)
|
279
|
+
end
|
280
|
+
end
|
203
281
|
end
|
204
282
|
end
|
205
283
|
|
206
284
|
# /database_id/document_id/_id.js
|
207
285
|
describe "_id.js" do
|
286
|
+
before do
|
287
|
+
@path = "/#{TESTDB}/document_id/_id.js"
|
288
|
+
end
|
289
|
+
|
208
290
|
it "directory? should return false" do
|
209
|
-
@quilt.directory?(
|
291
|
+
@quilt.directory?(@path).should be_false
|
210
292
|
end
|
211
293
|
it "file? should return true" do
|
212
|
-
@quilt.file?(
|
294
|
+
@quilt.file?(@path).should be_true
|
213
295
|
end
|
214
296
|
it "read_file should return contents" do
|
215
|
-
@quilt.read_file(
|
297
|
+
@quilt.read_file(@path).should == "document_id"
|
216
298
|
end
|
217
299
|
it "can_write? should return false" do
|
218
|
-
@quilt.can_write?(
|
300
|
+
@quilt.can_write?(@path).should be_false
|
219
301
|
end
|
220
302
|
it "can_delete? should return false" do
|
221
|
-
@quilt.can_delete?(
|
303
|
+
@quilt.can_delete?(@path).should be_false
|
222
304
|
end
|
223
305
|
end
|
224
306
|
|
225
307
|
# /database_id/document_id/name.js
|
226
308
|
describe "name.js" do
|
309
|
+
before do
|
310
|
+
@path = "/#{TESTDB}/document_id/name.js"
|
311
|
+
end
|
312
|
+
|
227
313
|
it "directory? should return false" do
|
228
|
-
@quilt.directory?(
|
314
|
+
@quilt.directory?(@path).should be_false
|
229
315
|
end
|
230
316
|
it "file? should return true" do
|
231
|
-
@quilt.file?(
|
317
|
+
@quilt.file?(@path).should be_true
|
232
318
|
end
|
233
319
|
it "read_file should return contents" do
|
234
|
-
@quilt.read_file(
|
320
|
+
@quilt.read_file(@path).should == @document["name"]
|
235
321
|
end
|
236
322
|
it "can_write? should return true" do
|
237
|
-
@quilt.can_write?(
|
323
|
+
@quilt.can_write?(@path).should be_true
|
238
324
|
end
|
239
325
|
it "write_to should update document" do
|
240
|
-
@quilt.write_to(
|
326
|
+
@quilt.write_to(@path, "value").should be_true
|
241
327
|
end
|
242
328
|
it "can_delete? should return false" do
|
243
|
-
@quilt.can_delete?(
|
329
|
+
@quilt.can_delete?(@path).should be_true
|
244
330
|
end
|
245
331
|
it "delete should update document" do
|
246
|
-
@quilt.delete(
|
247
|
-
@quilt.file?(
|
332
|
+
@quilt.delete(@path).should be_true
|
333
|
+
@quilt.file?(@path).should be_false
|
248
334
|
end
|
249
335
|
end
|
250
336
|
|
251
337
|
# /database_id/document_id/boolean.b.js
|
252
338
|
describe "boolean.b.js" do
|
339
|
+
before do
|
340
|
+
@path = "/#{TESTDB}/document_id/boolean.b.js"
|
341
|
+
end
|
342
|
+
|
253
343
|
it "directory? should return false" do
|
254
|
-
@quilt.directory?(
|
344
|
+
@quilt.directory?(@path).should be_false
|
255
345
|
end
|
256
346
|
it "file? should return true" do
|
257
|
-
@quilt.file?(
|
347
|
+
@quilt.file?(@path).should be_true
|
258
348
|
end
|
259
349
|
it "read_file should return contents" do
|
260
|
-
@quilt.read_file(
|
350
|
+
@quilt.read_file(@path).should == @document["boolean"].to_s
|
261
351
|
end
|
262
352
|
it "can_write? should return true" do
|
263
|
-
@quilt.can_write?(
|
353
|
+
@quilt.can_write?(@path).should be_true
|
264
354
|
end
|
265
355
|
it "write_to should update document" do
|
266
|
-
@quilt.write_to(
|
356
|
+
@quilt.write_to(@path, "value").should be_true
|
267
357
|
end
|
268
358
|
it "can_delete? should return true" do
|
269
|
-
@quilt.can_delete?(
|
359
|
+
@quilt.can_delete?(@path).should be_true
|
270
360
|
end
|
271
361
|
it "delete should update document" do
|
272
|
-
@quilt.delete(
|
273
|
-
@quilt.file?(
|
362
|
+
@quilt.delete(@path).should be_true
|
363
|
+
@quilt.file?(@path).should be_false
|
274
364
|
end
|
275
365
|
end
|
276
366
|
|
277
|
-
|
278
367
|
# /database_id/document_id/object
|
279
368
|
describe "object/" do
|
369
|
+
before do
|
370
|
+
@path = "/#{TESTDB}/document_id/object"
|
371
|
+
end
|
372
|
+
|
280
373
|
it "directory? should return true" do
|
281
|
-
@quilt.directory?(
|
374
|
+
@quilt.directory?(@path).should be_true
|
282
375
|
end
|
283
376
|
it "file? should return false" do
|
284
|
-
@quilt.file?(
|
377
|
+
@quilt.file?(@path).should be_false
|
285
378
|
end
|
286
379
|
it "contents should list object content" do
|
287
|
-
@quilt.contents(
|
380
|
+
@quilt.contents(@path).should == ["key.js"]
|
288
381
|
end
|
289
382
|
it "can_mkdir? should return false" do
|
290
|
-
@quilt.can_mkdir?(
|
383
|
+
@quilt.can_mkdir?(@path).should be_false
|
291
384
|
end
|
292
385
|
it "can_rmdir? should return false when not empty" do
|
293
|
-
@quilt.can_rmdir?(
|
386
|
+
@quilt.can_rmdir?(@path).should be_false
|
294
387
|
end
|
295
388
|
end
|
296
389
|
|
297
390
|
# /database_id/document_id/array
|
298
|
-
describe "array
|
391
|
+
describe "array/" do
|
392
|
+
before do
|
393
|
+
@path = "/#{TESTDB}/document_id/array"
|
394
|
+
end
|
395
|
+
|
299
396
|
it "directory? should return true" do
|
300
|
-
@quilt.directory?(
|
397
|
+
@quilt.directory?(@path).should be_true
|
301
398
|
end
|
302
399
|
it "file? should return false" do
|
303
|
-
@quilt.file?(
|
400
|
+
@quilt.file?(@path).should be_false
|
304
401
|
end
|
305
402
|
it "contents should list array content" do
|
306
|
-
@quilt.contents(
|
403
|
+
@quilt.contents(@path).should == ["0i.js"]
|
307
404
|
end
|
308
405
|
it "can_mkdir? should return false" do
|
309
|
-
@quilt.can_mkdir?(
|
406
|
+
@quilt.can_mkdir?(@path).should be_false
|
310
407
|
end
|
311
408
|
it "can_rmdir? should return false when not empty" do
|
312
|
-
@quilt.can_rmdir?(
|
409
|
+
@quilt.can_rmdir?(@path).should be_false
|
313
410
|
end
|
411
|
+
|
412
|
+
# /database_id/document_id/array/0i.js
|
314
413
|
describe "0i.js" do
|
414
|
+
before do
|
415
|
+
@path = "/#{TESTDB}/document_id/array/0i.js"
|
416
|
+
end
|
417
|
+
|
315
418
|
it "directory? should return false" do
|
316
|
-
@quilt.directory?(
|
419
|
+
@quilt.directory?(@path).should be_false
|
317
420
|
end
|
318
421
|
it "file? should return true" do
|
319
|
-
@quilt.file?(
|
422
|
+
@quilt.file?(@path).should be_true
|
320
423
|
end
|
321
424
|
it "read_file should return contents" do
|
322
|
-
@quilt.read_file(
|
425
|
+
@quilt.read_file(@path).should == @document["array"].first
|
323
426
|
end
|
324
427
|
it "can_write? should return true" do
|
325
|
-
@quilt.can_write?(
|
428
|
+
@quilt.can_write?(@path).should be_true
|
326
429
|
end
|
327
430
|
it "write_to should update document" do
|
328
|
-
@quilt.write_to(
|
431
|
+
@quilt.write_to(@path, "value").should be_true
|
329
432
|
end
|
330
433
|
it "can_delete? should return true" do
|
331
|
-
@quilt.can_delete?(
|
434
|
+
@quilt.can_delete?(@path).should be_true
|
332
435
|
end
|
333
436
|
it "delete should update document" do
|
334
|
-
@quilt.delete(
|
335
|
-
@quilt.file?(
|
437
|
+
@quilt.delete(@path).should be_true
|
438
|
+
@quilt.file?(@path).should be_false
|
336
439
|
end
|
337
440
|
end
|
338
441
|
end
|
339
442
|
|
340
443
|
# /database_id/document_id/empty
|
341
444
|
describe "empty/" do
|
445
|
+
before do
|
446
|
+
@path = "/#{TESTDB}/document_id/empty"
|
447
|
+
end
|
448
|
+
|
342
449
|
it "directory? should return true" do
|
343
|
-
@quilt.directory?(
|
450
|
+
@quilt.directory?(@path).should be_true
|
344
451
|
end
|
345
452
|
it "file? should return false" do
|
346
|
-
@quilt.file?(
|
453
|
+
@quilt.file?(@path).should be_false
|
347
454
|
end
|
348
455
|
it "contents should list empty content" do
|
349
|
-
@quilt.contents(
|
456
|
+
@quilt.contents(@path).should == []
|
350
457
|
end
|
351
458
|
it "can_mkdir? should return false" do
|
352
|
-
@quilt.can_mkdir?(
|
459
|
+
@quilt.can_mkdir?(@path).should be_false
|
353
460
|
end
|
354
461
|
it "can_rmdir? should return true when empty" do
|
355
|
-
@quilt.can_rmdir?(
|
462
|
+
@quilt.can_rmdir?(@path).should be_true
|
356
463
|
end
|
357
464
|
it "rmdir should remove empty from document tree when empty" do
|
358
|
-
@quilt.rmdir(
|
359
|
-
@quilt.directory?(
|
465
|
+
@quilt.rmdir(@path).should be_true
|
466
|
+
@quilt.directory?(@path).should be_false
|
360
467
|
end
|
361
468
|
end
|
362
469
|
end
|
363
470
|
|
364
471
|
# /database_id/_design
|
365
472
|
describe "_design/" do
|
473
|
+
before do
|
474
|
+
@path = "/#{TESTDB}/_design"
|
475
|
+
end
|
476
|
+
|
366
477
|
it "directory? should return true" do
|
367
|
-
@quilt.directory?(
|
478
|
+
@quilt.directory?(@path).should be_true
|
368
479
|
end
|
369
480
|
it "file? should return false" do
|
370
|
-
@quilt.file?(
|
481
|
+
@quilt.file?(@path).should be_false
|
371
482
|
end
|
372
483
|
it "contents should list design documents" do
|
373
|
-
@quilt.contents(
|
484
|
+
@quilt.contents(@path).should == ["design_document_id"]
|
374
485
|
end
|
375
486
|
it "can_mkdir? should return false" do
|
376
|
-
@quilt.can_mkdir?(
|
487
|
+
@quilt.can_mkdir?(@path).should be_false
|
377
488
|
end
|
378
489
|
it "can_rmdir? should return false" do
|
379
|
-
@quilt.can_rmdir?(
|
490
|
+
@quilt.can_rmdir?(@path).should be_false
|
380
491
|
end
|
381
492
|
|
382
493
|
# /database_id/_design/new_design_document_id
|
383
494
|
describe "new_design_document_id/" do
|
495
|
+
before do
|
496
|
+
@path = "/#{TESTDB}/_design/new_design_document_id"
|
497
|
+
end
|
498
|
+
|
384
499
|
it "mkdir should create design document which touch _delete should remove" do
|
385
|
-
@quilt.directory?(
|
386
|
-
@quilt.mkdir(
|
387
|
-
@quilt.directory?(
|
388
|
-
@quilt.touch("
|
389
|
-
@quilt.directory?(
|
500
|
+
@quilt.directory?(@path).should be_false
|
501
|
+
@quilt.mkdir(@path).should be_true
|
502
|
+
@quilt.directory?(@path).should be_true
|
503
|
+
@quilt.touch("#{@path}/_delete").should be_true
|
504
|
+
@quilt.directory?(@path).should be_false
|
390
505
|
end
|
391
506
|
end
|
392
507
|
|
393
508
|
# /database_id/_design/design_document_id
|
394
509
|
describe "design_document_id/" do
|
510
|
+
before do
|
511
|
+
@path = "/#{TESTDB}/_design/design_document_id"
|
512
|
+
end
|
513
|
+
|
395
514
|
it "directory? should return true" do
|
396
|
-
@quilt.directory?(
|
515
|
+
@quilt.directory?(@path).should be_true
|
397
516
|
end
|
398
517
|
it "file? should return false" do
|
399
|
-
@quilt.file?(
|
518
|
+
@quilt.file?(@path).should be_false
|
400
519
|
end
|
401
520
|
it "contents should list design documents content" do
|
402
|
-
@quilt.contents(
|
521
|
+
@quilt.contents(@path).should == ["_id.js", "_list", "_rev.js", "_show", "_view", "language.js", "lists", "name.js", "shows", "views"]
|
403
522
|
end
|
404
523
|
it "can_mkdir? should return false" do
|
405
|
-
@quilt.can_mkdir?(
|
524
|
+
@quilt.can_mkdir?(@path).should be_false
|
406
525
|
end
|
407
526
|
it "can_rmdir? should return false" do
|
408
|
-
@quilt.can_rmdir?(
|
527
|
+
@quilt.can_rmdir?(@path).should be_false
|
409
528
|
end
|
410
529
|
|
411
530
|
# /database_id/_design/design_document_id/_id.js
|
412
531
|
describe "_id.js" do
|
532
|
+
before do
|
533
|
+
@path = "/#{TESTDB}/_design/design_document_id/_id.js"
|
534
|
+
end
|
535
|
+
|
413
536
|
it "directory? should return false" do
|
414
|
-
@quilt.directory?(
|
537
|
+
@quilt.directory?(@path).should be_false
|
415
538
|
end
|
416
539
|
it "file? should return true" do
|
417
|
-
@quilt.file?(
|
540
|
+
@quilt.file?(@path).should be_true
|
418
541
|
end
|
419
542
|
it "read_file should return value" do
|
420
|
-
@quilt.read_file(
|
543
|
+
@quilt.read_file(@path).should == @design_document["_id"]
|
421
544
|
end
|
422
545
|
it "can_write? should return false" do
|
423
|
-
@quilt.can_write?(
|
546
|
+
@quilt.can_write?(@path).should be_false
|
424
547
|
end
|
425
548
|
it "can_delete? should return false" do
|
426
|
-
@quilt.can_delete?(
|
549
|
+
@quilt.can_delete?(@path).should be_false
|
427
550
|
end
|
428
551
|
end
|
429
552
|
|
430
553
|
# /database_id/_design/design_document_id/name.js
|
431
554
|
describe "name.js" do
|
555
|
+
before do
|
556
|
+
@path = "/#{TESTDB}/_design/design_document_id/name.js"
|
557
|
+
end
|
558
|
+
|
432
559
|
it "directory? should return false" do
|
433
|
-
@quilt.directory?(
|
560
|
+
@quilt.directory?(@path).should be_false
|
434
561
|
end
|
435
562
|
it "file? should return true" do
|
436
|
-
@quilt.file?(
|
563
|
+
@quilt.file?(@path).should be_true
|
437
564
|
end
|
438
565
|
it "read_file should return value" do
|
439
|
-
@quilt.read_file(
|
566
|
+
@quilt.read_file(@path).should == @design_document["name"]
|
440
567
|
end
|
441
568
|
it "can_write? should return true" do
|
442
|
-
@quilt.can_write?(
|
569
|
+
@quilt.can_write?(@path).should be_true
|
443
570
|
end
|
444
571
|
it "write_to should update _design/design_document_id" do
|
445
|
-
@quilt.write_to(
|
572
|
+
@quilt.write_to(@path, "value").should be_true
|
446
573
|
end
|
447
574
|
it "can_delete? should return true" do
|
448
|
-
@quilt.can_delete?(
|
575
|
+
@quilt.can_delete?(@path).should be_true
|
449
576
|
end
|
450
577
|
it "delete should update design document" do
|
451
|
-
@quilt.delete(
|
452
|
-
@quilt.file?(
|
578
|
+
@quilt.delete(@path).should be_true
|
579
|
+
@quilt.file?(@path).should be_false
|
453
580
|
end
|
454
581
|
end
|
455
582
|
|
456
583
|
# /database_id/_design/design_document_id/_list
|
457
584
|
describe "_list/" do
|
585
|
+
before do
|
586
|
+
@path = "/#{TESTDB}/_design/design_document_id/_list"
|
587
|
+
end
|
588
|
+
|
458
589
|
it "directory? should return true" do
|
459
|
-
@quilt.directory?(
|
590
|
+
@quilt.directory?(@path).should be_true
|
460
591
|
end
|
461
592
|
it "file? should return false" do
|
462
|
-
@quilt.file?(
|
593
|
+
@quilt.file?(@path).should be_false
|
463
594
|
end
|
464
595
|
it "contents should list list functions" do
|
465
|
-
@quilt.contents(
|
596
|
+
@quilt.contents(@path).should == ["list_function_name"]
|
466
597
|
end
|
467
598
|
it "can_mkdir? should return false" do
|
468
|
-
@quilt.can_mkdir?(
|
599
|
+
@quilt.can_mkdir?(@path).should be_false
|
469
600
|
end
|
470
601
|
it "can_rmdir? should return false" do
|
471
|
-
@quilt.can_rmdir?(
|
602
|
+
@quilt.can_rmdir?(@path).should be_false
|
472
603
|
end
|
473
604
|
|
474
605
|
# /database_id/_design/design_document_id/_list/list_function_name
|
475
606
|
describe "list_function_name/" do
|
607
|
+
before do
|
608
|
+
@path = "/#{TESTDB}/_design/design_document_id/_list/list_function_name"
|
609
|
+
end
|
610
|
+
|
476
611
|
it "directory? should return true" do
|
477
|
-
@quilt.directory?(
|
612
|
+
@quilt.directory?(@path).should be_true
|
478
613
|
end
|
479
614
|
it "file? should return false" do
|
480
|
-
@quilt.file?(
|
615
|
+
@quilt.file?(@path).should be_false
|
481
616
|
end
|
482
617
|
it "contents should list views" do
|
483
|
-
@quilt.contents(
|
618
|
+
@quilt.contents(@path).should == ["view_function_name.html"]
|
484
619
|
end
|
485
620
|
it "can_mkdir? should return false" do
|
486
|
-
@quilt.can_mkdir?(
|
621
|
+
@quilt.can_mkdir?(@path).should be_false
|
487
622
|
end
|
488
623
|
it "can_rmdir? should return false" do
|
489
|
-
@quilt.can_rmdir?(
|
624
|
+
@quilt.can_rmdir?(@path).should be_false
|
490
625
|
end
|
491
626
|
|
492
627
|
# /database_id/_design/design_document_id/_list/list_function_name/view_function_name.html
|
493
628
|
describe "view_function_name.html" do
|
629
|
+
before do
|
630
|
+
@path = "/#{TESTDB}/_design/design_document_id/_list/list_function_name/view_function_name.html"
|
631
|
+
end
|
632
|
+
|
494
633
|
it "directory? should return false" do
|
495
|
-
@quilt.directory?(
|
634
|
+
@quilt.directory?(@path).should be_false
|
496
635
|
end
|
497
636
|
it "file? should return true" do
|
498
|
-
@quilt.file?(
|
637
|
+
@quilt.file?(@path).should be_true
|
499
638
|
end
|
500
639
|
it "read_file should return contents" do
|
501
|
-
@quilt.read_file(
|
640
|
+
@quilt.read_file(@path).should == "Hello World!"
|
502
641
|
end
|
503
642
|
it "can_write? should return false" do
|
504
|
-
@quilt.can_write?(
|
643
|
+
@quilt.can_write?(@path).should be_false
|
505
644
|
end
|
506
645
|
it "can_delete? should return false" do
|
507
|
-
@quilt.can_delete?(
|
646
|
+
@quilt.can_delete?(@path).should be_false
|
508
647
|
end
|
509
648
|
end
|
510
649
|
end
|
@@ -512,56 +651,68 @@ describe Couchquilt::FS do
|
|
512
651
|
|
513
652
|
# /database_id/_design/design_document_id/_show
|
514
653
|
describe "_show/" do
|
654
|
+
before do
|
655
|
+
@path = "/#{TESTDB}/_design/design_document_id/_show"
|
656
|
+
end
|
657
|
+
|
515
658
|
it "directory? should return true" do
|
516
|
-
@quilt.directory?(
|
659
|
+
@quilt.directory?(@path).should be_true
|
517
660
|
end
|
518
661
|
it "file? should return false" do
|
519
|
-
@quilt.file?(
|
662
|
+
@quilt.file?(@path).should be_false
|
520
663
|
end
|
521
664
|
it "contents should list show functions" do
|
522
|
-
@quilt.contents(
|
665
|
+
@quilt.contents(@path).should == ["show_function_name"]
|
523
666
|
end
|
524
667
|
it "can_mkdir? should return false" do
|
525
|
-
@quilt.can_mkdir?(
|
668
|
+
@quilt.can_mkdir?(@path).should be_false
|
526
669
|
end
|
527
670
|
it "can_rmdir? should return false" do
|
528
|
-
@quilt.can_rmdir?(
|
671
|
+
@quilt.can_rmdir?(@path).should be_false
|
529
672
|
end
|
530
673
|
|
531
674
|
# /database_id/_design/design_document_id/_show/show_function_name
|
532
675
|
describe "show_function_name/" do
|
676
|
+
before do
|
677
|
+
@path = "/#{TESTDB}/_design/design_document_id/_show/show_function_name"
|
678
|
+
end
|
679
|
+
|
533
680
|
it "directory? should return true" do
|
534
|
-
@quilt.directory?(
|
681
|
+
@quilt.directory?(@path).should be_true
|
535
682
|
end
|
536
683
|
it "file? should return false" do
|
537
|
-
@quilt.file?(
|
684
|
+
@quilt.file?(@path).should be_false
|
538
685
|
end
|
539
686
|
it "contents should list documents" do
|
540
|
-
@quilt.contents(
|
687
|
+
@quilt.contents(@path).should == ["document_id.html"]
|
541
688
|
end
|
542
689
|
it "can_mkdir? should return false" do
|
543
|
-
@quilt.can_mkdir?(
|
690
|
+
@quilt.can_mkdir?(@path).should be_false
|
544
691
|
end
|
545
692
|
it "can_rmdir? should return false" do
|
546
|
-
@quilt.can_rmdir?(
|
693
|
+
@quilt.can_rmdir?(@path).should be_false
|
547
694
|
end
|
548
695
|
|
549
696
|
# /database_id/_design/design_document_id/_show/show_function_name/document_id.html
|
550
697
|
describe "document_id.html" do
|
698
|
+
before do
|
699
|
+
@path = "/#{TESTDB}/_design/design_document_id/_show/show_function_name/document_id.html"
|
700
|
+
end
|
701
|
+
|
551
702
|
it "directory? should return false" do
|
552
|
-
@quilt.directory?(
|
703
|
+
@quilt.directory?(@path).should be_false
|
553
704
|
end
|
554
705
|
it "file? should return true" do
|
555
|
-
@quilt.file?(
|
706
|
+
@quilt.file?(@path).should be_true
|
556
707
|
end
|
557
708
|
it "read_file should return contents" do
|
558
|
-
@quilt.read_file(
|
709
|
+
@quilt.read_file(@path).should == "Hello World!"
|
559
710
|
end
|
560
711
|
it "can_write? should return false" do
|
561
|
-
@quilt.can_write?(
|
712
|
+
@quilt.can_write?(@path).should be_false
|
562
713
|
end
|
563
714
|
it "can_delete? should return false" do
|
564
|
-
@quilt.can_delete?(
|
715
|
+
@quilt.can_delete?(@path).should be_false
|
565
716
|
end
|
566
717
|
end
|
567
718
|
end
|
@@ -569,142 +720,192 @@ describe Couchquilt::FS do
|
|
569
720
|
|
570
721
|
# /database_id/_design/design_document_id/_view
|
571
722
|
describe "_view/" do
|
723
|
+
before do
|
724
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view"
|
725
|
+
end
|
726
|
+
|
572
727
|
it "directory? should return true" do
|
573
|
-
@quilt.directory?(
|
728
|
+
@quilt.directory?(@path).should be_true
|
574
729
|
end
|
575
730
|
it "file? should return false" do
|
576
|
-
@quilt.file?(
|
731
|
+
@quilt.file?(@path).should be_false
|
577
732
|
end
|
578
733
|
it "contents should list view functions" do
|
579
|
-
@quilt.contents(
|
734
|
+
@quilt.contents(@path).should == ["view_function_name"]
|
580
735
|
end
|
581
736
|
it "can_mkdir? should return false" do
|
582
|
-
@quilt.can_mkdir?(
|
737
|
+
@quilt.can_mkdir?(@path).should be_false
|
583
738
|
end
|
584
739
|
it "can_rmdir? should return false" do
|
585
|
-
@quilt.can_rmdir?(
|
740
|
+
@quilt.can_rmdir?(@path).should be_false
|
586
741
|
end
|
587
742
|
|
588
743
|
# /database_id/_design/design_document_id/_view/view_function_name
|
589
744
|
describe "view_function_name/" do
|
745
|
+
before do
|
746
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name"
|
747
|
+
end
|
748
|
+
|
590
749
|
it "directory? should return true" do
|
591
|
-
@quilt.directory?(
|
750
|
+
@quilt.directory?(@path).should be_true
|
592
751
|
end
|
593
752
|
it "file? should return false" do
|
594
|
-
@quilt.file?(
|
753
|
+
@quilt.file?(@path).should be_false
|
595
754
|
end
|
596
755
|
it "contents should list view result document contents" do
|
597
|
-
@quilt.contents(
|
756
|
+
@quilt.contents(@path).should == ["offset.i.js", "rows", "total_rows.i.js"]
|
598
757
|
end
|
599
758
|
it "can_mkdir? should return false" do
|
600
|
-
@quilt.can_mkdir?(
|
759
|
+
@quilt.can_mkdir?(@path).should be_false
|
601
760
|
end
|
602
761
|
it "can_rmdir? should return false" do
|
603
|
-
@quilt.can_rmdir?(
|
762
|
+
@quilt.can_rmdir?(@path).should be_false
|
604
763
|
end
|
764
|
+
|
765
|
+
# /database_id/_design/design_document_id/_view/view_function_name/offset.i.js
|
605
766
|
describe "offset.i.js" do
|
767
|
+
before do
|
768
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/offset.i.js"
|
769
|
+
end
|
770
|
+
|
606
771
|
it "directory? should return false" do
|
607
|
-
@quilt.directory?(
|
772
|
+
@quilt.directory?(@path).should be_false
|
608
773
|
end
|
609
774
|
it "file? should return true" do
|
610
|
-
@quilt.file?(
|
775
|
+
@quilt.file?(@path).should be_true
|
611
776
|
end
|
612
777
|
it "can_delete? should return false" do
|
613
|
-
@quilt.can_delete?(
|
778
|
+
@quilt.can_delete?(@path).should be_false
|
614
779
|
end
|
615
780
|
end
|
781
|
+
|
782
|
+
# /database_id/_design/design_document_id/_view/view_function_name/total_rows.i.js
|
616
783
|
describe "total_rows.i.js" do
|
784
|
+
before do
|
785
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/total_rows.i.js"
|
786
|
+
end
|
787
|
+
|
617
788
|
it "directory? should return false" do
|
618
|
-
@quilt.directory?(
|
789
|
+
@quilt.directory?(@path).should be_false
|
619
790
|
end
|
620
791
|
it "file? should return true" do
|
621
|
-
@quilt.file?(
|
792
|
+
@quilt.file?(@path).should be_true
|
622
793
|
end
|
623
794
|
it "can_delete? should return false" do
|
624
|
-
@quilt.can_delete?(
|
795
|
+
@quilt.can_delete?(@path).should be_false
|
625
796
|
end
|
626
797
|
end
|
627
|
-
|
798
|
+
|
799
|
+
# /database_id/_design/design_document_id/_view/view_function_name/rows
|
800
|
+
describe "rows/" do
|
801
|
+
before do
|
802
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/rows"
|
803
|
+
end
|
804
|
+
|
628
805
|
it "directory? should return true" do
|
629
|
-
@quilt.directory?(
|
806
|
+
@quilt.directory?(@path).should be_true
|
630
807
|
end
|
631
808
|
it "file? should return false" do
|
632
|
-
@quilt.file?(
|
809
|
+
@quilt.file?(@path).should be_false
|
633
810
|
end
|
634
811
|
it "contents should list view rows" do
|
635
|
-
@quilt.contents(
|
812
|
+
@quilt.contents(@path).should == ["0i"]
|
636
813
|
end
|
637
814
|
it "can_mkdir? should return false" do
|
638
|
-
@quilt.can_mkdir?(
|
815
|
+
@quilt.can_mkdir?(@path).should be_false
|
639
816
|
end
|
640
817
|
it "can_rmdir? should return false" do
|
641
|
-
@quilt.can_rmdir?(
|
818
|
+
@quilt.can_rmdir?(@path).should be_false
|
642
819
|
end
|
820
|
+
|
821
|
+
# /database_id/_design/design_document_id/_view/view_function_name/rows/0i
|
643
822
|
describe "0i/" do
|
823
|
+
before do
|
824
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/rows/0i"
|
825
|
+
end
|
826
|
+
|
644
827
|
it "directory? should return true" do
|
645
|
-
@quilt.directory?(
|
828
|
+
@quilt.directory?(@path).should be_true
|
646
829
|
end
|
647
830
|
it "file? should return false" do
|
648
|
-
@quilt.file?(
|
831
|
+
@quilt.file?(@path).should be_false
|
649
832
|
end
|
650
833
|
it "contents should list view result row content" do
|
651
|
-
@quilt.contents(
|
834
|
+
@quilt.contents(@path).should == ["id.js", "key.js", "value.js"]
|
652
835
|
end
|
653
836
|
it "can_mkdir? should return false" do
|
654
|
-
@quilt.can_mkdir?(
|
837
|
+
@quilt.can_mkdir?(@path).should be_false
|
655
838
|
end
|
656
839
|
it "can_rmdir? should return false" do
|
657
|
-
@quilt.can_rmdir?(
|
840
|
+
@quilt.can_rmdir?(@path).should be_false
|
658
841
|
end
|
842
|
+
|
843
|
+
# /database_id/_design/design_document_id/_view/view_function_name/rows/0i/id.js
|
659
844
|
describe "id.js" do
|
845
|
+
before do
|
846
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/rows/0i/id.js"
|
847
|
+
end
|
848
|
+
|
660
849
|
it "directory? should return false" do
|
661
|
-
@quilt.directory?(
|
850
|
+
@quilt.directory?(@path).should be_false
|
662
851
|
end
|
663
852
|
it "file? should return true" do
|
664
|
-
@quilt.file?(
|
853
|
+
@quilt.file?(@path).should be_true
|
665
854
|
end
|
666
855
|
it "read_file should return contents" do
|
667
|
-
@quilt.read_file(
|
856
|
+
@quilt.read_file(@path).should == "document_id"
|
668
857
|
end
|
669
858
|
it "can_write? should return false" do
|
670
|
-
@quilt.can_write?(
|
859
|
+
@quilt.can_write?(@path).should be_false
|
671
860
|
end
|
672
861
|
it "can_delete? should return false" do
|
673
|
-
@quilt.can_delete?(
|
862
|
+
@quilt.can_delete?(@path).should be_false
|
674
863
|
end
|
675
864
|
end
|
865
|
+
|
866
|
+
# /database_id/_design/design_document_id/_view/view_function_name/rows/0i/key.js
|
676
867
|
describe "key.js" do
|
868
|
+
before do
|
869
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/rows/0i/key.js"
|
870
|
+
end
|
871
|
+
|
677
872
|
it "directory? should return false" do
|
678
|
-
@quilt.directory?(
|
873
|
+
@quilt.directory?(@path).should be_false
|
679
874
|
end
|
680
875
|
it "file? should return true" do
|
681
|
-
@quilt.file?(
|
876
|
+
@quilt.file?(@path).should be_true
|
682
877
|
end
|
683
878
|
it "read_file should return contents" do
|
684
|
-
@quilt.read_file(
|
879
|
+
@quilt.read_file(@path).should == "This is a name"
|
685
880
|
end
|
686
881
|
it "can_write? should return false" do
|
687
|
-
@quilt.can_write?(
|
882
|
+
@quilt.can_write?(@path).should be_false
|
688
883
|
end
|
689
884
|
it "can_delete? should return false" do
|
690
|
-
@quilt.can_delete?(
|
885
|
+
@quilt.can_delete?(@path).should be_false
|
691
886
|
end
|
692
887
|
end
|
888
|
+
|
889
|
+
# /database_id/_design/design_document_id/_view/view_function_name/rows/0i/value.js
|
693
890
|
describe "value.js" do
|
891
|
+
before do
|
892
|
+
@path = "/#{TESTDB}/_design/design_document_id/_view/view_function_name/rows/0i/value.js"
|
893
|
+
end
|
894
|
+
|
694
895
|
it "directory? should return false" do
|
695
|
-
@quilt.directory?(
|
896
|
+
@quilt.directory?(@path).should be_false
|
696
897
|
end
|
697
898
|
it "file? should return true" do
|
698
|
-
@quilt.file?(
|
899
|
+
@quilt.file?(@path).should be_true
|
699
900
|
end
|
700
901
|
it "read_file should return contents" do
|
701
|
-
@quilt.read_file(
|
902
|
+
@quilt.read_file(@path).should == ""
|
702
903
|
end
|
703
904
|
it "can_write? should return false" do
|
704
|
-
@quilt.can_write?(
|
905
|
+
@quilt.can_write?(@path).should be_false
|
705
906
|
end
|
706
907
|
it "can_delete? should return false" do
|
707
|
-
@quilt.can_delete?(
|
908
|
+
@quilt.can_delete?(@path).should be_false
|
708
909
|
end
|
709
910
|
end
|
710
911
|
end
|
@@ -717,36 +918,46 @@ describe Couchquilt::FS do
|
|
717
918
|
|
718
919
|
# /_uuids
|
719
920
|
describe "_uuids/" do
|
921
|
+
before do
|
922
|
+
@path = "/_uuids"
|
923
|
+
end
|
924
|
+
|
720
925
|
it "directory? should return true" do
|
721
|
-
@quilt.directory?(
|
926
|
+
@quilt.directory?(@path).should be_true
|
722
927
|
end
|
723
928
|
it "file? should return false" do
|
724
|
-
@quilt.file?(
|
929
|
+
@quilt.file?(@path).should be_false
|
725
930
|
end
|
726
931
|
it "can_mkdir? should return false" do
|
727
|
-
@quilt.can_mkdir?(
|
932
|
+
@quilt.can_mkdir?(@path).should be_false
|
728
933
|
end
|
729
934
|
it "can_rmdir? should return false" do
|
730
|
-
@quilt.can_rmdir?(
|
935
|
+
@quilt.can_rmdir?(@path).should be_false
|
731
936
|
end
|
732
937
|
it "contents should include 0i.js" do
|
733
|
-
@quilt.contents(
|
938
|
+
@quilt.contents(@path).should == ["0i.js"]
|
734
939
|
end
|
940
|
+
|
941
|
+
# /_uuids/0i.js
|
735
942
|
describe "0i.js" do
|
943
|
+
before do
|
944
|
+
@path = "/_uuids/0i.js"
|
945
|
+
end
|
946
|
+
|
736
947
|
it "directory? should return false" do
|
737
|
-
@quilt.directory?(
|
948
|
+
@quilt.directory?(@path).should be_false
|
738
949
|
end
|
739
950
|
it "file? should return true" do
|
740
|
-
@quilt.file?(
|
951
|
+
@quilt.file?(@path).should be_true
|
741
952
|
end
|
742
953
|
it "can_delete? should return false" do
|
743
|
-
@quilt.can_delete?(
|
954
|
+
@quilt.can_delete?(@path).should be_false
|
744
955
|
end
|
745
956
|
it "can_write? should return false" do
|
746
|
-
@quilt.can_write?(
|
957
|
+
@quilt.can_write?(@path).should be_false
|
747
958
|
end
|
748
959
|
it "read_file should return contents" do
|
749
|
-
@quilt.read_file(
|
960
|
+
@quilt.read_file(@path).should =~ /\A[a-z0-9]{32}\z/
|
750
961
|
end
|
751
962
|
end
|
752
963
|
end
|