Sha256: 6d7913f4b86bd449fdd13264a4d900c9c091cc016756135fa09c76e2272d8ca6

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe Excon do
  context "when dispatching requests" do
    context('to a server that does not supply response headers') do
      include_context("test server", :exec, 'bad.rb', :before => :start, :after => :stop )
      before(:all) do
        @conn = Excon.new('http://127.0.0.1:9292')
      end

      context('when no block is given') do
        it 'should rescue from an EOFError and return response' do
          body = @conn.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking').body
        expect(body).to eq 'hello'
        end
      end

      context('when a block is given') do
        it 'should rescue from EOFError and return response' do
          body = ""
          response_block = lambda {|chunk, remaining, total| body << chunk }
          @conn.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking', :response_block => response_block)
          expect(body).to eq 'hello'
        end
      end
    end

    context('to a server that prematurely aborts the request with no response') do
      include_context("test server", :exec, 'eof.rb', :before => :start, :after => :stop )

      it 'should raise an EOFError' do
        expect { Excon.get('http://127.0.0.1:9292/eof') }.to raise_error(Excon::Errors::SocketError)
      end
    end
  end
end

Version data entries

16 entries across 14 versions & 2 rubygems

Version Path
excon-0.64.0 spec/requests/eof_requests_spec.rb
excon-0.63.0 spec/requests/eof_requests_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/excon-0.62.0/spec/requests/eof_requests_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/excon-0.62.0/spec/requests/eof_requests_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/excon-0.62.0/spec/requests/eof_requests_spec.rb
excon-0.62.0 spec/requests/eof_requests_spec.rb
excon-0.61.0 spec/requests/eof_requests_spec.rb
excon-0.60.0 spec/requests/eof_requests_spec.rb
excon-0.59.0 spec/requests/eof_requests_spec.rb
excon-0.58.0 spec/requests/eof_requests_spec.rb
excon-0.57.1 spec/requests/eof_requests_spec.rb
excon-0.57.0 spec/requests/eof_requests_spec.rb
excon-0.56.0 spec/requests/eof_requests_spec.rb
excon-0.55.0 spec/requests/eof_requests_spec.rb
excon-0.54.0 spec/requests/eof_requests_spec.rb
excon-0.53.0 spec/requests/eof_requests_spec.rb