Sha256: 52eb37e359e26ab7d6c348e4ebb9de8fc390b0e64efa522f9962388295166880

Contents?: true

Size: 1.31 KB

Versions: 26

Compression:

Stored size: 1.31 KB

Contents

require "spec_helper"
require "support/error_helper"

describe HTTPI do
  include ErrorHelper

  context "with :httpclient" do
    it "tags Errno::ECONNREFUSED with HTTPI::ConnectionError" do
      expect_error(Errno::ECONNREFUSED, "Connection refused - connect(2)").to be_tagged_with(HTTPI::ConnectionError)
    end

    def fake_error(error, message)
      request(:httpclient) { |client| client.expects(:request).raises(error, message) }
    end
  end

  unless RUBY_PLATFORM =~ /java/
    context "with :curb" do
      it "tags Curl::Err::ConnectionFailedError with HTTPI::ConnectionError" do
        expect_error(Curl::Err::ConnectionFailedError, "Curl::Err::ConnectionFailedError").to be_tagged_with(HTTPI::ConnectionError)
      end

      def fake_error(error, message)
        request(:curb) { |client| client.expects(:send).raises(error, message) }
      end
    end
  end

  context "with :net_http" do
    it "tags Errno::ECONNREFUSED with HTTPI::ConnectionError" do
      expect_error(Errno::ECONNREFUSED, "Connection refused - connect(2)").to be_tagged_with(HTTPI::ConnectionError)
    end

    def fake_error(error, message)
      request(:net_http) { |client| client.expects(:start).raises(error, message) }
    end
  end

  def request(adapter)
    HTTPI.get("http://example.com", adapter) { |client| yield client }
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
httpi-4.0.3 spec/httpi/error_spec.rb
httpi-4.0.2 spec/httpi/error_spec.rb
httpi-4.0.1 spec/httpi/error_spec.rb
httpi-3.0.2 spec/httpi/error_spec.rb
httpi-3.0.1 spec/httpi/error_spec.rb
httpi-3.0.0 spec/httpi/error_spec.rb
httpi-2.5.0 spec/httpi/error_spec.rb
httpi-2.4.5 spec/httpi/error_spec.rb
httpi-2.4.4 spec/httpi/error_spec.rb
httpi-2.4.3 spec/httpi/error_spec.rb
httpi-2.4.2 spec/httpi/error_spec.rb
httpi-2.4.1 spec/httpi/error_spec.rb
httpi-2.4.0 spec/httpi/error_spec.rb
httpi-2.3.0 spec/httpi/error_spec.rb
httpi-2.1.1 spec/httpi/error_spec.rb
httpi-2.2.7 spec/httpi/error_spec.rb
httpi-2.2.6 spec/httpi/error_spec.rb
httpi-2.2.5 spec/httpi/error_spec.rb
httpi-2.2.4 spec/httpi/error_spec.rb
httpi-2.2.3 spec/httpi/error_spec.rb