Sha256: 8e119b6c3dc5f52e2c31eaae3f0512c2b6f3aa50e5917ba2a1ec27d4def7768c

Contents?: true

Size: 1.64 KB

Versions: 79

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

RSpec.describe Faraday::Adapter::NetHttp do
  features :request_body_on_query_methods, :reason_phrase_parse, :compression, :streaming, :trace_method

  it_behaves_like 'an adapter'

  context 'checking http' do
    let(:url) { URI('http://example.com') }
    let(:adapter) { described_class.new }
    let(:http) { adapter.send(:connection, url: url, request: {}) }

    it { expect(http.port).to eq(80) }

    it 'sets max_retries to 0' do
      adapter.send(:configure_request, http, {})

      expect(http.max_retries).to eq(0) if http.respond_to?(:max_retries=)
    end

    it 'supports write_timeout' do
      adapter.send(:configure_request, http, write_timeout: 10)

      expect(http.write_timeout).to eq(10) if http.respond_to?(:write_timeout=)
    end

    it 'supports open_timeout' do
      adapter.send(:configure_request, http, open_timeout: 10)

      expect(http.open_timeout).to eq(10)
    end

    it 'supports read_timeout' do
      adapter.send(:configure_request, http, read_timeout: 10)

      expect(http.read_timeout).to eq(10)
    end

    context 'with https url' do
      let(:url) { URI('https://example.com') }

      it { expect(http.port).to eq(443) }
    end

    context 'with http url including port' do
      let(:url) { URI('https://example.com:1234') }

      it { expect(http.port).to eq(1234) }
    end

    context 'with custom adapter config' do
      let(:adapter) do
        described_class.new do |http|
          http.continue_timeout = 123
        end
      end

      it do
        adapter.send(:configure_request, http, {})
        expect(http.continue_timeout).to eq(123)
      end
    end
  end
end

Version data entries

79 entries across 66 versions & 15 rubygems

Version Path
faraday-1.10.4 spec/faraday/adapter/net_http_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/faraday-1.2.0/spec/faraday/adapter/net_http_spec.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/faraday-1.10.3/spec/faraday/adapter/net_http_spec.rb
faraday-1.10.3 spec/faraday/adapter/net_http_spec.rb
faraday-1.10.2 spec/faraday/adapter/net_http_spec.rb
faraday-1.10.1 spec/faraday/adapter/net_http_spec.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.0.1/spec/faraday/adapter/net_http_spec.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/spec/faraday/adapter/net_http_spec.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.10.0/spec/faraday/adapter/net_http_spec.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/spec/faraday/adapter/net_http_spec.rb
faraday-1.10.0 spec/faraday/adapter/net_http_spec.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/faraday-1.9.3/spec/faraday/adapter/net_http_spec.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/spec/faraday/adapter/net_http_spec.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.9.3/spec/faraday/adapter/net_http_spec.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/faraday-1.9.3/spec/faraday/adapter/net_http_spec.rb
faraday-1.9.3 spec/faraday/adapter/net_http_spec.rb
faraday-1.9.2 spec/faraday/adapter/net_http_spec.rb
faraday-1.9.1 spec/faraday/adapter/net_http_spec.rb
faraday-1.9.0 spec/faraday/adapter/net_http_spec.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/spec/faraday/adapter/net_http_spec.rb