File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 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
129140end
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
98116end
You can’t perform that action at this time.
0 commit comments