Sha256: b34cb2c309a9afd12789f7497f95eb00d525402bc0e32c87b5e4dc3ed6d214dc

Contents?: true

Size: 1.03 KB

Versions: 15

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

15 entries across 15 versions & 2 rubygems

Version Path
freddy-1.4.1 spec/freddy/responder_handler_spec.rb
freddy-1.4.0 spec/freddy/responder_handler_spec.rb
freddy-1.3.3 spec/freddy/responder_handler_spec.rb
freddy-jruby-1.3.2 spec/freddy/responder_handler_spec.rb
freddy-1.3.2 spec/freddy/responder_handler_spec.rb
freddy-1.3.1 spec/freddy/responder_handler_spec.rb
freddy-1.3.0 spec/freddy/responder_handler_spec.rb
freddy-1.2.0 spec/freddy/responder_handler_spec.rb
freddy-1.1.0 spec/freddy/responder_handler_spec.rb
freddy-1.0.1 spec/freddy/responder_handler_spec.rb
freddy-jruby-1.0.0 spec/freddy/responder_handler_spec.rb
freddy-1.0.0 spec/freddy/responder_handler_spec.rb
freddy-jruby-0.7.2 spec/freddy/responder_handler_spec.rb
freddy-0.7.2 spec/freddy/responder_handler_spec.rb
freddy-0.7.1 spec/freddy/responder_handler_spec.rb