|
220 | 220 | describe 'adapter' do
|
221 | 221 | context 'when no adapter is specified' do
|
222 | 222 | let(:adapter) do
|
223 |
| - client.transport.connections.all.first.connection.builder.handlers |
| 223 | + client.transport.connections.all.first.connection.builder.adapter |
224 | 224 | end
|
225 | 225 |
|
226 | 226 | it 'uses Faraday NetHttp' do
|
227 |
| - expect(adapter).to include(Faraday::Adapter::NetHttp) |
| 227 | + expect(adapter).to eq Faraday::Adapter::NetHttp |
228 | 228 | end
|
229 | 229 | end
|
230 | 230 |
|
231 | 231 | context 'when the adapter is specified' do
|
232 | 232 |
|
233 | 233 | let(:adapter) do
|
234 |
| - client.transport.connections.all.first.connection.builder.handlers |
| 234 | + client.transport.connections.all.first.connection.builder.adapter |
235 | 235 | end
|
236 | 236 |
|
237 | 237 | let(:client) do
|
238 |
| - described_class.new(adapter: :typhoeus) |
| 238 | + described_class.new(adapter: :patron) |
239 | 239 | end
|
240 | 240 |
|
241 | 241 | it 'uses Faraday with the adapter' do
|
242 |
| - expect(adapter).to include(Faraday::Adapter::Typhoeus) |
| 242 | + expect(adapter).to eq Faraday::Adapter::Patron |
243 | 243 | end
|
244 | 244 | end
|
245 | 245 |
|
246 | 246 | context 'when the adapter is specified as a string key' do
|
247 | 247 |
|
248 | 248 | let(:adapter) do
|
249 |
| - client.transport.connections.all.first.connection.builder.handlers |
| 249 | + client.transport.connections.all.first.connection.builder.adapter |
250 | 250 | end
|
251 | 251 |
|
252 | 252 | let(:client) do
|
253 |
| - described_class.new('adapter' => :typhoeus) |
| 253 | + described_class.new('adapter' => :patron) |
254 | 254 | end
|
255 | 255 |
|
256 | 256 | it 'uses Faraday with the adapter' do
|
257 |
| - expect(adapter).to include(Faraday::Adapter::Typhoeus) |
| 257 | + expect(adapter).to eq Faraday::Adapter::Patron |
258 | 258 | end
|
259 | 259 | end
|
260 | 260 |
|
|
266 | 266 | end
|
267 | 267 |
|
268 | 268 | let(:adapter) do
|
269 |
| - client.transport.connections.all.first.connection.builder.handlers |
| 269 | + client.transport.connections.all.first.connection.builder.adapter |
270 | 270 | end
|
271 | 271 |
|
272 | 272 | it 'uses the detected adapter' do
|
273 |
| - expect(adapter).to include(Faraday::Adapter::Patron) |
| 273 | + expect(adapter).to eq Faraday::Adapter::Patron |
274 | 274 | end
|
275 | 275 | end
|
276 | 276 |
|
277 | 277 | context 'when the Faraday adapter is configured' do
|
278 | 278 |
|
279 | 279 | let(:client) do
|
280 | 280 | described_class.new do |faraday|
|
281 |
| - faraday.adapter :typhoeus |
| 281 | + faraday.adapter :patron |
282 | 282 | faraday.response :logger
|
283 | 283 | end
|
284 | 284 | end
|
285 | 285 |
|
| 286 | + let(:adapter) do |
| 287 | + client.transport.connections.all.first.connection.builder.adapter |
| 288 | + end |
| 289 | + |
286 | 290 | let(:handlers) do
|
287 | 291 | client.transport.connections.all.first.connection.builder.handlers
|
288 | 292 | end
|
289 | 293 |
|
290 | 294 | it 'sets the adapter' do
|
291 |
| - expect(handlers).to include(Faraday::Adapter::Typhoeus) |
| 295 | + expect(adapter).to eq Faraday::Adapter::Patron |
292 | 296 | end
|
293 | 297 |
|
294 | 298 | it 'sets the logger' do
|
|
1209 | 1213 | end
|
1210 | 1214 |
|
1211 | 1215 | context 'when the Faraday adapter is set in the block' do
|
1212 |
| - |
1213 | 1216 | let(:client) do
|
1214 | 1217 | Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
|
1215 | 1218 | client.adapter(:net_http_persistent)
|
1216 | 1219 | end
|
1217 | 1220 | end
|
1218 | 1221 |
|
1219 |
| - let(:connection_handler) do |
1220 |
| - client.transport.connections.first.connection.builder.handlers.first |
| 1222 | + let(:handler_name) do |
| 1223 | + client.transport.connections.first.connection.builder.adapter.name |
1221 | 1224 | end
|
1222 | 1225 |
|
1223 | 1226 | let(:response) do
|
1224 | 1227 | client.perform_request('GET', '_cluster/health')
|
1225 | 1228 | end
|
1226 | 1229 |
|
1227 | 1230 | it 'sets the adapter' do
|
1228 |
| - expect(connection_handler.name).to eq('Faraday::Adapter::NetHttpPersistent') |
| 1231 | + expect(handler_name).to eq('Faraday::Adapter::NetHttpPersistent') |
1229 | 1232 | end
|
1230 | 1233 |
|
1231 | 1234 | it 'uses the adapter to connect' do
|
|
1559 | 1562 | { adapter: :patron }
|
1560 | 1563 | end
|
1561 | 1564 |
|
1562 |
| - let(:connection_handler) do |
1563 |
| - client.transport.connections.first.connection.builder.handlers.first |
| 1565 | + let(:adapter) do |
| 1566 | + client.transport.connections.first.connection.builder.adapter |
1564 | 1567 | end
|
1565 | 1568 |
|
1566 | 1569 | it 'uses the patron connection handler' do
|
1567 |
| - expect(connection_handler).to eq('Faraday::Adapter::Patron') |
| 1570 | + expect(adapter).to eq('Faraday::Adapter::Patron') |
1568 | 1571 | end
|
1569 | 1572 |
|
1570 | 1573 | it 'keeps connections open' do
|
|
0 commit comments