Sha256: 6c5343180753f9d020e9b7fe2ee06c86e6ba45f93aaac2b1cc35ed081166d0b2

Contents?: true

Size: 1.73 KB

Versions: 36

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

RSpec.describe Faraday::ProxyOptions do
  describe '#from' do
    it 'works with string' do
      options = Faraday::ProxyOptions.from 'http://user:pass@example.org'
      expect(options.user).to eq('user')
      expect(options.password).to eq('pass')
      expect(options.uri).to be_a_kind_of(URI)
      expect(options.path).to eq('')
      expect(options.port).to eq(80)
      expect(options.host).to eq('example.org')
      expect(options.scheme).to eq('http')
      expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
    end

    it 'defaults to http' do
      options = Faraday::ProxyOptions.from 'example.org'
      expect(options.port).to eq(80)
      expect(options.host).to eq('example.org')
      expect(options.scheme).to eq('http')
    end

    it 'works with nil' do
      options = Faraday::ProxyOptions.from nil
      expect(options).to be_a_kind_of(Faraday::ProxyOptions)
      expect(options.inspect).to eq('#<Faraday::ProxyOptions (empty)>')
    end

    it 'works with no auth' do
      proxy = Faraday::ProxyOptions.from 'http://example.org'
      expect(proxy.user).to be_nil
      expect(proxy.password).to be_nil
    end

    it 'treats empty string as nil' do
      proxy = nil
      proxy_string = proxy.to_s # => empty string
      options = Faraday::ProxyOptions.from proxy_string
      expect(options).to be_a_kind_of(Faraday::ProxyOptions)
      expect(options.inspect).to eq('#<Faraday::ProxyOptions (empty)>')
    end
  end

  it 'allows hash access' do
    proxy = Faraday::ProxyOptions.from 'http://a%40b:pw%20d@example.org'
    expect(proxy.user).to eq('a@b')
    expect(proxy[:user]).to eq('a@b')
    expect(proxy.password).to eq('pw d')
    expect(proxy[:password]).to eq('pw d')
  end
end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
es_cli-0.1.0 vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/proxy_options_spec.rb
faraday-2.12.2 spec/faraday/options/proxy_options_spec.rb
faraday-2.12.1 spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
faraday-2.12.0 spec/faraday/options/proxy_options_spec.rb
faraday-2.11.0 spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
faraday-2.10.1 spec/faraday/options/proxy_options_spec.rb
faraday-2.10.0 spec/faraday/options/proxy_options_spec.rb
faraday-2.9.2 spec/faraday/options/proxy_options_spec.rb
faraday-2.9.1 spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.4 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb
moneykit-0.1.3 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/spec/faraday/options/proxy_options_spec.rb