sphinx 0.9.9.2117 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -3
- data/README.rdoc +18 -213
- data/Rakefile +15 -24
- data/VERSION.yml +1 -2
- data/install.rb +5 -0
- data/lib/sphinx/client.rb +893 -2089
- data/lib/sphinx/request.rb +11 -82
- data/lib/sphinx/response.rb +0 -2
- data/lib/sphinx.rb +5 -50
- data/spec/client_response_spec.rb +40 -33
- data/spec/client_spec.rb +471 -669
- data/spec/fixtures/ranking_sph04.php +9 -0
- data/spec/fixtures/sphinxapi.php +69 -54
- data/spec/sphinx/sphinx-id64.conf +1 -1
- data/spec/sphinx/sphinx.conf +1 -1
- data/spec/sphinx/sphinx_test.sql +2 -4
- data/sphinx.gemspec +8 -13
- data/sphinx.yml.tpl +3 -0
- data/tasks/sphinx.rake +75 -0
- metadata +6 -11
- data/lib/sphinx/buffered_io.rb +0 -26
- data/lib/sphinx/constants.rb +0 -179
- data/lib/sphinx/indifferent_access.rb +0 -152
- data/lib/sphinx/server.rb +0 -170
- data/lib/sphinx/timeout.rb +0 -31
- data/spec/client_validations_spec.rb +0 -859
- data/spec/spec_helper.rb +0 -24
@@ -1,859 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Sphinx::Client, 'disconnected' do
|
4
|
-
before :each do
|
5
|
-
@sphinx = Sphinx::Client.new
|
6
|
-
end
|
7
|
-
|
8
|
-
context 'in SetServer method' do
|
9
|
-
it 'should raise an error when host is not String' do
|
10
|
-
expect {
|
11
|
-
@sphinx.SetServer(1234, 1234)
|
12
|
-
}.to raise_error(ArgumentError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should raise an error when port is not Integer' do
|
16
|
-
expect {
|
17
|
-
@sphinx.SetServer('hello', 'world')
|
18
|
-
}.to raise_error(ArgumentError)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'in SetConnectTimeout method' do
|
23
|
-
it 'should raise an error when timeout is not Integer' do
|
24
|
-
expect {
|
25
|
-
@sphinx.SetConnectTimeout('timeout')
|
26
|
-
}.to raise_error(ArgumentError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should raise an error when retries is not Integer' do
|
30
|
-
expect {
|
31
|
-
@sphinx.SetConnectTimeout(1, 'retries')
|
32
|
-
}.to raise_error(ArgumentError)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should raise an error when retries is less than 1' do
|
36
|
-
expect {
|
37
|
-
@sphinx.SetConnectTimeout(1, 0)
|
38
|
-
}.to raise_error(ArgumentError)
|
39
|
-
|
40
|
-
expect {
|
41
|
-
@sphinx.SetConnectTimeout(1, -1)
|
42
|
-
}.to raise_error(ArgumentError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'in SetRequestTimeout method' do
|
47
|
-
it 'should raise an error when timeout is not Integer' do
|
48
|
-
expect {
|
49
|
-
@sphinx.SetRequestTimeout('timeout')
|
50
|
-
}.to raise_error(ArgumentError)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should raise an error when retries is not Integer' do
|
54
|
-
expect {
|
55
|
-
@sphinx.SetRequestTimeout(1, 'retries')
|
56
|
-
}.to raise_error(ArgumentError)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should raise an error when retries is less than 1' do
|
60
|
-
expect {
|
61
|
-
@sphinx.SetRequestTimeout(1, 0)
|
62
|
-
}.to raise_error(ArgumentError)
|
63
|
-
|
64
|
-
expect {
|
65
|
-
@sphinx.SetRequestTimeout(1, -1)
|
66
|
-
}.to raise_error(ArgumentError)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'in SetLimits method' do
|
71
|
-
it 'should raise an error when offset is not Integer' do
|
72
|
-
expect {
|
73
|
-
@sphinx.SetLimits('offset', 1, 0, 0)
|
74
|
-
}.to raise_error(ArgumentError)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should raise an error when limit is not Integer' do
|
78
|
-
expect {
|
79
|
-
@sphinx.SetLimits(0, 'limit', 0, 0)
|
80
|
-
}.to raise_error(ArgumentError)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should raise an error when max is not Integer' do
|
84
|
-
expect {
|
85
|
-
@sphinx.SetLimits(0, 1, 'max', 0)
|
86
|
-
}.to raise_error(ArgumentError)
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should raise an error when cutoff is not Integer' do
|
90
|
-
expect {
|
91
|
-
@sphinx.SetLimits(0, 1, 0, 'cutoff')
|
92
|
-
}.to raise_error(ArgumentError)
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should raise an error when offset is less than zero' do
|
96
|
-
expect {
|
97
|
-
@sphinx.SetLimits(-1, 1, 0, 0)
|
98
|
-
}.to raise_error(ArgumentError)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'should raise an error when limit is less than 1' do
|
102
|
-
expect {
|
103
|
-
@sphinx.SetLimits(0, 0, 0, 0)
|
104
|
-
}.to raise_error(ArgumentError)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should raise an error when max is less than zero' do
|
108
|
-
expect {
|
109
|
-
@sphinx.SetLimits(0, 1, -1, 0)
|
110
|
-
}.to raise_error(ArgumentError)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should raise an error when cutoff is less than zero' do
|
114
|
-
expect {
|
115
|
-
@sphinx.SetLimits(0, 1, 0, -1)
|
116
|
-
}.to raise_error(ArgumentError)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'in SetMaxQueryTime method' do
|
121
|
-
it 'should raise an error when max is not Integer' do
|
122
|
-
expect {
|
123
|
-
@sphinx.SetMaxQueryTime('max')
|
124
|
-
}.to raise_error(ArgumentError)
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
it 'should raise an error when max is less than zero' do
|
129
|
-
expect {
|
130
|
-
@sphinx.SetMaxQueryTime(-1)
|
131
|
-
}.to raise_error(ArgumentError)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context 'in SetMatchMode method' do
|
136
|
-
it 'should raise an error when mode is not Integer, String or Symbol' do
|
137
|
-
expect {
|
138
|
-
@sphinx.SetMatchMode([])
|
139
|
-
}.to raise_error(ArgumentError)
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should raise an error when mode is invalid' do
|
143
|
-
expect {
|
144
|
-
@sphinx.SetMatchMode('invalid')
|
145
|
-
}.to raise_error(ArgumentError)
|
146
|
-
|
147
|
-
expect {
|
148
|
-
@sphinx.SetMatchMode(:invalid)
|
149
|
-
}.to raise_error(ArgumentError)
|
150
|
-
|
151
|
-
expect {
|
152
|
-
@sphinx.SetMatchMode(100)
|
153
|
-
}.to raise_error(ArgumentError)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context 'in SetRankingMode method' do
|
158
|
-
it 'should raise an error when ranker is not Integer, String or Symbol' do
|
159
|
-
expect {
|
160
|
-
@sphinx.SetRankingMode([])
|
161
|
-
}.to raise_error(ArgumentError)
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should raise an error when ranker is invalid' do
|
165
|
-
expect {
|
166
|
-
@sphinx.SetRankingMode('invalid')
|
167
|
-
}.to raise_error(ArgumentError)
|
168
|
-
|
169
|
-
expect {
|
170
|
-
@sphinx.SetRankingMode(:invalid)
|
171
|
-
}.to raise_error(ArgumentError)
|
172
|
-
|
173
|
-
expect {
|
174
|
-
@sphinx.SetRankingMode(100)
|
175
|
-
}.to raise_error(ArgumentError)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context 'in SetSortMode method' do
|
180
|
-
it 'should raise an error when mode is not Integer, String or Symbol' do
|
181
|
-
expect {
|
182
|
-
@sphinx.SetSortMode([])
|
183
|
-
}.to raise_error(ArgumentError)
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'should raise an error when mode is invalid' do
|
187
|
-
expect {
|
188
|
-
@sphinx.SetSortMode('invalid')
|
189
|
-
}.to raise_error(ArgumentError)
|
190
|
-
|
191
|
-
expect {
|
192
|
-
@sphinx.SetSortMode(:invalid)
|
193
|
-
}.to raise_error(ArgumentError)
|
194
|
-
|
195
|
-
expect {
|
196
|
-
@sphinx.SetSortMode(100)
|
197
|
-
}.to raise_error(ArgumentError)
|
198
|
-
end
|
199
|
-
|
200
|
-
it 'should raise an error when sortby is not String' do
|
201
|
-
expect {
|
202
|
-
@sphinx.SetSortMode(:relevance, [])
|
203
|
-
}.to raise_error(ArgumentError)
|
204
|
-
end
|
205
|
-
|
206
|
-
it 'should raise an error when sortby is empty' do
|
207
|
-
expect {
|
208
|
-
@sphinx.SetSortMode(:attr_desc)
|
209
|
-
}.to raise_error(ArgumentError)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context 'in SetWeights method' do
|
214
|
-
it 'should raise an error when weights is not Array' do
|
215
|
-
expect {
|
216
|
-
@sphinx.SetWeights({})
|
217
|
-
}.to raise_error(ArgumentError)
|
218
|
-
end
|
219
|
-
|
220
|
-
it 'should raise an error when weights is not Array of Integers' do
|
221
|
-
expect {
|
222
|
-
@sphinx.SetWeights([1, 'a'])
|
223
|
-
}.to raise_error(ArgumentError)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'in SetFieldWeights method' do
|
228
|
-
it 'should raise an error when weights is not Hash' do
|
229
|
-
expect {
|
230
|
-
@sphinx.SetFieldWeights([])
|
231
|
-
}.to raise_error(ArgumentError)
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'should raise an error when weights is not Hash map of strings to integers' do
|
235
|
-
expect {
|
236
|
-
@sphinx.SetFieldWeights('a' => 'b', :c => 5)
|
237
|
-
}.to raise_error(ArgumentError)
|
238
|
-
|
239
|
-
expect {
|
240
|
-
@sphinx.SetFieldWeights(:a => 'b', :c => 5)
|
241
|
-
}.to raise_error(ArgumentError)
|
242
|
-
|
243
|
-
expect {
|
244
|
-
@sphinx.SetFieldWeights(1 => 1, :c => 5)
|
245
|
-
}.to raise_error(ArgumentError)
|
246
|
-
|
247
|
-
expect {
|
248
|
-
@sphinx.SetFieldWeights(1 => 'a', :c => 5)
|
249
|
-
}.to raise_error(ArgumentError)
|
250
|
-
|
251
|
-
expect {
|
252
|
-
@sphinx.SetFieldWeights(:a => 1, :c => 5)
|
253
|
-
}.to_not raise_error(ArgumentError)
|
254
|
-
|
255
|
-
expect {
|
256
|
-
@sphinx.SetFieldWeights('a' => 1, :c => 5)
|
257
|
-
}.to_not raise_error(ArgumentError)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
context 'in SetIndexWeights method' do
|
262
|
-
it 'should raise an error when weights is not Hash' do
|
263
|
-
expect {
|
264
|
-
@sphinx.SetIndexWeights([])
|
265
|
-
}.to raise_error(ArgumentError)
|
266
|
-
end
|
267
|
-
|
268
|
-
it 'should raise an error when weights is not Hash map of strings to integers' do
|
269
|
-
expect {
|
270
|
-
@sphinx.SetIndexWeights('a' => 'b', :c => 5)
|
271
|
-
}.to raise_error(ArgumentError)
|
272
|
-
|
273
|
-
expect {
|
274
|
-
@sphinx.SetIndexWeights(:a => 'b', :c => 5)
|
275
|
-
}.to raise_error(ArgumentError)
|
276
|
-
|
277
|
-
expect {
|
278
|
-
@sphinx.SetIndexWeights(1 => 1, :c => 5)
|
279
|
-
}.to raise_error(ArgumentError)
|
280
|
-
|
281
|
-
expect {
|
282
|
-
@sphinx.SetIndexWeights(1 => 'a', :c => 5)
|
283
|
-
}.to raise_error(ArgumentError)
|
284
|
-
|
285
|
-
expect {
|
286
|
-
@sphinx.SetIndexWeights(:a => 1, :c => 5)
|
287
|
-
}.to_not raise_error(ArgumentError)
|
288
|
-
|
289
|
-
expect {
|
290
|
-
@sphinx.SetIndexWeights('a' => 1, :c => 5)
|
291
|
-
}.to_not raise_error(ArgumentError)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
context 'in SetIDRange method' do
|
296
|
-
it 'should raise an error when min is not Integer' do
|
297
|
-
expect {
|
298
|
-
@sphinx.SetIDRange('min', 0)
|
299
|
-
}.to raise_error(ArgumentError)
|
300
|
-
end
|
301
|
-
|
302
|
-
it 'should raise an error when max is not Integer' do
|
303
|
-
expect {
|
304
|
-
@sphinx.SetIDRange(0, 'max')
|
305
|
-
}.to raise_error(ArgumentError)
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'should raise an error when max is less than zero' do
|
309
|
-
expect {
|
310
|
-
@sphinx.SetIDRange(2, 1)
|
311
|
-
}.to raise_error(ArgumentError)
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
context 'in SetFilter method' do
|
316
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
317
|
-
expect {
|
318
|
-
@sphinx.SetFilter(1, [1, 2])
|
319
|
-
}.to raise_error(ArgumentError)
|
320
|
-
|
321
|
-
expect {
|
322
|
-
@sphinx.SetFilter('attr', [1, 2])
|
323
|
-
}.to_not raise_error(ArgumentError)
|
324
|
-
|
325
|
-
expect {
|
326
|
-
@sphinx.SetFilter(:attr, [1, 2])
|
327
|
-
}.to_not raise_error(ArgumentError)
|
328
|
-
end
|
329
|
-
|
330
|
-
it 'should raise an error when values is not Array or Integer' do
|
331
|
-
expect {
|
332
|
-
@sphinx.SetFilter(:attr, {})
|
333
|
-
}.to raise_error(ArgumentError)
|
334
|
-
|
335
|
-
expect {
|
336
|
-
@sphinx.SetFilter(:attr, 1)
|
337
|
-
}.to_not raise_error(ArgumentError)
|
338
|
-
|
339
|
-
expect {
|
340
|
-
@sphinx.SetFilter(:attr, [1])
|
341
|
-
}.to_not raise_error(ArgumentError)
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'should raise an error when values is not Array of Integers' do
|
345
|
-
expect {
|
346
|
-
@sphinx.SetFilter(:attr, [1, 'a'])
|
347
|
-
}.to raise_error(ArgumentError)
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'should not raise an error when values is empty Array' do
|
351
|
-
expect {
|
352
|
-
@sphinx.SetFilter(:attr, [])
|
353
|
-
}.to_not raise_error(ArgumentError)
|
354
|
-
@sphinx.instance_variable_get(:@filters).should be_empty
|
355
|
-
end
|
356
|
-
|
357
|
-
it 'should raise an error when exclude is not Boolean' do
|
358
|
-
expect {
|
359
|
-
@sphinx.SetFilter(:attr, [1, 2], 'true')
|
360
|
-
}.to raise_error(ArgumentError)
|
361
|
-
|
362
|
-
expect {
|
363
|
-
@sphinx.SetFilter(:attr, [1, 2], true)
|
364
|
-
}.to_not raise_error(ArgumentError)
|
365
|
-
|
366
|
-
expect {
|
367
|
-
@sphinx.SetFilter(:attr, [1, 2], false)
|
368
|
-
}.to_not raise_error(ArgumentError)
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
context 'in SetFilterRange method' do
|
373
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
374
|
-
expect {
|
375
|
-
@sphinx.SetFilterRange(1, 1, 2)
|
376
|
-
}.to raise_error(ArgumentError)
|
377
|
-
|
378
|
-
expect {
|
379
|
-
@sphinx.SetFilterRange('attr', 1, 2)
|
380
|
-
}.to_not raise_error(ArgumentError)
|
381
|
-
|
382
|
-
expect {
|
383
|
-
@sphinx.SetFilterRange(:attr, 1, 2)
|
384
|
-
}.to_not raise_error(ArgumentError)
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'should raise an error when min is not Integer' do
|
388
|
-
expect {
|
389
|
-
@sphinx.SetFilterRange(:attr, 'min', 0)
|
390
|
-
}.to raise_error(ArgumentError)
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'should raise an error when max is not Integer' do
|
394
|
-
expect {
|
395
|
-
@sphinx.SetFilterRange(:attr, 0, 'max')
|
396
|
-
}.to raise_error(ArgumentError)
|
397
|
-
end
|
398
|
-
|
399
|
-
it 'should raise an error when max is less than zero' do
|
400
|
-
expect {
|
401
|
-
@sphinx.SetFilterRange(:attr, 2, 1)
|
402
|
-
}.to raise_error(ArgumentError)
|
403
|
-
end
|
404
|
-
|
405
|
-
it 'should raise an error when exclude is not Boolean' do
|
406
|
-
expect {
|
407
|
-
@sphinx.SetFilterRange(:attr, 1, 2, 'true')
|
408
|
-
}.to raise_error(ArgumentError)
|
409
|
-
|
410
|
-
expect {
|
411
|
-
@sphinx.SetFilterRange(:attr, 1, 2, true)
|
412
|
-
}.to_not raise_error(ArgumentError)
|
413
|
-
|
414
|
-
expect {
|
415
|
-
@sphinx.SetFilterRange(:attr, 1, 2, false)
|
416
|
-
}.to_not raise_error(ArgumentError)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
context 'in SetFilterFloatRange method' do
|
421
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
422
|
-
expect {
|
423
|
-
@sphinx.SetFilterFloatRange(1, 1, 2)
|
424
|
-
}.to raise_error(ArgumentError)
|
425
|
-
|
426
|
-
expect {
|
427
|
-
@sphinx.SetFilterFloatRange('attr', 1, 2)
|
428
|
-
}.to_not raise_error(ArgumentError)
|
429
|
-
|
430
|
-
expect {
|
431
|
-
@sphinx.SetFilterFloatRange(:attr, 1, 2)
|
432
|
-
}.to_not raise_error(ArgumentError)
|
433
|
-
end
|
434
|
-
|
435
|
-
it 'should raise an error when min is not Integer or Float' do
|
436
|
-
expect {
|
437
|
-
@sphinx.SetFilterFloatRange(:attr, 'min', 1)
|
438
|
-
}.to raise_error(ArgumentError)
|
439
|
-
|
440
|
-
expect {
|
441
|
-
@sphinx.SetFilterFloatRange(:attr, 0, 1)
|
442
|
-
}.to_not raise_error(ArgumentError)
|
443
|
-
|
444
|
-
expect {
|
445
|
-
@sphinx.SetFilterFloatRange(:attr, 0.1, 1)
|
446
|
-
}.to_not raise_error(ArgumentError)
|
447
|
-
end
|
448
|
-
|
449
|
-
it 'should raise an error when max is not Integer or Float' do
|
450
|
-
expect {
|
451
|
-
@sphinx.SetFilterFloatRange(:attr, 0, 'max')
|
452
|
-
}.to raise_error(ArgumentError)
|
453
|
-
|
454
|
-
expect {
|
455
|
-
@sphinx.SetFilterFloatRange(:attr, 0, 1)
|
456
|
-
}.to_not raise_error(ArgumentError)
|
457
|
-
|
458
|
-
expect {
|
459
|
-
@sphinx.SetFilterFloatRange(:attr, 0, 1.1)
|
460
|
-
}.to_not raise_error(ArgumentError)
|
461
|
-
end
|
462
|
-
|
463
|
-
it 'should raise an error when max is less than zero' do
|
464
|
-
expect {
|
465
|
-
@sphinx.SetFilterFloatRange(:attr, 2, 1)
|
466
|
-
}.to raise_error(ArgumentError)
|
467
|
-
end
|
468
|
-
|
469
|
-
it 'should raise an error when exclude is not Boolean' do
|
470
|
-
expect {
|
471
|
-
@sphinx.SetFilterFloatRange(:attr, 1, 2, 'true')
|
472
|
-
}.to raise_error(ArgumentError)
|
473
|
-
|
474
|
-
expect {
|
475
|
-
@sphinx.SetFilterFloatRange(:attr, 1, 2, true)
|
476
|
-
}.to_not raise_error(ArgumentError)
|
477
|
-
|
478
|
-
expect {
|
479
|
-
@sphinx.SetFilterFloatRange(:attr, 1, 2, false)
|
480
|
-
}.to_not raise_error(ArgumentError)
|
481
|
-
end
|
482
|
-
end
|
483
|
-
|
484
|
-
context 'in SetGeoAnchor method' do
|
485
|
-
it 'should raise an error when attrlat is not String or Symbol' do
|
486
|
-
expect {
|
487
|
-
@sphinx.SetGeoAnchor(1, 'attrlong', 1, 2)
|
488
|
-
}.to raise_error(ArgumentError)
|
489
|
-
|
490
|
-
expect {
|
491
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1, 2)
|
492
|
-
}.to_not raise_error(ArgumentError)
|
493
|
-
|
494
|
-
expect {
|
495
|
-
@sphinx.SetGeoAnchor(:attrlat, 'attrlong', 1, 2)
|
496
|
-
}.to_not raise_error(ArgumentError)
|
497
|
-
end
|
498
|
-
|
499
|
-
it 'should raise an error when attrlong is not String or Symbol' do
|
500
|
-
expect {
|
501
|
-
@sphinx.SetGeoAnchor('attrlat', 1, 1, 2)
|
502
|
-
}.to raise_error(ArgumentError)
|
503
|
-
|
504
|
-
expect {
|
505
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1, 2)
|
506
|
-
}.to_not raise_error(ArgumentError)
|
507
|
-
|
508
|
-
expect {
|
509
|
-
@sphinx.SetGeoAnchor('attrlat', :attrlong, 1, 2)
|
510
|
-
}.to_not raise_error(ArgumentError)
|
511
|
-
end
|
512
|
-
|
513
|
-
it 'should raise an error when lat is not Integer or Float' do
|
514
|
-
expect {
|
515
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 'a', 2)
|
516
|
-
}.to raise_error(ArgumentError)
|
517
|
-
|
518
|
-
expect {
|
519
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1, 2)
|
520
|
-
}.to_not raise_error(ArgumentError)
|
521
|
-
|
522
|
-
expect {
|
523
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1.1, 2)
|
524
|
-
}.to_not raise_error(ArgumentError)
|
525
|
-
end
|
526
|
-
|
527
|
-
it 'should raise an error when long is not Integer or Float' do
|
528
|
-
expect {
|
529
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1, 'a')
|
530
|
-
}.to raise_error(ArgumentError)
|
531
|
-
|
532
|
-
expect {
|
533
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1, 2)
|
534
|
-
}.to_not raise_error(ArgumentError)
|
535
|
-
|
536
|
-
expect {
|
537
|
-
@sphinx.SetGeoAnchor('attrlat', 'attrlong', 1.1, 2)
|
538
|
-
}.to_not raise_error(ArgumentError)
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
context 'in SetGroupBy method' do
|
543
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
544
|
-
expect {
|
545
|
-
@sphinx.SetGroupBy(1, :day)
|
546
|
-
}.to raise_error(ArgumentError)
|
547
|
-
|
548
|
-
expect {
|
549
|
-
@sphinx.SetGroupBy('attr', :day)
|
550
|
-
}.to_not raise_error(ArgumentError)
|
551
|
-
|
552
|
-
expect {
|
553
|
-
@sphinx.SetGroupBy(:attr, :day)
|
554
|
-
}.to_not raise_error(ArgumentError)
|
555
|
-
end
|
556
|
-
|
557
|
-
it 'should raise an error when func is invalid' do
|
558
|
-
expect {
|
559
|
-
@sphinx.SetGroupBy(:attr, 'invalid')
|
560
|
-
}.to raise_error(ArgumentError)
|
561
|
-
|
562
|
-
expect {
|
563
|
-
@sphinx.SetGroupBy(:attr, :invalid)
|
564
|
-
}.to raise_error(ArgumentError)
|
565
|
-
|
566
|
-
expect {
|
567
|
-
@sphinx.SetGroupBy(:attr, 100)
|
568
|
-
}.to raise_error(ArgumentError)
|
569
|
-
end
|
570
|
-
|
571
|
-
it 'should raise an error when groupsort is not String' do
|
572
|
-
expect {
|
573
|
-
@sphinx.SetGroupBy(1, :day, 1)
|
574
|
-
}.to raise_error(ArgumentError)
|
575
|
-
|
576
|
-
expect {
|
577
|
-
@sphinx.SetGroupBy('attr', :day, 'groupsort')
|
578
|
-
}.to_not raise_error(ArgumentError)
|
579
|
-
end
|
580
|
-
end
|
581
|
-
|
582
|
-
context 'in SetGroupDistinct method' do
|
583
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
584
|
-
expect {
|
585
|
-
@sphinx.SetGroupDistinct(1)
|
586
|
-
}.to raise_error(ArgumentError)
|
587
|
-
|
588
|
-
expect {
|
589
|
-
@sphinx.SetGroupDistinct('attr')
|
590
|
-
}.to_not raise_error(ArgumentError)
|
591
|
-
|
592
|
-
expect {
|
593
|
-
@sphinx.SetGroupDistinct(:attr)
|
594
|
-
}.to_not raise_error(ArgumentError)
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
context 'in SetRetries method' do
|
599
|
-
it 'should raise an error when count is not Integer' do
|
600
|
-
expect {
|
601
|
-
@sphinx.SetRetries('count', 0)
|
602
|
-
}.to raise_error(ArgumentError)
|
603
|
-
end
|
604
|
-
|
605
|
-
it 'should raise an error when delay is not Integer' do
|
606
|
-
expect {
|
607
|
-
@sphinx.SetRetries(0, 'delay')
|
608
|
-
}.to raise_error(ArgumentError)
|
609
|
-
end
|
610
|
-
end
|
611
|
-
|
612
|
-
context 'in SetOverride method' do
|
613
|
-
it 'should raise an error when attribute is not String or Symbol' do
|
614
|
-
expect {
|
615
|
-
@sphinx.SetOverride(1, :integer, {})
|
616
|
-
}.to raise_error(ArgumentError)
|
617
|
-
|
618
|
-
expect {
|
619
|
-
@sphinx.SetOverride('attr', :integer, {})
|
620
|
-
}.to_not raise_error(ArgumentError)
|
621
|
-
|
622
|
-
expect {
|
623
|
-
@sphinx.SetOverride(:attr, :integer, {})
|
624
|
-
}.to_not raise_error(ArgumentError)
|
625
|
-
end
|
626
|
-
|
627
|
-
it 'should raise an error when attrtype is invalid' do
|
628
|
-
expect {
|
629
|
-
@sphinx.SetOverride(:attr, 'invalid', {})
|
630
|
-
}.to raise_error(ArgumentError)
|
631
|
-
|
632
|
-
expect {
|
633
|
-
@sphinx.SetOverride(:attr, :invalid, {})
|
634
|
-
}.to raise_error(ArgumentError)
|
635
|
-
|
636
|
-
expect {
|
637
|
-
@sphinx.SetOverride(:attr, 100, {})
|
638
|
-
}.to raise_error(ArgumentError)
|
639
|
-
end
|
640
|
-
|
641
|
-
it 'should raise an error when values is not Hash' do
|
642
|
-
expect {
|
643
|
-
@sphinx.SetOverride(:attr, :integer, [])
|
644
|
-
}.to raise_error(ArgumentError)
|
645
|
-
end
|
646
|
-
|
647
|
-
it "should raise an error when values Hash keys are not Integers" do
|
648
|
-
expect {
|
649
|
-
@sphinx.SetOverride(:attr, :integer, { 'a' => 10 })
|
650
|
-
}.to raise_error(ArgumentError)
|
651
|
-
|
652
|
-
expect {
|
653
|
-
@sphinx.SetOverride(:attr, :integer, { 10 => 10 })
|
654
|
-
}.to_not raise_error(ArgumentError)
|
655
|
-
end
|
656
|
-
|
657
|
-
[:integer, :ordinal, :bool, :bigint].each do |attrtype|
|
658
|
-
it "should raise an error when attrtype is \"#{attrtype}\" and values Hash values are not Integers" do
|
659
|
-
expect {
|
660
|
-
@sphinx.SetOverride(:attr, attrtype, { 10 => '10' })
|
661
|
-
}.to raise_error(ArgumentError)
|
662
|
-
|
663
|
-
expect {
|
664
|
-
@sphinx.SetOverride(:attr, attrtype, { 10 => 10 })
|
665
|
-
}.to_not raise_error(ArgumentError)
|
666
|
-
end
|
667
|
-
end
|
668
|
-
|
669
|
-
it "should raise an error when attrtype is \"timestamp\" and values Hash values are not Integers or Time" do
|
670
|
-
expect {
|
671
|
-
@sphinx.SetOverride(:attr, :timestamp, { 10 => '10' })
|
672
|
-
}.to raise_error(ArgumentError)
|
673
|
-
|
674
|
-
expect {
|
675
|
-
@sphinx.SetOverride(:attr, :timestamp, { 10 => 10 })
|
676
|
-
}.to_not raise_error(ArgumentError)
|
677
|
-
|
678
|
-
expect {
|
679
|
-
@sphinx.SetOverride(:attr, :timestamp, { 10 => Time.now })
|
680
|
-
}.to_not raise_error(ArgumentError)
|
681
|
-
end
|
682
|
-
|
683
|
-
it "should raise an error when attrtype is \"float\" and values Hash values are not Integers or Floats" do
|
684
|
-
expect {
|
685
|
-
@sphinx.SetOverride(:attr, :float, { 10 => '10' })
|
686
|
-
}.to raise_error(ArgumentError)
|
687
|
-
|
688
|
-
expect {
|
689
|
-
@sphinx.SetOverride(:attr, :float, { 10 => 10 })
|
690
|
-
}.to_not raise_error(ArgumentError)
|
691
|
-
|
692
|
-
expect {
|
693
|
-
@sphinx.SetOverride(:attr, :float, { 10 => 10.1 })
|
694
|
-
}.to_not raise_error(ArgumentError)
|
695
|
-
end
|
696
|
-
end
|
697
|
-
|
698
|
-
context 'in SetSelect method' do
|
699
|
-
it 'should raise an error when select is not String' do
|
700
|
-
expect {
|
701
|
-
@sphinx.SetSelect(:select)
|
702
|
-
}.to raise_error(ArgumentError)
|
703
|
-
|
704
|
-
expect {
|
705
|
-
@sphinx.SetSelect(1)
|
706
|
-
}.to raise_error(ArgumentError)
|
707
|
-
|
708
|
-
expect {
|
709
|
-
@sphinx.SetSelect('select')
|
710
|
-
}.to_not raise_error(ArgumentError)
|
711
|
-
end
|
712
|
-
end
|
713
|
-
|
714
|
-
context 'in BuildExcerpts method' do
|
715
|
-
it 'should raise an error when docs is not Array of Strings' do
|
716
|
-
expect {
|
717
|
-
@sphinx.BuildExcerpts(1, 'index', 'words')
|
718
|
-
}.to raise_error(ArgumentError)
|
719
|
-
|
720
|
-
expect {
|
721
|
-
@sphinx.BuildExcerpts('doc', 'index', 'words')
|
722
|
-
}.to raise_error(ArgumentError)
|
723
|
-
|
724
|
-
expect {
|
725
|
-
@sphinx.BuildExcerpts([1], 'index', 'words')
|
726
|
-
}.to raise_error(ArgumentError)
|
727
|
-
|
728
|
-
expect {
|
729
|
-
@sphinx.BuildExcerpts(['doc'], 'index', 'words')
|
730
|
-
}.to_not raise_error(ArgumentError)
|
731
|
-
end
|
732
|
-
|
733
|
-
it 'should raise an error when index is not String or Symbol' do
|
734
|
-
expect {
|
735
|
-
@sphinx.BuildExcerpts(['doc'], 1, 'words')
|
736
|
-
}.to raise_error(ArgumentError)
|
737
|
-
|
738
|
-
expect {
|
739
|
-
@sphinx.BuildExcerpts(['doc'], 'index', 'words')
|
740
|
-
}.to_not raise_error(ArgumentError)
|
741
|
-
|
742
|
-
expect {
|
743
|
-
@sphinx.BuildExcerpts(['doc'], :index, 'words')
|
744
|
-
}.to_not raise_error(ArgumentError)
|
745
|
-
end
|
746
|
-
|
747
|
-
it 'should raise an error when words is not String' do
|
748
|
-
expect {
|
749
|
-
@sphinx.BuildExcerpts(['doc'], 'index', 1)
|
750
|
-
}.to raise_error(ArgumentError)
|
751
|
-
end
|
752
|
-
|
753
|
-
it 'should raise an error when opts is not Hash' do
|
754
|
-
expect {
|
755
|
-
@sphinx.BuildExcerpts(['doc'], 'index', 'words', [])
|
756
|
-
}.to raise_error(ArgumentError)
|
757
|
-
end
|
758
|
-
end
|
759
|
-
|
760
|
-
context 'in BuildKeywords method' do
|
761
|
-
it 'should raise an error when query is not String' do
|
762
|
-
expect {
|
763
|
-
@sphinx.BuildExcerpts([], 'index', true)
|
764
|
-
}.to raise_error(ArgumentError)
|
765
|
-
end
|
766
|
-
|
767
|
-
it 'should raise an error when index is not String or Symbol' do
|
768
|
-
expect {
|
769
|
-
@sphinx.BuildKeywords('query', 1, true)
|
770
|
-
}.to raise_error(ArgumentError)
|
771
|
-
|
772
|
-
expect {
|
773
|
-
@sphinx.BuildKeywords('query', 'index', true)
|
774
|
-
}.to_not raise_error(ArgumentError)
|
775
|
-
|
776
|
-
expect {
|
777
|
-
@sphinx.BuildKeywords('query', :index, true)
|
778
|
-
}.to_not raise_error(ArgumentError)
|
779
|
-
end
|
780
|
-
|
781
|
-
it 'should raise an error when hits is not Boolean' do
|
782
|
-
expect {
|
783
|
-
@sphinx.BuildKeywords('query', :index, 1)
|
784
|
-
}.to raise_error(ArgumentError)
|
785
|
-
|
786
|
-
expect {
|
787
|
-
@sphinx.BuildKeywords('query', :index, true)
|
788
|
-
}.to_not raise_error(ArgumentError)
|
789
|
-
|
790
|
-
expect {
|
791
|
-
@sphinx.BuildKeywords('query', :index, false)
|
792
|
-
}.to_not raise_error(ArgumentError)
|
793
|
-
end
|
794
|
-
end
|
795
|
-
|
796
|
-
context 'in UpdateAttributes method' do
|
797
|
-
it 'should raise an error when index is not String or Symbol' do
|
798
|
-
expect {
|
799
|
-
@sphinx.UpdateAttributes(1, [:attr1, :attr2], { 10 => [1, 2], 20 => [3, 4] }, false)
|
800
|
-
}.to raise_error(ArgumentError)
|
801
|
-
|
802
|
-
expect {
|
803
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [1, 2], 20 => [3, 4] }, false)
|
804
|
-
}.to_not raise_error(ArgumentError)
|
805
|
-
|
806
|
-
expect {
|
807
|
-
@sphinx.UpdateAttributes(:index, [:attr1, :attr2], { 10 => [1, 2], 20 => [3, 4] }, false)
|
808
|
-
}.to_not raise_error(ArgumentError)
|
809
|
-
end
|
810
|
-
|
811
|
-
it 'should raise an error when mva is not Boolean' do
|
812
|
-
expect {
|
813
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [1, 2], 20 => [3, 4] }, 1)
|
814
|
-
}.to raise_error(ArgumentError)
|
815
|
-
|
816
|
-
expect {
|
817
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [1, 2], 20 => [3, 4] }, false)
|
818
|
-
}.to_not raise_error(ArgumentError)
|
819
|
-
|
820
|
-
expect {
|
821
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [[1], [2]], 20 => [[3], [4]] }, true)
|
822
|
-
}.to_not raise_error(ArgumentError)
|
823
|
-
end
|
824
|
-
|
825
|
-
it 'should raise an error when values is not Hash' do
|
826
|
-
expect {
|
827
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], [], 1)
|
828
|
-
}.to raise_error(ArgumentError)
|
829
|
-
end
|
830
|
-
|
831
|
-
it 'should raise an error when mva is false and values is not Hash map of Integers to Arrays of Integers' do
|
832
|
-
expect {
|
833
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 'a' => [1, 2], 20 => [3, 4] }, false)
|
834
|
-
}.to raise_error(ArgumentError)
|
835
|
-
|
836
|
-
expect {
|
837
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [1, 2], 20 => ['3', 4] }, false)
|
838
|
-
}.to raise_error(ArgumentError)
|
839
|
-
|
840
|
-
expect {
|
841
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [1, 2], 20 => 5 }, false)
|
842
|
-
}.to raise_error(ArgumentError)
|
843
|
-
end
|
844
|
-
|
845
|
-
it 'should raise an error when mva is true and values is not Hash map of Integers to Arrays of Arrays of Integers' do
|
846
|
-
expect {
|
847
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 'a' => [[1], [2]], 20 => [[3], [4]] }, true)
|
848
|
-
}.to raise_error(ArgumentError)
|
849
|
-
|
850
|
-
expect {
|
851
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [[1], [2]], 20 => 5 }, true)
|
852
|
-
}.to raise_error(ArgumentError)
|
853
|
-
|
854
|
-
expect {
|
855
|
-
@sphinx.UpdateAttributes('index', [:attr1, :attr2], { 10 => [[1], [2]], 20 => [3, [4]] }, true)
|
856
|
-
}.to raise_error(ArgumentError)
|
857
|
-
end
|
858
|
-
end
|
859
|
-
end
|