Sha256: a74e872fd6fe03bfb2e8948329bd9ef1fddc3ab6ac3466cf780f26ad6c5881a9

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require File.expand_path('../integration', __FILE__)

module Adapters
  class NetHttpTest < Faraday::TestCase

    def adapter() :net_http end

    behaviors = [:NonParallel]
    behaviors << :Compression if RUBY_VERSION >= '1.9'

    Integration.apply(self, *behaviors)

    def test_connection_errors_get_wrapped
      connection = Faraday.new('http://disney.com') do |b|
        b.adapter :net_http
      end

      exceptions = [
        EOFError,
        Errno::ECONNABORTED,
        Errno::ECONNREFUSED,
        Errno::ECONNRESET,
        Errno::EINVAL,
        Net::HTTPBadResponse,
        Net::HTTPHeaderSyntaxError,
        Net::ProtocolError,
        SocketError
      ]

      exceptions << OpenSSL::SSL::SSLError if defined?(OpenSSL)

      exceptions.each do |exception_class|
        stub_request(:get, 'disney.com/hello').to_raise(exception_class)

        assert_raise(Faraday::Error::ConnectionFailed,
                     "Failed to wrap #{exception_class} exceptions") do
          connection.get('/hello')
        end
      end
    end

    def test_configure_ssl
      http = Net::HTTP.new 'disney.com', 443
      # this should not raise an error
      Faraday::Adapter::NetHttp.new.configure_ssl(http, :ssl => {:verify => true})
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
avdi-faraday-0.8.1 test/adapters/net_http_test.rb
faraday-0.8.1 test/adapters/net_http_test.rb
faraday-0.8.0 test/adapters/net_http_test.rb