|
13 | 13 | end |
14 | 14 | let(:default_searchable_attributes) { ['*'] } |
15 | 15 | let(:default_displayed_attributes) { ['*'] } |
16 | | - |
17 | 16 | let(:settings_keys) do |
18 | 17 | [ |
19 | 18 | 'rankingRules', |
|
26 | 25 | 'sortableAttributes' |
27 | 26 | ] |
28 | 27 | end |
| 28 | + let(:uid) { random_uid } |
29 | 29 |
|
30 | 30 | context 'On global settings routes' do |
31 | | - before do |
32 | | - @uid = random_uid |
33 | | - client.create_index(@uid) |
34 | | - end |
| 31 | + let(:index) { client.index(uid) } |
35 | 32 |
|
36 | | - let(:index) { client.index(@uid) } |
| 33 | + before { client.create_index(uid) } |
37 | 34 |
|
38 | 35 | it 'gets default values of settings' do |
39 | 36 | response = index.settings |
|
95 | 92 | end |
96 | 93 |
|
97 | 94 | context 'On ranking-rules sub-routes' do |
98 | | - before do |
99 | | - @uid = random_uid |
100 | | - client.create_index(@uid) |
101 | | - end |
102 | | - |
103 | | - let(:index) { client.index(@uid) } |
| 95 | + let(:index) { client.index(uid) } |
104 | 96 | let(:ranking_rules) { ['title:asc', 'words', 'typo'] } |
105 | 97 | let(:wrong_ranking_rules) { ['title:asc', 'typos'] } |
106 | 98 |
|
| 99 | + before { client.create_index(uid) } |
| 100 | + |
107 | 101 | it 'gets default values of ranking rules' do |
108 | 102 | response = index.ranking_rules |
109 | 103 | expect(response).to eq(default_ranking_rules) |
|
150 | 144 | end |
151 | 145 |
|
152 | 146 | context 'On distinct-attribute sub-routes' do |
153 | | - let(:uid) { random_uid } |
154 | 147 | let(:index) { client.index(uid) } |
155 | 148 | let(:distinct_attribute) { 'title' } |
156 | 149 |
|
|
191 | 184 | end |
192 | 185 |
|
193 | 186 | context 'On searchable-attributes sub-routes' do |
194 | | - before do |
195 | | - @uid = random_uid |
196 | | - client.create_index(@uid) |
197 | | - end |
198 | | - |
199 | | - let(:index) { client.index(@uid) } |
| 187 | + let(:index) { client.index(uid) } |
200 | 188 | let(:searchable_attributes) { ['title', 'description'] } |
201 | 189 |
|
| 190 | + before { client.create_index(uid) } |
| 191 | + |
202 | 192 | it 'gets default values of searchable attributes' do |
203 | 193 | response = index.searchable_attributes |
204 | 194 | expect(response).to eq(default_searchable_attributes) |
|
236 | 226 | end |
237 | 227 |
|
238 | 228 | context 'On displayed-attributes sub-routes' do |
239 | | - before do |
240 | | - @uid = random_uid |
241 | | - client.create_index(@uid) |
242 | | - end |
243 | | - |
244 | | - let(:index) { client.index(@uid) } |
| 229 | + let(:index) { client.index(uid) } |
245 | 230 | let(:displayed_attributes) { ['title', 'description'] } |
246 | 231 |
|
| 232 | + before { client.create_index(uid) } |
| 233 | + |
247 | 234 | it 'gets default values of displayed attributes' do |
248 | 235 | response = index.displayed_attributes |
249 | 236 | expect(response).to eq(default_displayed_attributes) |
|
282 | 269 | end |
283 | 270 |
|
284 | 271 | context 'On synonyms sub-routes' do |
285 | | - before do |
286 | | - @uid = random_uid |
287 | | - client.create_index(@uid) |
288 | | - end |
289 | | - |
290 | | - let(:index) { client.index(@uid) } |
| 272 | + let(:index) { client.index(uid) } |
291 | 273 | let(:synonyms) do |
292 | 274 | { |
293 | 275 | wow: ['world of warcraft'], |
|
296 | 278 | } |
297 | 279 | end |
298 | 280 |
|
| 281 | + before { client.create_index(uid) } |
| 282 | + |
299 | 283 | it 'gets an empty hash of synonyms by default' do |
300 | 284 | response = index.synonyms |
301 | 285 | expect(response).to be_a(Hash) |
|
354 | 338 | end |
355 | 339 |
|
356 | 340 | context 'On stop-words sub-routes' do |
357 | | - before do |
358 | | - @uid = random_uid |
359 | | - client.create_index(@uid) |
360 | | - end |
361 | | - |
362 | | - let(:index) { client.index(@uid) } |
| 341 | + let(:index) { client.index(uid) } |
363 | 342 | let(:stop_words_array) { ['the', 'of'] } |
364 | 343 | let(:stop_words_string) { 'a' } |
365 | 344 |
|
| 345 | + before { client.create_index(uid) } |
| 346 | + |
366 | 347 | it 'gets an empty array when there is no stop-words' do |
367 | 348 | response = index.stop_words |
368 | 349 | expect(response).to be_a(Array) |
|
425 | 406 | end |
426 | 407 |
|
427 | 408 | context 'On filterable-attributes sub-routes' do |
428 | | - before do |
429 | | - @uid = random_uid |
430 | | - client.create_index(@uid) |
431 | | - end |
432 | | - |
433 | | - let(:index) { client.index(@uid) } |
| 409 | + let(:index) { client.index(uid) } |
434 | 410 | let(:filterable_attributes) { ['title', 'description'] } |
435 | 411 |
|
| 412 | + before { client.create_index(uid) } |
| 413 | + |
436 | 414 | it 'gets default values of filterable attributes' do |
437 | 415 | response = index.filterable_attributes |
438 | 416 | expect(response).to be_a(Array) |
|
471 | 449 | end |
472 | 450 |
|
473 | 451 | context 'On sortable-attributes sub-routes' do |
474 | | - before do |
475 | | - @uid = random_uid |
476 | | - client.create_index(@uid) |
477 | | - end |
478 | | - |
479 | | - let(:index) { client.index(@uid) } |
| 452 | + let(:index) { client.index(uid) } |
480 | 453 | let(:sortable_attributes) { ['title', 'description'] } |
481 | 454 |
|
| 455 | + before { client.create_index(uid) } |
| 456 | + |
482 | 457 | it 'gets default values of sortable attributes' do |
483 | 458 | response = index.sortable_attributes |
484 | 459 | expect(response).to be_a(Array) |
|
517 | 492 | end |
518 | 493 |
|
519 | 494 | context 'Index with primary-key' do |
520 | | - before do |
521 | | - @uid = random_uid |
522 | | - client.create_index(@uid, primaryKey: 'id') |
523 | | - end |
| 495 | + let(:index) { client.index(uid) } |
524 | 496 |
|
525 | | - let(:index) { client.index(@uid) } |
| 497 | + before { client.create_index(uid, primaryKey: 'id') } |
526 | 498 |
|
527 | 499 | it 'gets the default values of settings' do |
528 | 500 | response = index.settings |
|
624 | 596 | end |
625 | 597 |
|
626 | 598 | context 'Aliases' do |
627 | | - before do |
628 | | - @uid = random_uid |
629 | | - client.create_index(@uid) |
630 | | - end |
| 599 | + let(:index) { client.index(uid) } |
631 | 600 |
|
632 | | - let(:index) { client.index(@uid) } |
| 601 | + before { client.create_index(uid) } |
633 | 602 |
|
634 | 603 | it 'works with method aliases' do |
635 | 604 | expect(index.method(:settings) == index.method(:get_settings)).to be_truthy |
|
0 commit comments