Sha256: dde35be7be54f11f4acc6f025737921b797a16fd33298fab5e7cf4dcc26335e0

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require 'spec_helper'

describe Freddy::SyncResponseContainer do
  let(:container) { described_class.new }

  before do
    container.on_timeout {}
  end

  context 'when timeout' do
    subject { container.wait_for_response(0.01) }

    it 'raises timeout error' do
      expect { subject }.to raise_error do |error|
        expect(error).to be_a(Freddy::TimeoutError)
        expect(error.response).to eq(
          error: 'RequestTimeout',
          message: 'Timed out waiting for response'
        )
      end
    end
  end

  context 'when nil resonse' do
    let(:delivery) { {} }

    before do
      Thread.new do
        default_sleep
        container.call(nil, delivery)
      end
    end

    it 'raises timeout error' do
      expect {
        container.wait_for_response(2)
      }.to raise_error(StandardError, 'unexpected nil value for response')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
freddy-0.5.3 spec/freddy/sync_response_container_spec.rb