diff --git a/elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb b/elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb index 29c30c7a9d..b04345b89b 100644 --- a/elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb +++ b/elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb @@ -220,41 +220,41 @@ describe 'adapter' do context 'when no adapter is specified' do let(:adapter) do - client.transport.connections.all.first.connection.builder.handlers + client.transport.connections.all.first.connection.builder.adapter end it 'uses Faraday NetHttp' do - expect(adapter).to include(Faraday::Adapter::NetHttp) + expect(adapter).to eq Faraday::Adapter::NetHttp end end context 'when the adapter is specified' do let(:adapter) do - client.transport.connections.all.first.connection.builder.handlers + client.transport.connections.all.first.connection.builder.adapter end let(:client) do - described_class.new(adapter: :typhoeus) + described_class.new(adapter: :patron) end it 'uses Faraday with the adapter' do - expect(adapter).to include(Faraday::Adapter::Typhoeus) + expect(adapter).to eq Faraday::Adapter::Patron end end context 'when the adapter is specified as a string key' do let(:adapter) do - client.transport.connections.all.first.connection.builder.handlers + client.transport.connections.all.first.connection.builder.adapter end let(:client) do - described_class.new('adapter' => :typhoeus) + described_class.new('adapter' => :patron) end it 'uses Faraday with the adapter' do - expect(adapter).to include(Faraday::Adapter::Typhoeus) + expect(adapter).to eq Faraday::Adapter::Patron end end @@ -266,11 +266,11 @@ end let(:adapter) do - client.transport.connections.all.first.connection.builder.handlers + client.transport.connections.all.first.connection.builder.adapter end it 'uses the detected adapter' do - expect(adapter).to include(Faraday::Adapter::Patron) + expect(adapter).to eq Faraday::Adapter::Patron end end @@ -278,17 +278,21 @@ let(:client) do described_class.new do |faraday| - faraday.adapter :typhoeus + faraday.adapter :patron faraday.response :logger end end + let(:adapter) do + client.transport.connections.all.first.connection.builder.adapter + end + let(:handlers) do client.transport.connections.all.first.connection.builder.handlers end it 'sets the adapter' do - expect(handlers).to include(Faraday::Adapter::Typhoeus) + expect(adapter).to eq Faraday::Adapter::Patron end it 'sets the logger' do @@ -1209,15 +1213,14 @@ end context 'when the Faraday adapter is set in the block' do - let(:client) do Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client| client.adapter(:net_http_persistent) end end - let(:connection_handler) do - client.transport.connections.first.connection.builder.handlers.first + let(:handler_name) do + client.transport.connections.first.connection.builder.adapter.name end let(:response) do @@ -1225,7 +1228,7 @@ end it 'sets the adapter' do - expect(connection_handler.name).to eq('Faraday::Adapter::NetHttpPersistent') + expect(handler_name).to eq('Faraday::Adapter::NetHttpPersistent') end it 'uses the adapter to connect' do @@ -1559,12 +1562,12 @@ { adapter: :patron } end - let(:connection_handler) do - client.transport.connections.first.connection.builder.handlers.first + let(:adapter) do + client.transport.connections.first.connection.builder.adapter end it 'uses the patron connection handler' do - expect(connection_handler).to eq('Faraday::Adapter::Patron') + expect(adapter).to eq('Faraday::Adapter::Patron') end it 'keeps connections open' do