Sha256: b43b98ec21c662b6f0bc615a9fc5198a0a81d1c81fe21959f0b54eb8a5650adb
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
# encoding: utf-8 require 'spec_helper' describe 'Client error handling', reactor: true do include_context :server_client_pair let(:served) { client.perform(open_request) } subject! { client.close(reason) } describe 'on connection error' do let(:reason) { Errno::ENETUNREACH } it 'rejects promises' do expect(client).to be_closed expect(client).to be_error expect(client).to be_network_fault expect(served).to be_rejected expect(served.reason).to be(reason) end end describe 'on timeout' do let(:reason) { Errno::ETIMEDOUT } it 'rejects promises' do expect(client).to be_closed expect(client).to be_error expect(client).to be_timeout expect(served).to be_rejected expect(served.reason).to be(reason) end end end describe 'Server error handling', reactor: true do include_context :server_client_pair describe 'on application error' do let(:server_config) { { handlers: [handler] } } let(:handler) { double('handler') } let(:reason) { RuntimeError.new } before do allow(handler).to receive(:serve) { raise reason } end subject! do client.perform(open_request) tick(2) end it 'rejects promises' do expect(server).to be_closed expect(server).to be_error end end describe 'on timeout' do subject! do client.perform(open_request) tick(1) server.close(Errno::ETIMEDOUT) tick(1) end it 'rejects promises' do expect(server).to be_closed expect(server).to be_error expect(server).to be_timeout end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
httpkit-0.6.0 | spec/integration/error_handling_spec.rb |
httpkit-0.6.0.pre.5 | spec/integration/error_handling_spec.rb |
httpkit-0.6.0.pre.3 | spec/integration/error_handling_spec.rb |