Skip to content

Commit 7feed1e

Browse files
committed
Create failing cases with snake_case support
#217
1 parent 62765a9 commit 7feed1e

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

spec/meilisearch/client/indexes_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,15 @@
126126
expect(@client.delete_index_if_exists(@uid6)).to eq(false)
127127
expect(@client.indexes.count).to eq(0)
128128
end
129+
130+
context 'with snake_case options' do
131+
it 'creates an index without errors' do
132+
uid = SecureRandom.uuid
133+
134+
expect do
135+
@client.create_index(uid, primary_key: @primary_key)
136+
@client.fetch_index(uid)
137+
end.to_not raise_error
138+
end
139+
end
129140
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe 'MeiliSearch::Client requests' do
4+
let(:key) { SecureRandom.uuid }
5+
6+
before(:each) do
7+
@client = MeiliSearch::Client.new(URL, MASTER_KEY)
8+
9+
expect(MeiliSearch::Client).to receive(:post)
10+
.with(kind_of(String), hash_including(body: "{\"primaryKey\":\"#{key}\",\"uid\":\"#{key}\"}"))
11+
.and_call_original
12+
end
13+
14+
it 'parses options when they are in a snake_case' do
15+
@client.create_index(key, primary_key: key)
16+
end
17+
18+
it 'parses options when they are in a different shape' do
19+
@client.create_index(key, priMARy_kEy: key)
20+
end
21+
end

spec/meilisearch/index/search/multi_params_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,22 @@
9595
expect(response['facetsDistribution']['genre']['fantasy']).to eq(1)
9696
expect(response['exhaustiveFacetsCount']).to be false
9797
end
98+
99+
context 'with snake_case options' do
100+
it 'does a custom search with attributes in a unusual formatting' do
101+
response = @index.search(
102+
'prince',
103+
{
104+
aTTributes_TO_Crop: ['title'],
105+
cropLength: 2,
106+
filter: 'genre = adventure',
107+
attributes_to_highlight: ['title']
108+
}
109+
)
110+
111+
expect(response['hits'].count).to be(1)
112+
expect(response['hits'].first).to have_key('_formatted')
113+
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
114+
end
115+
end
98116
end

0 commit comments

Comments
 (0)