Skip to content

Commit b59b1dc

Browse files
jmksbrunoocasali
authored andcommitted
Update specs to use snake_case attributes
1 parent 9203f2c commit b59b1dc

File tree

8 files changed

+71
-72
lines changed

8 files changed

+71
-72
lines changed

spec/meilisearch/client/indexes_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
context 'with a primary key' do
3434
it 'creates an index' do
35-
task = client.create_index('books', primaryKey: 'reference_code')
35+
task = client.create_index('books', primary_key: 'reference_code')
3636

3737
expect(task['type']).to eq('indexCreation')
3838

@@ -46,7 +46,7 @@
4646
end
4747

4848
it 'creates an index synchronously' do
49-
task = client.create_index!('books', primaryKey: 'reference_code')
49+
task = client.create_index!('books', primary_key: 'reference_code')
5050

5151
expect(task['type']).to eq('indexCreation')
5252
expect(task['status']).to eq('succeeded')
@@ -77,7 +77,7 @@
7777
it 'ignores the uid option' do
7878
task = client.create_index(
7979
'books',
80-
primaryKey: 'reference_code',
80+
primary_key: 'reference_code',
8181
uid: 'publications'
8282
)
8383

@@ -173,7 +173,7 @@
173173

174174
describe '#fetch_index' do
175175
it 'fetches index by uid' do
176-
client.create_index!('books', primaryKey: 'reference_code')
176+
client.create_index!('books', primary_key: 'reference_code')
177177

178178
fetched_index = client.fetch_index('books')
179179

@@ -186,7 +186,7 @@
186186

187187
describe '#fetch_raw_index' do
188188
it 'fetch a specific index raw Hash response based on uid' do
189-
client.create_index!('books', primaryKey: 'reference_code')
189+
client.create_index!('books', primary_key: 'reference_code')
190190
index = client.fetch_index('books')
191191
raw_response = index.fetch_raw_info
192192

@@ -202,7 +202,7 @@
202202

203203
describe '#index' do
204204
it 'returns an index object with the provided uid' do
205-
client.create_index!('books', primaryKey: 'reference_code')
205+
client.create_index!('books', primary_key: 'reference_code')
206206
# this index is in memory, without metadata from server
207207
index = client.index('books')
208208

spec/meilisearch/client/keys_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
description: 'A new key to delete docs',
99
actions: ['documents.delete'],
1010
indexes: ['*'],
11-
expiresAt: nil
11+
expires_at: nil
1212
}
1313
end
1414
let(:add_docs_key_options) do
1515
{
1616
description: 'A new key to add docs',
1717
actions: ['documents.add'],
1818
indexes: ['*'],
19-
expiresAt: nil
19+
expires_at: nil
2020
}
2121
end
2222

spec/meilisearch/index/base_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
end
1616

1717
it 'fetch the raw Hash info of the index' do
18-
client.create_index!('books', primaryKey: 'reference_number')
18+
client.create_index!('books', primary_key: 'reference_number')
1919

2020
raw_index = client.fetch_raw_index('books')
2121

@@ -37,7 +37,7 @@
3737
end
3838

3939
it 'get primary-key of index if it exists' do
40-
client.create_index!('index_with_prirmary_key', primaryKey: 'primary_key')
40+
client.create_index!('index_with_prirmary_key', primary_key: 'primary_key')
4141

4242
index = client.fetch_index('index_with_prirmary_key')
4343
expect(index.primary_key).to eq('primary_key')
@@ -54,7 +54,7 @@
5454
it 'updates primary-key of index if not defined before' do
5555
client.create_index!('uid')
5656

57-
task = client.index('uid').update(primaryKey: 'new_primary_key')
57+
task = client.index('uid').update(primary_key: 'new_primary_key')
5858
expect(task['type']).to eq('indexUpdate')
5959
client.wait_for_task(task['taskUid'])
6060

@@ -70,9 +70,9 @@
7070
end
7171

7272
it 'updates primary-key of index if has been defined before but there is not docs' do
73-
client.create_index!('books', primaryKey: 'reference_number')
73+
client.create_index!('books', primary_key: 'reference_number')
7474

75-
task = client.index('books').update(primaryKey: 'international_standard_book_number')
75+
task = client.index('books').update(primary_key: 'international_standard_book_number')
7676
expect(task['type']).to eq('indexUpdate')
7777
client.wait_for_task(task['taskUid'])
7878

@@ -91,7 +91,7 @@
9191
index = client.index('uid')
9292
index.add_documents!({ id: 1, title: 'My Title' })
9393

94-
task = index.update(primaryKey: 'new_primary_key')
94+
task = index.update(primary_key: 'new_primary_key')
9595
expect(task['type']).to eq('indexUpdate')
9696
achieved_task = client.wait_for_task(task['taskUid'])
9797

@@ -177,7 +177,7 @@
177177
end
178178

179179
it 'works with method aliases' do
180-
client.create_index!('uid', primaryKey: 'primary_key')
180+
client.create_index!('uid', primary_key: 'primary_key')
181181

182182
index = client.fetch_index('uid')
183183
expect(index.method(:fetch_primary_key) == index.method(:get_primary_key)).to be_truthy

spec/meilisearch/index/search/attributes_to_crop_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
before { index.add_documents!(document) }
1414

1515
it 'searches with default cropping params' do
16-
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6)
16+
response = index.search('galaxy', attributes_to_crop: ['*'], crop_length: 6)
1717

1818
expect(response.dig('hits', 0, '_formatted', 'description')).to eq('…Guide to the Galaxy is a…')
1919
end
2020

2121
it 'searches with custom crop markers' do
22-
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6, cropMarker: '(ꈍᴗꈍ)')
22+
response = index.search('galaxy', attributes_to_crop: ['*'], crop_length: 6, crop_marker: '(ꈍᴗꈍ)')
2323

2424
expect(response.dig('hits', 0, '_formatted', 'description')).to eq('(ꈍᴗꈍ)Guide to the Galaxy is a(ꈍᴗꈍ)')
2525
end
2626

2727
it 'searches with mixed highlight and crop config' do
2828
response = index.search(
2929
'galaxy',
30-
attributesToHighlight: ['*'],
31-
attributesToCrop: ['*'],
32-
highlightPreTag: '<span class="bold">'
30+
attributes_to_highlight: ['*'],
31+
attributes_to_crop: ['*'],
32+
highlight_pre_tag: '<span class="bold">'
3333
)
3434

3535
expect(response.dig('hits', 0, '_formatted', 'description')).to \
@@ -39,22 +39,22 @@
3939
it 'searches with highlight tags' do
4040
response = index.search(
4141
'galaxy',
42-
attributesToHighlight: ['*'],
43-
highlightPreTag: '<span>',
44-
highlightPostTag: '</span>'
42+
attributes_to_highlight: ['*'],
43+
highlight_pre_tag: '<span>',
44+
highlight_post_tag: '</span>'
4545
)
4646

4747
expect(response.dig('hits', 0, '_formatted', 'description')).to include('<span>Galaxy</span>')
4848
end
4949

5050
it 'does a custom search with attributes to crop' do
51-
response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 6 })
51+
response = index.search('galaxy', { attributes_to_crop: ['description'], crop_length: 6 })
5252
expect(response['hits'].first).to have_key('_formatted')
5353
expect(response['hits'].first['_formatted']['description']).to eq('…Guide to the Galaxy is a…')
5454
end
5555

5656
it 'does a placehodler search with attributes to crop' do
57-
response = index.search('', { attributesToCrop: ['description'], cropLength: 5 })
57+
response = index.search('', { attributes_to_crop: ['description'], crop_length: 5 })
5858
expect(response['hits'].first).to have_key('_formatted')
5959
expect(response['hits'].first['description']).to eq(document[:description])
6060
expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker's Guide to…")

spec/meilisearch/index/search/attributes_to_highlight.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
include_context 'search books with genre'
55

66
it 'does a custom search with highlight' do
7-
response = index.search('the', attributesToHighlight: ['title'])
7+
response = index.search('the', attributes_to_highlight: ['title'])
88
expect(response).to be_a(Hash)
99
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
1010
expect(response['hits'].count).to eq(3)
@@ -13,15 +13,15 @@
1313
end
1414

1515
it 'does a placeholder search with attributes to highlight' do
16-
response = index.search('', attributesToHighlight: ['*'])
16+
response = index.search('', attributes_to_highlight: ['*'])
1717
expect(response).to be_a(Hash)
1818
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
1919
expect(response['hits'].count).to eq(7)
2020
expect(response['hits'].first).to have_key('_formatted')
2121
end
2222

2323
it 'does a placeholder search (nil) with attributes to highlight' do
24-
response = index.search(nil, attributesToHighlight: ['*'])
24+
response = index.search(nil, attributes_to_highlight: ['*'])
2525
expect(response).to be_a(Hash)
2626
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
2727
expect(response['hits'].count).to eq(documents.count)

spec/meilisearch/index/search/attributes_to_retrieve_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
RSpec.describe 'MeiliSearch::Index - Search with attributes to retrieve' do
44
include_context 'search books with genre'
55

6-
it 'does a custom search with one attributesToRetrieve' do
7-
response = index.search('the', attributesToRetrieve: ['title'])
6+
it 'does a custom search with one attributes_to_retrieve' do
7+
response = index.search('the', attributes_to_retrieve: ['title'])
88
expect(response).to be_a(Hash)
99
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
1010
expect(response['hits'].count).to eq(3)
@@ -13,8 +13,8 @@
1313
expect(response['hits'].first).not_to have_key('genre')
1414
end
1515

16-
it 'does a custom search with multiple attributesToRetrieve' do
17-
response = index.search('the', attributesToRetrieve: ['title', 'genre'])
16+
it 'does a custom search with multiple attributes_to_retrieve' do
17+
response = index.search('the', attributes_to_retrieve: ['title', 'genre'])
1818
expect(response).to be_a(Hash)
1919
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
2020
expect(response['hits'].count).to eq(3)
@@ -23,8 +23,8 @@
2323
expect(response['hits'].first).to have_key('genre')
2424
end
2525

26-
it 'does a custom search with all attributesToRetrieve' do
27-
response = index.search('the', attributesToRetrieve: ['*'])
26+
it 'does a custom search with all attributes_to_retrieve' do
27+
response = index.search('the', attributes_to_retrieve: ['*'])
2828
expect(response).to be_a(Hash)
2929
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
3030
expect(response['hits'].count).to eq(3)
@@ -33,8 +33,8 @@
3333
expect(response['hits'].first).to have_key('genre')
3434
end
3535

36-
it 'does a placeholder search with one attributesToRetrieve' do
37-
response = index.search('', attributesToRetrieve: ['title'])
36+
it 'does a placeholder search with one attributes_to_retrieve' do
37+
response = index.search('', attributes_to_retrieve: ['title'])
3838
expect(response).to be_a(Hash)
3939
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
4040
expect(response['hits'].count).to eq(documents.count)
@@ -43,8 +43,8 @@
4343
expect(response['hits'].first).not_to have_key('genre')
4444
end
4545

46-
it 'does a placeholder search with multiple attributesToRetrieve' do
47-
response = index.search('', attributesToRetrieve: ['title', 'genre'])
46+
it 'does a placeholder search with multiple attributes_to_retrieve' do
47+
response = index.search('', attributes_to_retrieve: ['title', 'genre'])
4848
expect(response).to be_a(Hash)
4949
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
5050
expect(response['hits'].count).to eq(documents.count)
@@ -53,8 +53,8 @@
5353
expect(response['hits'].first).to have_key('genre')
5454
end
5555

56-
it 'does a placeholder search with all attributesToRetrieve' do
57-
response = index.search('', attributesToRetrieve: ['*'])
56+
it 'does a placeholder search with all attributes_to_retrieve' do
57+
response = index.search('', attributes_to_retrieve: ['*'])
5858
expect(response).to be_a(Hash)
5959
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
6060
expect(response['hits'].count).to eq(documents.count)

spec/meilisearch/index/search/multi_params_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
it 'does a custom search with attributes to crop, filter and attributes to highlight' do
1212
response = index.search('prince',
1313
{
14-
attributesToCrop: ['title'],
15-
cropLength: 2,
14+
attributes_to_crop: ['title'],
15+
crop_length: 2,
1616
filter: 'genre = adventure',
17-
attributesToHighlight: ['title']
17+
attributes_to_highlight: ['title']
1818
})
1919
expect(response['hits'].count).to be(1)
2020
expect(response['hits'].first).to have_key('_formatted')
2121
expect(response['hits'].first['_formatted']['title']).to eq('…Petit <em>Prince</em>')
2222
end
2323

24-
it 'does a custom search with attributesToRetrieve and a limit' do
25-
response = index.search('the', attributesToRetrieve: ['title', 'genre'], limit: 2)
24+
it 'does a custom search with attributes_to_retrieve and a limit' do
25+
response = index.search('the', attributes_to_retrieve: ['title', 'genre'], limit: 2)
2626
expect(response).to be_a(Hash)
2727
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
2828
expect(response['hits'].count).to eq(2)
@@ -37,21 +37,21 @@
3737
end
3838

3939
it 'does a custom search with limit and attributes to highlight' do
40-
response = index.search('the', { limit: 1, attributesToHighlight: ['*'] })
40+
response = index.search('the', { limit: 1, attributes_to_highlight: ['*'] })
4141
expect(response).to be_a(Hash)
4242
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
4343
expect(response['hits'].count).to eq(1)
4444
expect(response['hits'].first).to have_key('_formatted')
4545
end
4646

47-
it 'does a custom search with filter, attributesToRetrieve and attributesToHighlight' do
47+
it 'does a custom search with filter, attributes_to_retrieve and attributes_to_highlight' do
4848
response = index.update_filterable_attributes(['genre'])
4949
index.wait_for_task(response['taskUid'])
5050
response = index.search('prinec',
5151
{
5252
filter: ['genre = fantasy'],
53-
attributesToRetrieve: ['title'],
54-
attributesToHighlight: ['*']
53+
attributes_to_retrieve: ['title'],
54+
attributes_to_highlight: ['*']
5555
})
5656
expect(response.keys).to contain_exactly(*DEFAULT_SEARCH_RESPONSE_KEYS)
5757
expect(response['estimatedTotalHits']).to eq(1)
@@ -86,7 +86,7 @@
8686
'prince',
8787
{
8888
aTTributes_TO_Crop: ['title'],
89-
cropLength: 2,
89+
crop_length: 2,
9090
filter: 'genre = adventure',
9191
attributes_to_highlight: ['title']
9292
}

0 commit comments

Comments
 (0)