Skip to content

Commit 8b4e067

Browse files
committed
Refactor multi_search_spec to avoid deprecations
1 parent f9640bc commit 8b4e067

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

spec/multi_search_spec.rb

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
Color => { q: 'bl' }
4545
)
4646

47-
expect(results).to contain_exactly(
48-
steve_jobs, palm_pixi_plus, blue, black
47+
expect(results.to_h).to match(
48+
Book => [steve_jobs],
49+
Product => [palm_pixi_plus],
50+
Color => contain_exactly(blue, black)
4951
)
5052
end
5153
end
@@ -69,11 +71,13 @@
6971
'colors' => { q: 'bl', index_uid: Color.index.uid }
7072
)
7173

72-
expect(results).to contain_exactly(
73-
a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs'),
74-
a_hash_including('name' => 'palm pixi plus'),
75-
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
76-
a_hash_including('name' => 'black', 'short_name' => 'bla')
74+
expect(results.to_h).to match(
75+
'books' => [a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs')],
76+
'products' => [a_hash_including('name' => 'palm pixi plus')],
77+
'colors' => contain_exactly(
78+
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
79+
a_hash_including('name' => 'black', 'short_name' => 'bla')
80+
)
7781
)
7882
end
7983

@@ -86,10 +90,10 @@
8690
'nature_colors' => { q: 'green', index_uid: index_uid }
8791
)
8892

89-
expect(results).to contain_exactly(
90-
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
91-
a_hash_including('name' => 'black', 'short_name' => 'bla'),
92-
a_hash_including('name' => 'green', 'short_name' => 'gre')
93+
expect(results.to_h).to match(
94+
'bright_colors' => [a_hash_including('name' => 'blue', 'short_name' => 'blu')],
95+
'dark_colors' => [a_hash_including('name' => 'black', 'short_name' => 'bla')],
96+
'nature_colors' => [a_hash_including('name' => 'green', 'short_name' => 'gre')]
9397
)
9498
end
9599

@@ -101,8 +105,10 @@
101105
'colors' => { q: 'bl', index_uid: Color.index.uid, class_name: 'Color' }
102106
)
103107

104-
expect(results).to contain_exactly(
105-
steve_jobs, palm_pixi_plus, blue, black
108+
expect(results.to_h).to match(
109+
'books' => [steve_jobs],
110+
'products' => [palm_pixi_plus],
111+
'colors' => contain_exactly(blue, black)
106112
)
107113
end
108114
end
@@ -117,11 +123,13 @@
117123
Color.index.uid => { q: 'bl' }
118124
)
119125

120-
expect(results).to contain_exactly(
121-
a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs'),
122-
a_hash_including('name' => 'palm pixi plus'),
123-
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
124-
a_hash_including('name' => 'black', 'short_name' => 'bla')
126+
expect(results.to_h).to match(
127+
Book.index.uid => [a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs')],
128+
Product.index.uid.to_sym => [a_hash_including('name' => 'palm pixi plus')],
129+
Color.index.uid => contain_exactly(
130+
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
131+
a_hash_including('name' => 'black', 'short_name' => 'bla')
132+
)
125133
)
126134
end
127135

@@ -133,8 +141,10 @@
133141
Color.index.uid => { q: 'bl', class_name: 'Color' }
134142
)
135143

136-
expect(results).to contain_exactly(
137-
steve_jobs, palm_pixi_plus, blue, black
144+
expect(results.to_h).to match(
145+
Book.index.uid => [steve_jobs],
146+
Product.index.uid.to_sym => [palm_pixi_plus],
147+
Color.index.uid => contain_exactly(blue, black)
138148
)
139149
end
140150

@@ -158,10 +168,13 @@
158168
Color.index.uid => { q: 'bl' }
159169
)
160170

161-
expect(results).to contain_exactly(
162-
steve_jobs, palm_pixi_plus,
163-
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
164-
a_hash_including('name' => 'black', 'short_name' => 'bla')
171+
expect(results.to_h).to match(
172+
Book => [steve_jobs],
173+
Product.index_uid => [palm_pixi_plus],
174+
Color.index.uid => contain_exactly(
175+
a_hash_including('name' => 'blue', 'short_name' => 'blu'),
176+
a_hash_including('name' => 'black', 'short_name' => 'bla')
177+
)
165178
)
166179
end
167180
end
@@ -176,9 +189,12 @@
176189
Color.index.uid => { q: 'bl', page: 1, 'hitsPerPage' => '1' }
177190
)
178191

179-
expect(results).to contain_exactly(
180-
steve_jobs, palm_pixi_plus,
181-
a_hash_including('name' => 'black', 'short_name' => 'bla')
192+
expect(results.to_h).to match(
193+
Book => [steve_jobs],
194+
Product => [palm_pixi_plus],
195+
Color.index_uid => contain_exactly(
196+
a_hash_including('name' => 'black', 'short_name' => 'bla')
197+
)
182198
)
183199

184200
MeiliSearch::Rails.configuration[:pagination_backend] = nil

0 commit comments

Comments
 (0)