spec/elastic/transport/client_spec.rb in elastic-transport-8.0.1 vs spec/elastic/transport/client_spec.rb in elastic-transport-8.1.0.pre1
- 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 unless jruby?
- end
+ end
+ end unless jruby?
context 'when the adapter is patron' do
let(:adapter) do
client.transport.connections.all.first.connection.builder.adapter
end
@@ -202,20 +202,23 @@
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
+ end unless jruby?
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
@@ -232,11 +235,11 @@
end
it 'uses Faraday with the adapter' do
expect(adapter).to eq Faraday::Adapter::Patron
end
- end
+ end unless jruby?
context 'when the adapter can be detected', unless: jruby? do
around do |example|
require 'patron'; load 'patron.rb'
example.run
@@ -272,11 +275,11 @@
end
it 'sets the logger' do
expect(handlers).to include(Faraday::Response::Logger)
end
- end
+ end unless jruby?
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
@@ -1261,10 +1264,12 @@
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
@@ -1412,9 +1417,11 @@
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