Sha256: 15664a5489de4a8521b9eb13b86bcae364faaba8c1ec167a4a450f0b0ba7fbe2

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Freddy::ResponderHandler do
  let(:freddy) { Freddy.build(logger, config) }

  let(:destination) { random_destination }
  let(:payload)     { { pay: 'load' } }

  after { freddy.close }

  describe '#shutdown' do
    it 'lets ongoing workers to finish' do
      count = 0

      consumer_handler = freddy.respond_to destination do
        sleep 0.3
        count += 1
      end
      deliver

      sleep 0.15
      consumer_handler.shutdown

      expect(count).to eq(1)
    end

    it 'does not accept new jobs' do
      count = 0

      consumer_handler = freddy.respond_to destination do
        count += 1
      end

      consumer_handler.shutdown
      deliver

      expect(count).to eq(0)
    end

    it 'does not touch other handlers' do
      count = 0

      freddy.respond_to destination do
        count += 1
      end

      consumer_handler2 = freddy.respond_to random_destination do
        count += 1
      end
      consumer_handler2.shutdown

      deliver
      expect(count).to eq(1)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
freddy-2.5.1 spec/freddy/responder_handler_spec.rb
freddy-2.5.0 spec/freddy/responder_handler_spec.rb
freddy-2.5.0.pre.rc.1 spec/freddy/responder_handler_spec.rb
freddy-2.4.0 spec/freddy/responder_handler_spec.rb
freddy-2.3.0 spec/freddy/responder_handler_spec.rb
freddy-2.2.4 spec/freddy/responder_handler_spec.rb
freddy-2.2.3 spec/freddy/responder_handler_spec.rb
freddy-2.2.2 spec/freddy/responder_handler_spec.rb
freddy-2.2.1 spec/freddy/responder_handler_spec.rb
freddy-2.2.0 spec/freddy/responder_handler_spec.rb
freddy-2.1.0 spec/freddy/responder_handler_spec.rb
freddy-2.0.0 spec/freddy/responder_handler_spec.rb
freddy-1.7.0 spec/freddy/responder_handler_spec.rb
freddy-1.6.0 spec/freddy/responder_handler_spec.rb
freddy-1.5.0 spec/freddy/responder_handler_spec.rb
freddy-1.4.2 spec/freddy/responder_handler_spec.rb