Skip to content

Commit 9e316a7

Browse files
committed
Fix RuboCop violations
1 parent db2ae7b commit 9e316a7

File tree

2 files changed

+33
-64
lines changed

2 files changed

+33
-64
lines changed

spec/meilisearch/index/search/multi_params_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
response = index.update_filterable_attributes(['genre'])
4949
index.wait_for_pending_update(response['updateId'])
5050
response = index.search('prinec',
51-
{
52-
filter: ['genre = fantasy'],
53-
attributesToRetrieve: ['title'],
54-
attributesToHighlight: ['*']
55-
})
51+
{
52+
filter: ['genre = fantasy'],
53+
attributesToRetrieve: ['title'],
54+
attributesToHighlight: ['*']
55+
})
5656
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
5757
expect(response['nbHits']).to eq(1)
5858
expect(response['hits'].first).to have_key('_formatted')

spec/meilisearch/index/settings_spec.rb

Lines changed: 28 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
end
1414
let(:default_searchable_attributes) { ['*'] }
1515
let(:default_displayed_attributes) { ['*'] }
16-
1716
let(:settings_keys) do
1817
[
1918
'rankingRules',
@@ -26,14 +25,12 @@
2625
'sortableAttributes'
2726
]
2827
end
28+
let(:uid) { random_uid }
2929

3030
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) }
3532

36-
let(:index) { client.index(@uid) }
33+
before { client.create_index(uid) }
3734

3835
it 'gets default values of settings' do
3936
response = index.settings
@@ -95,15 +92,12 @@
9592
end
9693

9794
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) }
10496
let(:ranking_rules) { ['title:asc', 'words', 'typo'] }
10597
let(:wrong_ranking_rules) { ['title:asc', 'typos'] }
10698

99+
before { client.create_index(uid) }
100+
107101
it 'gets default values of ranking rules' do
108102
response = index.ranking_rules
109103
expect(response).to eq(default_ranking_rules)
@@ -150,7 +144,6 @@
150144
end
151145

152146
context 'On distinct-attribute sub-routes' do
153-
let(:uid) { random_uid }
154147
let(:index) { client.index(uid) }
155148
let(:distinct_attribute) { 'title' }
156149

@@ -191,14 +184,11 @@
191184
end
192185

193186
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) }
200188
let(:searchable_attributes) { ['title', 'description'] }
201189

190+
before { client.create_index(uid) }
191+
202192
it 'gets default values of searchable attributes' do
203193
response = index.searchable_attributes
204194
expect(response).to eq(default_searchable_attributes)
@@ -236,14 +226,11 @@
236226
end
237227

238228
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) }
245230
let(:displayed_attributes) { ['title', 'description'] }
246231

232+
before { client.create_index(uid) }
233+
247234
it 'gets default values of displayed attributes' do
248235
response = index.displayed_attributes
249236
expect(response).to eq(default_displayed_attributes)
@@ -282,12 +269,7 @@
282269
end
283270

284271
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) }
291273
let(:synonyms) do
292274
{
293275
wow: ['world of warcraft'],
@@ -296,6 +278,8 @@
296278
}
297279
end
298280

281+
before { client.create_index(uid) }
282+
299283
it 'gets an empty hash of synonyms by default' do
300284
response = index.synonyms
301285
expect(response).to be_a(Hash)
@@ -354,15 +338,12 @@
354338
end
355339

356340
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) }
363342
let(:stop_words_array) { ['the', 'of'] }
364343
let(:stop_words_string) { 'a' }
365344

345+
before { client.create_index(uid) }
346+
366347
it 'gets an empty array when there is no stop-words' do
367348
response = index.stop_words
368349
expect(response).to be_a(Array)
@@ -425,14 +406,11 @@
425406
end
426407

427408
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) }
434410
let(:filterable_attributes) { ['title', 'description'] }
435411

412+
before { client.create_index(uid) }
413+
436414
it 'gets default values of filterable attributes' do
437415
response = index.filterable_attributes
438416
expect(response).to be_a(Array)
@@ -471,14 +449,11 @@
471449
end
472450

473451
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) }
480453
let(:sortable_attributes) { ['title', 'description'] }
481454

455+
before { client.create_index(uid) }
456+
482457
it 'gets default values of sortable attributes' do
483458
response = index.sortable_attributes
484459
expect(response).to be_a(Array)
@@ -517,12 +492,9 @@
517492
end
518493

519494
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) }
524496

525-
let(:index) { client.index(@uid) }
497+
before { client.create_index(uid, primaryKey: 'id') }
526498

527499
it 'gets the default values of settings' do
528500
response = index.settings
@@ -624,12 +596,9 @@
624596
end
625597

626598
context 'Aliases' do
627-
before do
628-
@uid = random_uid
629-
client.create_index(@uid)
630-
end
599+
let(:index) { client.index(uid) }
631600

632-
let(:index) { client.index(@uid) }
601+
before { client.create_index(uid) }
633602

634603
it 'works with method aliases' do
635604
expect(index.method(:settings) == index.method(:get_settings)).to be_truthy

0 commit comments

Comments
 (0)