swiftype 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/client_spec.rb CHANGED
@@ -13,27 +13,27 @@ describe Swiftype::Client do
13
13
  it 'searches all DocumentTypes in the engine' do
14
14
  VCR.use_cassette(:engine_search) do
15
15
  results = client.search(engine_slug, 'cat')
16
- results.document_types.size.should == 2
17
- results['videos'].size.should == 2
18
- results['channels'].size.should == 1
16
+ expect(results.document_types.size).to eq(2)
17
+ expect(results['videos'].size).to eq(2)
18
+ expect(results['channels'].size).to eq(1)
19
19
  end
20
20
  end
21
21
 
22
22
  it 'searches the engine with options' do
23
23
  VCR.use_cassette(:engine_search_pagination) do
24
24
  results = client.search(engine_slug, 'cat', {:page => 2})
25
- results.document_types.size.should == 2
26
- results['videos'].size.should == 0
27
- results['channels'].size.should == 0
25
+ expect(results.document_types.size).to eq(2)
26
+ expect(results['videos'].size).to eq(0)
27
+ expect(results['channels'].size).to eq(0)
28
28
  end
29
29
  end
30
30
 
31
31
  it 'includes facets when requested' do
32
32
  VCR.use_cassette(:engine_search_facets) do
33
33
  results = client.search(engine_slug, nil, {:facets => {:videos => ['category_id']}})
34
- results.document_types.size.should == 2
35
- results.facets('channels').should be_empty
36
- results.facets('videos')['category_id'].should == {
34
+ expect(results.document_types.size).to eq(2)
35
+ expect(results.facets('channels')).to be_empty
36
+ expect(results.facets('videos')['category_id']).to eq({
37
37
  "23" => 4,
38
38
  "28" => 2,
39
39
  "15" => 2,
@@ -41,7 +41,7 @@ describe Swiftype::Client do
41
41
  "22" => 1,
42
42
  "2" => 1,
43
43
  "10" => 1
44
- }
44
+ })
45
45
  end
46
46
  end
47
47
  end
@@ -52,38 +52,49 @@ describe Swiftype::Client do
52
52
  it 'searches only the provided DocumentType' do
53
53
  VCR.use_cassette(:document_type_search) do
54
54
  results = client.search_document_type(engine_slug, document_type_slug, 'cat')
55
- results.document_types.should == ['videos']
56
- results['videos'].size.should == 2
55
+ expect(results.document_types).to eq(['videos'])
56
+ expect(results['videos'].size).to eq(2)
57
57
  end
58
58
  end
59
59
 
60
60
  it 'searches the DocumentType with options' do
61
61
  VCR.use_cassette(:document_type_search_pagination) do
62
62
  results = client.search_document_type(engine_slug, document_type_slug, 'cat', {:page => 2})
63
- results.document_types.should == ['videos']
64
- results[document_type_slug].size.should == 0
63
+ expect(results.document_types).to eq(['videos'])
64
+ expect(results[document_type_slug].size).to eq(0)
65
65
  end
66
66
  end
67
67
  end
68
68
  end
69
69
 
70
+ context 'Options' do
71
+ let(:options_client) { Swiftype::Client.new(options) }
72
+
73
+ context '#request' do
74
+ let(:options) { { :open_timeout => 3 } }
75
+ it 'respects the Net::HTTP open_timeout option' do
76
+ expect(options_client.open_timeout).to eq(3)
77
+ end
78
+ end
79
+ end
80
+
70
81
  context 'Suggest' do
71
82
  context '#suggest' do
72
83
  it 'does prefix searches for all DocumentTypes in the engine' do
73
84
  VCR.use_cassette(:engine_suggest) do
74
85
  results = client.suggest(engine_slug, 'goo')
75
- results.document_types.size.should == 2
76
- results['videos'].size.should == 1
77
- results['channels'].size.should == 1
86
+ expect(results.document_types.size).to eq(2)
87
+ expect(results['videos'].size).to eq(1)
88
+ expect(results['channels'].size).to eq(1)
78
89
  end
79
90
  end
80
91
 
81
92
  it 'suggests for an engine with options' do
82
93
  VCR.use_cassette(:engine_suggest_pagination) do
83
94
  results = client.suggest(engine_slug, 'goo', {:page => 2})
84
- results.document_types.size.should == 2
85
- results['videos'].size.should == 0
86
- results['channels'].size.should == 0
95
+ expect(results.document_types.size).to eq(2)
96
+ expect(results['videos'].size).to eq(0)
97
+ expect(results['channels'].size).to eq(0)
87
98
  end
88
99
  end
89
100
  end
@@ -94,16 +105,16 @@ describe Swiftype::Client do
94
105
  it 'does a prefix search on the provided DocumentType' do
95
106
  VCR.use_cassette(:document_type_suggest) do
96
107
  results = client.suggest_document_type(engine_slug, document_type_slug, 'goo')
97
- results.document_types.should == ['videos']
98
- results['videos'].size.should == 1
108
+ expect(results.document_types).to eq(['videos'])
109
+ expect(results['videos'].size).to eq(1)
99
110
  end
100
111
  end
101
112
 
102
113
  it 'suggests for a document types with options' do
103
114
  VCR.use_cassette(:document_type_suggest_pagination) do
104
115
  results = client.suggest_document_type(engine_slug, document_type_slug, 'goo', {:page => 2})
105
- results.document_types.should == ['videos']
106
- results[document_type_slug].size.should == 0
116
+ expect(results.document_types).to eq(['videos'])
117
+ expect(results[document_type_slug].size).to eq(0)
107
118
  end
108
119
  end
109
120
  end
@@ -114,28 +125,28 @@ describe Swiftype::Client do
114
125
  it 'gets all engines' do
115
126
  VCR.use_cassette(:list_engines) do
116
127
  engines = client.engines
117
- engines.size.should == 6
128
+ expect(engines.size).to eq(6)
118
129
  end
119
130
  end
120
131
 
121
132
  it 'gets an engine' do
122
133
  VCR.use_cassette(:find_engine) do
123
134
  engine = client.engine(engine_slug)
124
- engine['slug'].should == engine_slug
135
+ expect(engine['slug']).to eq(engine_slug)
125
136
  end
126
137
  end
127
138
 
128
139
  it 'creates engines' do
129
140
  VCR.use_cassette(:create_engine) do
130
141
  engine = client.create_engine('new engine from spec')
131
- engine['slug'].should == 'new-engine-from-spec'
142
+ expect(engine['slug']).to eq('new-engine-from-spec')
132
143
  end
133
144
  end
134
145
 
135
146
  it 'destroys engines' do
136
147
  VCR.use_cassette(:destroy_engine) do
137
148
  response = client.destroy_engine('new-engine-from-spec')
138
- response.should be_nil
149
+ expect(response).to be_nil
139
150
  end
140
151
  end
141
152
  end
@@ -146,15 +157,15 @@ describe Swiftype::Client do
146
157
  it 'gets all document types' do
147
158
  VCR.use_cassette(:list_document_type) do
148
159
  document_types = client.document_types(engine_slug)
149
- document_types.size.should == 2
150
- document_types.map { |dt| dt['name'] }.sort.should == ['channels', 'videos']
160
+ expect(document_types.size).to eq(2)
161
+ expect(document_types.map { |dt| dt['name'] }.sort).to eq(['channels', 'videos'])
151
162
  end
152
163
  end
153
164
 
154
165
  it 'gets a document type' do
155
166
  VCR.use_cassette(:find_document_type) do
156
167
  document_type = client.document_type(engine_slug, document_type_slug)
157
- document_type['slug'].should == document_type_slug
168
+ expect(document_type['slug']).to eq(document_type_slug)
158
169
  end
159
170
  end
160
171
 
@@ -162,15 +173,15 @@ describe Swiftype::Client do
162
173
  VCR.use_cassette(:create_document_type) do
163
174
  name = document_type_slug
164
175
  document_type = client.create_document_type(engine_slug, 'new_doc_type')
165
- document_type['name'].should == 'new_doc_type'
166
- document_type['slug'].should == 'new-doc-type'
176
+ expect(document_type['name']).to eq('new_doc_type')
177
+ expect(document_type['slug']).to eq('new-doc-type')
167
178
  end
168
179
  end
169
180
 
170
181
  it 'destroys document types' do
171
182
  VCR.use_cassette(:destroy_document_type) do
172
183
  response = client.destroy_document_type(engine_slug, 'new-doc-type')
173
- response.should be_nil
184
+ expect(response).to be_nil
174
185
  end
175
186
  end
176
187
 
@@ -184,6 +195,16 @@ describe Swiftype::Client do
184
195
  end
185
196
 
186
197
  context 'Document' do
198
+
199
+ def check_async_response_format(response, options = {})
200
+ expect(response.keys).to match_array(["document_receipts", "batch_link"])
201
+ expect(response["document_receipts"]).to be_a_kind_of(Array)
202
+ expect(response["document_receipts"].first.keys).to match_array(["id", "external_id", "link", "status", "errors"])
203
+ expect(response["document_receipts"].first["external_id"]).to eq(options[:external_id]) if options[:external_id]
204
+ expect(response["document_receipts"].first["status"]).to eq(options[:status]) if options[:status]
205
+ expect(response["document_receipts"].first["errors"]).to eq(options[:errors]) if options[:errors]
206
+ end
207
+
187
208
  let(:document_type_slug) { 'videos' }
188
209
  let(:document_id) { 'FtX8nswnUKU'}
189
210
  let(:documents) do
@@ -204,49 +225,49 @@ describe Swiftype::Client do
204
225
  it 'lists documents in a document type' do
205
226
  VCR.use_cassette(:list_documents) do
206
227
  documents = client.documents(engine_slug, document_type_slug)
207
- documents.size.should == 2
228
+ expect(documents.size).to eq(2)
208
229
  end
209
230
  end
210
231
 
211
232
  it 'lists documents with pagination' do
212
233
  VCR.use_cassette(:list_documents_with_pagination) do
213
234
  documents = client.documents(engine_slug, document_type_slug, 2, 2)
214
- documents.size.should == 2
235
+ expect(documents.size).to eq(2)
215
236
  end
216
237
  end
217
238
 
218
239
  it 'find a document' do
219
240
  VCR.use_cassette(:find_document) do
220
241
  document = client.document(engine_slug, document_type_slug, document_id)
221
- document['external_id'].should == document_id
242
+ expect(document['external_id']).to eq(document_id)
222
243
  end
223
244
  end
224
245
 
225
246
  it 'creates a document' do
226
247
  VCR.use_cassette(:create_document) do
227
248
  document = client.create_document(engine_slug, document_type_slug, documents.first)
228
- document['external_id'].should == 'INscMGmhmX4'
249
+ expect(document['external_id']).to eq('INscMGmhmX4')
229
250
  end
230
251
  end
231
252
 
232
253
  it 'bulk create multiple documents' do
233
254
  VCR.use_cassette(:bulk_create_documents) do
234
255
  response = client.create_documents(engine_slug, document_type_slug, documents)
235
- response.should == [true, true]
256
+ expect(response).to eq([true, true])
236
257
  end
237
258
  end
238
259
 
239
260
  it 'destroys a document' do
240
261
  VCR.use_cassette(:destroy_document) do
241
262
  response = client.destroy_document(engine_slug, document_type_slug, 'INscMGmhmX4')
242
- response.should be_nil
263
+ expect(response).to be_nil
243
264
  end
244
265
  end
245
266
 
246
267
  it 'destroys multiple documents' do
247
268
  VCR.use_cassette(:bulk_destroy_documents) do
248
269
  response = client.destroy_documents(engine_slug, document_type_slug, ['INscMGmhmX4', 'XfY9Dsg_DZk'])
249
- response.should == [true, true]
270
+ expect(response).to eq([true, true])
250
271
  end
251
272
  end
252
273
 
@@ -254,16 +275,16 @@ describe Swiftype::Client do
254
275
  it 'creates a document' do
255
276
  VCR.use_cassette(:create_or_update_document_create) do
256
277
  response = client.create_or_update_document(engine_slug, document_type_slug, {:external_id => 'foobar', :fields => [{:type => :string, :name => 'title', :value => 'new document'}]})
257
- response['external_id'].should == 'foobar'
258
- response['title'].should == 'new document'
278
+ expect(response['external_id']).to eq('foobar')
279
+ expect(response['title']).to eq('new document')
259
280
  end
260
281
  end
261
282
 
262
283
  it 'updates an existing document' do
263
284
  VCR.use_cassette(:create_or_update_document_update) do
264
285
  response = client.create_or_update_document(engine_slug, document_type_slug, {:external_id => document_id, :fields => [{:type => :string, :name => 'title', :value => 'new title'}]})
265
- response['external_id'].should == document_id
266
- response['title'].should == 'new title'
286
+ expect(response['external_id']).to eq(document_id)
287
+ expect(response['title']).to eq('new title')
267
288
  end
268
289
  end
269
290
  end
@@ -272,7 +293,7 @@ describe Swiftype::Client do
272
293
  it 'returns true for all documents successfully created or updated' do
273
294
  VCR.use_cassette(:bulk_create_or_update_documents_success) do
274
295
  response = client.create_or_update_documents(engine_slug, document_type_slug, documents)
275
- response.should == [true, true]
296
+ expect(response).to eq([true, true])
276
297
  end
277
298
  end
278
299
 
@@ -281,7 +302,76 @@ describe Swiftype::Client do
281
302
 
282
303
  VCR.use_cassette(:bulk_create_or_update_documents_failure) do
283
304
  response = client.create_or_update_documents(engine_slug, document_type_slug, documents)
284
- response.should == [false]
305
+ expect(response).to eq([false])
306
+ end
307
+ end
308
+ end
309
+
310
+ context '#async_create_or_update_documents' do
311
+ it 'returns true for all documents successfully created or updated' do
312
+ VCR.use_cassette(:async_create_or_update_document_success) do
313
+ response = client.async_create_or_update_documents(engine_slug, document_type_slug, documents)
314
+ check_async_response_format(response, :external_id => documents.first["external_id"], :status => "pending")
315
+ end
316
+ end
317
+
318
+ it 'returns false if a document cannot be created or updated due to an error' do
319
+ documents = [{:external_id => 'failed_doc', :fields => [{:type => :string, :name => :title}]}] # missing value
320
+
321
+ VCR.use_cassette(:async_create_or_update_document_failure) do
322
+ response = client.async_create_or_update_documents(engine_slug, document_type_slug, documents)
323
+ check_async_response_format(response, :external_id => documents.first["external_id"], :status => "failed", :errors => ["Missing required parameter: value"])
324
+ end
325
+ end
326
+ end
327
+
328
+ context '#document_receipts' do
329
+ before :each do
330
+ def get_receipt_ids
331
+ receipt_ids = nil
332
+ VCR.use_cassette(:async_create_or_update_document_success) do
333
+ response = client.async_create_or_update_documents(engine_slug, document_type_slug, documents)
334
+ receipt_ids = response["document_receipts"].map { |r| r["id"] }
335
+ end
336
+ receipt_ids
337
+ end
338
+ end
339
+
340
+ it 'returns array of hashes one for each receipt' do
341
+ VCR.use_cassette(:document_receipts_multiple) do
342
+ receipt_ids = get_receipt_ids
343
+ response = client.document_receipts(receipt_ids)
344
+ expect(response).to eq([{"id" => receipt_ids[0], "status" => "pending"}, {"id" => receipt_ids[1], "status" => "pending"}])
345
+ end
346
+ end
347
+ end
348
+
349
+ context '#index_documents' do
350
+ it 'returns #async_create_or_update_documents format return when async has been passed as true' do
351
+ VCR.use_cassette(:async_create_or_update_document_success) do
352
+ response = client.index_documents(engine_slug, document_type_slug, documents, :async => true)
353
+ check_async_response_format(response, :external_id => documents.first["external_id"], :status => "pending")
354
+ end
355
+ end
356
+
357
+ it 'returns document_receipts when successfull' do
358
+ VCR.use_cassette(:async_create_or_update_document_success) do
359
+ VCR.use_cassette(:document_receipts_multiple_complete) do
360
+ response = client.index_documents(engine_slug, document_type_slug, documents)
361
+ # Sort keys for Ruby 1.8.7 compatibility
362
+ expect(response.map(&:keys).map(&:sort)).to eq([["id", "link", "status"], ["id", "link", "status"]])
363
+ expect(response.map { |a| a["status"] }).to eq(["complete", "complete"])
364
+ end
365
+ end
366
+ end
367
+
368
+ it 'should timeout if the process takes longer than the timeout option passed' do
369
+ allow(client).to receive(:document_receipts) { sleep 0.05 }
370
+
371
+ VCR.use_cassette(:async_create_or_update_document_success) do
372
+ expect do
373
+ client.index_documents(engine_slug, document_type_slug, documents, :timeout => 0.01)
374
+ end.to raise_error(Timeout::Error)
285
375
  end
286
376
  end
287
377
  end
@@ -290,7 +380,7 @@ describe Swiftype::Client do
290
380
  it 'returns true for all documents successfully created or updated' do
291
381
  VCR.use_cassette(:bulk_create_or_update_documents_verbose_success) do
292
382
  response = client.create_or_update_documents_verbose(engine_slug, document_type_slug, documents)
293
- response.should == [true, true]
383
+ expect(response).to eq([true, true])
294
384
  end
295
385
  end
296
386
 
@@ -299,8 +389,8 @@ describe Swiftype::Client do
299
389
 
300
390
  VCR.use_cassette(:bulk_create_or_update_documents_verbose_failure) do
301
391
  response = client.create_or_update_documents_verbose(engine_slug, document_type_slug, documents)
302
- response.size.should == 1
303
- response.first.should match /^Invalid field definition/
392
+ expect(response.size).to eq(1)
393
+ expect(response.first).to match /^Invalid field definition/
304
394
  end
305
395
  end
306
396
  end
@@ -310,9 +400,9 @@ describe Swiftype::Client do
310
400
  fields = {:title => 'awesome new title', :channel_id => 'UC5VA5j05FjETg-iLekcyiBw'}
311
401
  VCR.use_cassette(:update_document) do
312
402
  response = client.update_document(engine_slug, document_type_slug, document_id, fields)
313
- response['external_id'].should == document_id
314
- response['title'].should == 'awesome new title'
315
- response['channel_id'].should == 'UC5VA5j05FjETg-iLekcyiBw'
403
+ expect(response['external_id']).to eq(document_id)
404
+ expect(response['title']).to eq('awesome new title')
405
+ expect(response['channel_id']).to eq('UC5VA5j05FjETg-iLekcyiBw')
316
406
  end
317
407
  end
318
408
 
@@ -333,7 +423,7 @@ describe Swiftype::Client do
333
423
 
334
424
  VCR.use_cassette(:update_documents_success) do
335
425
  response = client.update_documents(engine_slug, document_type_slug, documents)
336
- response.should == [true, true]
426
+ expect(response).to eq([true, true])
337
427
  end
338
428
  end
339
429
 
@@ -342,7 +432,7 @@ describe Swiftype::Client do
342
432
 
343
433
  VCR.use_cassette(:update_documents_failure_non_existent_document) do
344
434
  response = client.update_documents(engine_slug, document_type_slug, documents)
345
- response.should == [false]
435
+ expect(response).to eq([false])
346
436
  end
347
437
  end
348
438
  end
@@ -355,32 +445,32 @@ describe Swiftype::Client do
355
445
  it 'returns search counts for the default time frame' do
356
446
  VCR.use_cassette(:analytics_searches) do
357
447
  searches = client.analytics_searches(engine_slug)
358
- searches.size.should == 15 # FIXME: is this a bug in the API?
359
- searches.first.should == ['2013-09-13', 0]
448
+ expect(searches.size).to eq(15) # FIXME: is this a bug in the API?
449
+ expect(searches.first).to eq(['2013-09-13', 0])
360
450
  end
361
451
  end
362
452
 
363
453
  it 'returns search counts for a specified time range' do
364
454
  VCR.use_cassette(:analytics_searches_with_time_range) do
365
455
  searches = client.analytics_searches(engine_slug, :start_date => '2013-01-01', :end_date => '2013-01-07')
366
- searches.size.should == 7
367
- searches.first.should == ['2013-01-07', 0]
456
+ expect(searches.size).to eq(7)
457
+ expect(searches.first).to eq(['2013-01-07', 0])
368
458
  end
369
459
  end
370
460
 
371
461
  it 'returns search counts for a specified DocumentType' do
372
462
  VCR.use_cassette(:analytics_searchs_with_document_type) do
373
463
  searches = client.analytics_searches(engine_slug, :document_type_id => 'page')
374
- searches.size.should == 15
375
- searches.first.should == ['2013-09-16', 0]
464
+ expect(searches.size).to eq(15)
465
+ expect(searches.first).to eq(['2013-09-16', 0])
376
466
  end
377
467
  end
378
468
 
379
469
  it 'returns search counts for a specified DocumentType and time range' do
380
470
  VCR.use_cassette(:analytics_searches_with_document_type_and_time_range) do
381
471
  searches = client.analytics_autoselects(engine_slug, :document_type_id => 'page', :start_date => '2013-07-01', :end_date => '2013-07-07')
382
- searches.size.should == 7
383
- searches.first.should == ['2013-07-07', 0]
472
+ expect(searches.size).to eq(7)
473
+ expect(searches.first).to eq(['2013-07-07', 0])
384
474
  end
385
475
  end
386
476
  end
@@ -389,29 +479,29 @@ describe Swiftype::Client do
389
479
  it 'returns autoselect counts for the default time frame' do
390
480
  VCR.use_cassette(:analytics_autoselects) do
391
481
  autoselects = client.analytics_autoselects(engine_slug)
392
- autoselects.size.should == 15
393
- autoselects.first.should == ['2013-09-13', 0]
482
+ expect(autoselects.size).to eq(15)
483
+ expect(autoselects.first).to eq(['2013-09-13', 0])
394
484
  end
395
485
  end
396
486
 
397
487
  it 'returns autoselects counts for a specified time range' do
398
488
  VCR.use_cassette(:analytics_autoselects_with_time_range) do
399
489
  autoselects = client.analytics_autoselects(engine_slug, :start_date => '2013-07-01', :end_date => '2013-07-07')
400
- autoselects.size.should == 7
490
+ expect(autoselects.size).to eq(7)
401
491
  end
402
492
  end
403
493
 
404
494
  it 'returns autoselect counts for a specified DocumentType' do
405
495
  VCR.use_cassette(:analytics_autoselects_with_document_type) do
406
496
  autoselects = client.analytics_autoselects(engine_slug, :document_type_id => 'page')
407
- autoselects.size.should == 15
497
+ expect(autoselects.size).to eq(15)
408
498
  end
409
499
  end
410
500
 
411
501
  it 'returns autoselect counts for a specified DocumentType and time range' do
412
502
  VCR.use_cassette(:analytics_autoselects_with_document_type_and_time_range) do
413
503
  autoselects = client.analytics_autoselects(engine_slug, :document_type_id => 'page', :start_date => '2013-07-01', :end_date => '2013-07-07')
414
- autoselects.size.should == 7
504
+ expect(autoselects.size).to eq(7)
415
505
  end
416
506
  end
417
507
  end
@@ -420,31 +510,31 @@ describe Swiftype::Client do
420
510
  it 'returns click counts for the default time frame' do
421
511
  VCR.use_cassette(:analytics_clicks) do
422
512
  clicks = client.analytics_clicks(engine_slug)
423
- clicks.size.should == 15
424
- clicks.first.should == ['2013-09-17', 0]
513
+ expect(clicks.size).to eq(15)
514
+ expect(clicks.first).to eq(['2013-09-17', 0])
425
515
  end
426
516
  end
427
517
 
428
518
  it 'returns clicks counts for a specified time range' do
429
519
  VCR.use_cassette(:analytics_clicks_with_time_range) do
430
520
  clicks = client.analytics_clicks(engine_slug, :start_date => '2013-07-01', :end_date => '2013-07-07')
431
- clicks.size.should == 7
432
- clicks.first.should == ['2013-07-07', 0]
521
+ expect(clicks.size).to eq(7)
522
+ expect(clicks.first).to eq(['2013-07-07', 0])
433
523
  end
434
524
  end
435
525
 
436
526
  it 'returns click counts for a specified DocumentType' do
437
527
  VCR.use_cassette(:analytics_clicks_with_document_type) do
438
528
  clicks = client.analytics_clicks(engine_slug, :document_type_id => 'page')
439
- clicks.size.should == 15
529
+ expect(clicks.size).to eq(15)
440
530
  end
441
531
  end
442
532
 
443
533
  it 'returns click counts for a specified DocumentType and time range' do
444
534
  VCR.use_cassette(:analytics_clicks_with_document_type_and_time_range) do
445
535
  clicks = client.analytics_clicks(engine_slug, :document_type_id => 'page', :start_date => '2013-07-01', :end_date => '2013-07-07')
446
- clicks.size.should == 7
447
- clicks.first.should == ['2013-07-07', 0]
536
+ expect(clicks.size).to eq(7)
537
+ expect(clicks.first).to eq(['2013-07-07', 0])
448
538
  end
449
539
  end
450
540
  end
@@ -453,16 +543,16 @@ describe Swiftype::Client do
453
543
  it 'returns top queries' do
454
544
  VCR.use_cassette(:analytics_top_queries) do
455
545
  top_queries = client.analytics_top_queries(engine_slug)
456
- top_queries.size.should == 3
457
- top_queries.first.should == ['"fire watch"', 1]
546
+ expect(top_queries.size).to eq(3)
547
+ expect(top_queries.first).to eq(['"fire watch"', 1])
458
548
  end
459
549
  end
460
550
 
461
551
  it 'returns top queries with pagination' do
462
552
  VCR.use_cassette(:analytics_top_queries_paginated) do
463
553
  top_queries = client.analytics_top_queries(engine_slug, :start_date => '2013-08-01', :end_date => '2013-08-30', :per_page => 5, :page => 2)
464
- top_queries.size.should == 5
465
- top_queries.first.should == ['no simple victory', 1]
554
+ expect(top_queries.size).to eq(5)
555
+ expect(top_queries.first).to eq(['no simple victory', 1])
466
556
  end
467
557
  end
468
558
 
@@ -479,16 +569,16 @@ describe Swiftype::Client do
479
569
  it 'returns top queries with no results for the default time range' do
480
570
  VCR.use_cassette(:analytics_top_no_result_queries) do
481
571
  top_no_result_queries = client.analytics_top_no_result_queries(engine_slug)
482
- top_no_result_queries.size.should == 2
483
- top_no_result_queries.first.should == ['no results', 10]
572
+ expect(top_no_result_queries.size).to eq(2)
573
+ expect(top_no_result_queries.first).to eq(['no results', 10])
484
574
  end
485
575
  end
486
576
 
487
577
  it 'has top no result queries in date ranges' do
488
578
  VCR.use_cassette(:analytics_top_no_result_queries_paginated) do
489
579
  top_no_result_queries = client.analytics_top_no_result_queries(engine_slug, :start_date => '2013-08-01', :end_date => '2013-08-30', :per_page => 5, :page => 2)
490
- top_no_result_queries.size.should == 1
491
- top_no_result_queries.first.should == ['no result again', 2]
580
+ expect(top_no_result_queries.size).to eq(1)
581
+ expect(top_no_result_queries.first).to eq(['no result again', 2])
492
582
  end
493
583
  end
494
584
  end
@@ -501,8 +591,8 @@ describe Swiftype::Client do
501
591
  it 'gets all domains' do
502
592
  VCR.use_cassette(:list_domains) do
503
593
  domains = client.domains(engine_slug)
504
- domains.size.should == 1
505
- domains.first['id'].should == domain_id
594
+ expect(domains.size).to eq(1)
595
+ expect(domains.first['id']).to eq(domain_id)
506
596
  end
507
597
  end
508
598
 
@@ -510,7 +600,7 @@ describe Swiftype::Client do
510
600
  it 'shows a domain if it exists' do
511
601
  VCR.use_cassette(:find_domain) do
512
602
  domain = client.domain(engine_slug, domain_id)
513
- domain['id'].should == domain_id
603
+ expect(domain['id']).to eq(domain_id)
514
604
  end
515
605
  end
516
606
 
@@ -528,7 +618,7 @@ describe Swiftype::Client do
528
618
  VCR.use_cassette(:create_domain) do
529
619
  url = 'http://www.zombo.com/'
530
620
  domain = client.create_domain(engine_slug, url)
531
- domain['submitted_url'].should == url
621
+ expect(domain['submitted_url']).to eq(url)
532
622
  end
533
623
  end
534
624
  end
@@ -536,7 +626,7 @@ describe Swiftype::Client do
536
626
  it 'destroys a domain' do
537
627
  VCR.use_cassette(:destroy_domain) do
538
628
  response = client.destroy_domain(engine_slug, '52324b132ed960589800004a')
539
- response.should be_nil
629
+ expect(response).to be_nil
540
630
  end
541
631
  end
542
632
 
@@ -544,7 +634,7 @@ describe Swiftype::Client do
544
634
  it 'enqueues a request to recrawl a domain' do
545
635
  VCR.use_cassette(:recrawl_domain_success) do
546
636
  domain = client.recrawl_domain(engine_slug, domain_id)
547
- domain['id'].should == domain_id
637
+ expect(domain['id']).to eq(domain_id)
548
638
  end
549
639
  end
550
640
 
@@ -562,7 +652,7 @@ describe Swiftype::Client do
562
652
  VCR.use_cassette(:crawl_url) do
563
653
  url = 'http://crawler-demo-site.herokuapp.com/2012/01/01/first-post.html'
564
654
  crawled_url = client.crawl_url(engine_slug, domain_id, url)
565
- crawled_url['url'].should == url
655
+ expect(crawled_url['url']).to eq(url)
566
656
  end
567
657
  end
568
658
  end
@@ -579,7 +669,7 @@ describe Swiftype::Client do
579
669
  it 'returns nil' do
580
670
  VCR.use_cassette(:log_clickthrough_success) do
581
671
  response = client.log_clickthrough(engine_slug, document_type_slug, query, external_id)
582
- response.should == nil
672
+ expect(response).to eq(nil)
583
673
  end
584
674
  end
585
675