spec/elastic/transport/client_spec.rb in elastic-transport-8.1.0 vs spec/elastic/transport/client_spec.rb in elastic-transport-8.1.1
- old
+ new
@@ -189,12 +189,12 @@
let(:adapter) { client.transport.connections.all.first.connection.builder.adapter }
it 'uses Faraday NetHttp' do
expect(adapter).to eq Faraday::Adapter::NetHttp
end
- end
- end unless jruby?
+ end unless jruby?
+ end
context 'when the adapter is patron' do
let(:adapter) do
client.transport.connections.all.first.connection.builder.adapter
end
@@ -202,23 +202,20 @@
let(:client) do
described_class.new(adapter: :patron, enable_meta_header: false)
end
it 'uses Faraday with the adapter' do
- require 'faraday/patron'
expect(adapter).to eq Faraday::Adapter::Patron
end
- end unless jruby?
+ end
context 'when the adapter is typhoeus' do
let(:adapter) do
client.transport.connections.all.first.connection.builder.adapter
end
let(:client) do
- require 'faraday/typhoeus' if is_faraday_v2?
-
described_class.new(adapter: :typhoeus, enable_meta_header: false)
end
it 'uses Faraday with the adapter' do
expect(adapter).to eq Faraday::Adapter::Typhoeus
@@ -235,11 +232,11 @@
end
it 'uses Faraday with the adapter' do
expect(adapter).to eq Faraday::Adapter::Patron
end
- end unless jruby?
+ end
context 'when the adapter can be detected', unless: jruby? do
around do |example|
require 'patron'; load 'patron.rb'
example.run
@@ -275,11 +272,11 @@
end
it 'sets the logger' do
expect(handlers).to include(Faraday::Response::Logger)
end
- end unless jruby?
+ end
end
shared_examples_for 'a client that extracts hosts' do
context 'when the host is a String' do
context 'when there is a protocol specified' do
@@ -1264,12 +1261,10 @@
expect(response.body).to match(/---\n/)
expect(response.headers['content-type']).to eq('application/yaml')
end
context 'when the Faraday adapter is set in the block' do
- require 'faraday/net_http_persistent' if is_faraday_v2?
-
let(:client) do
Elastic::Transport::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
client.adapter(:net_http_persistent)
end
end
@@ -1325,13 +1320,13 @@
{ retry_on_failure: 1 }
end
it 'retries only the specified number of times' do
expect(client.perform_request('GET', '_nodes/_local'))
- expect {
+ expect do
client.perform_request('GET', '_nodes/_local')
- }.to raise_exception(Faraday::ConnectionFailed)
+ end.to raise_exception(Elastic::Transport::Transport::Error)
end
end
context 'when retry_on_failure is true and delay_on_retry is specified' do
context 'when a node is unreachable' do
@@ -1417,11 +1412,9 @@
expect(client.transport.connections[0].connection.headers['User-Agent'])
end
end
context 'when using the HTTPClient adapter' do
- require 'faraday/httpclient'
-
let(:client) do
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :httpclient, enable_meta_header: false)
end
it 'compresses the request and decompresses the response' do