|
91 | 91 | describe 'adapter' do |
92 | 92 | context 'when no adapter is specified' do |
93 | 93 | let(:adapter) do |
94 | | - client.transport.connections.all.first.connection.builder.handlers |
| 94 | + client.transport.connections.all.first.connection.builder.adapter |
95 | 95 | end |
96 | 96 |
|
97 | 97 | it 'uses Faraday NetHttp' do |
98 | | - expect(adapter).to include(Faraday::Adapter::NetHttp) |
| 98 | + expect(adapter).to eq Faraday::Adapter::NetHttp |
99 | 99 | end |
100 | 100 | end |
101 | 101 |
|
102 | 102 | context 'when the adapter is specified' do |
103 | 103 |
|
104 | 104 | let(:adapter) do |
105 | | - client.transport.connections.all.first.connection.builder.handlers |
| 105 | + client.transport.connections.all.first.connection.builder.adapter |
106 | 106 | end |
107 | 107 |
|
108 | 108 | let(:client) do |
109 | | - described_class.new(adapter: :typhoeus) |
| 109 | + described_class.new(adapter: :patron) |
110 | 110 | end |
111 | 111 |
|
112 | | - it 'uses Faraday' do |
113 | | - expect(adapter).to include(Faraday::Adapter::Typhoeus) |
| 112 | + it 'uses Faraday with the adapter' do |
| 113 | + expect(adapter).to eq Faraday::Adapter::Patron |
| 114 | + end |
| 115 | + end |
| 116 | + |
| 117 | + context 'when the adapter is specified as a string key' do |
| 118 | + |
| 119 | + let(:adapter) do |
| 120 | + client.transport.connections.all.first.connection.builder.adapter |
| 121 | + end |
| 122 | + |
| 123 | + let(:client) do |
| 124 | + described_class.new('adapter' => :patron) |
| 125 | + end |
| 126 | + |
| 127 | + it 'uses Faraday with the adapter' do |
| 128 | + expect(adapter).to eq Faraday::Adapter::Patron |
114 | 129 | end |
115 | 130 | end |
116 | 131 |
|
|
122 | 137 | end |
123 | 138 |
|
124 | 139 | let(:adapter) do |
125 | | - client.transport.connections.all.first.connection.builder.handlers |
| 140 | + client.transport.connections.all.first.connection.builder.adapter |
126 | 141 | end |
127 | 142 |
|
128 | 143 | it 'uses the detected adapter' do |
129 | | - expect(adapter).to include(Faraday::Adapter::Patron) |
| 144 | + expect(adapter).to eq Faraday::Adapter::Patron |
130 | 145 | end |
131 | 146 | end |
132 | 147 |
|
133 | 148 | context 'when the Faraday adapter is configured' do |
134 | 149 |
|
135 | 150 | let(:client) do |
136 | 151 | described_class.new do |faraday| |
137 | | - faraday.adapter :typhoeus |
| 152 | + faraday.adapter :patron |
138 | 153 | faraday.response :logger |
139 | 154 | end |
140 | 155 | end |
141 | 156 |
|
| 157 | + let(:adapter) do |
| 158 | + client.transport.connections.all.first.connection.builder.adapter |
| 159 | + end |
| 160 | + |
142 | 161 | let(:handlers) do |
143 | 162 | client.transport.connections.all.first.connection.builder.handlers |
144 | 163 | end |
145 | 164 |
|
146 | 165 | it 'sets the adapter' do |
147 | | - expect(handlers).to include(Faraday::Adapter::Typhoeus) |
| 166 | + expect(adapter).to eq Faraday::Adapter::Patron |
148 | 167 | end |
149 | 168 |
|
150 | 169 | it 'sets the logger' do |
|
766 | 785 | end |
767 | 786 |
|
768 | 787 | context 'when the Faraday adapter is set in the block' do |
769 | | - |
770 | 788 | let(:client) do |
771 | 789 | Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client| |
772 | 790 | client.adapter(:net_http_persistent) |
773 | 791 | end |
774 | 792 | end |
775 | 793 |
|
776 | | - let(:connection_handler) do |
777 | | - client.transport.connections.first.connection.builder.handlers.first |
| 794 | + let(:handler_name) do |
| 795 | + client.transport.connections.first.connection.builder.adapter.name |
778 | 796 | end |
779 | 797 |
|
780 | 798 | let(:response) do |
781 | 799 | client.perform_request('GET', '_cluster/health') |
782 | 800 | end |
783 | 801 |
|
784 | 802 | it 'sets the adapter' do |
785 | | - expect(connection_handler.name).to eq('Faraday::Adapter::NetHttpPersistent') |
| 803 | + expect(handler_name).to eq('Faraday::Adapter::NetHttpPersistent') |
786 | 804 | end |
787 | 805 |
|
788 | 806 | it 'uses the adapter to connect' do |
|
981 | 999 | { adapter: :patron } |
982 | 1000 | end |
983 | 1001 |
|
984 | | - let(:connection_handler) do |
985 | | - client.transport.connections.first.connection.builder.handlers.first |
| 1002 | + let(:adapter) do |
| 1003 | + client.transport.connections.first.connection.builder.adapter |
986 | 1004 | end |
987 | 1005 |
|
988 | 1006 | it 'uses the patron connection handler' do |
989 | | - expect(connection_handler).to eq('Faraday::Adapter::Patron') |
| 1007 | + expect(adapter).to eq('Faraday::Adapter::Patron') |
990 | 1008 | end |
991 | 1009 |
|
992 | 1010 | it 'keeps connections open' do |
|
0 commit comments