Sha256: 9a451727794efeaf3f382f5124ac07ee659c48b96428ce98327ef53b6252ebbf

Contents?: true

Size: 1.99 KB

Versions: 18

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe Sidekiq::Queue do
  context 'singleton' do
    shared_examples :constructor do
      it 'with default name' do
        new_object = -> { described_class.send constructor }
        new_object.call.should == new_object.call
      end

      it 'with given name' do
        new_object = ->(name) { described_class.send constructor, name }
        new_object.call('name').should == new_object.call('name')
      end
    end

    context '.new' do
      let(:constructor) { :new }
      it_behaves_like :constructor
    end

    context '.[]' do
      let(:constructor) { :[] }
      it_behaves_like :constructor
    end

    context '#lock' do
      let(:name) { 'example' }
      let(:queue) { Sidekiq::Queue[name] }

      it 'should be available' do
        queue.acquire.should be
      end

      it 'should be pausable' do
        queue.pause
        queue.acquire.should_not be
      end

      it 'should be continuable' do
        queue.pause
        queue.unpause
        queue.acquire.should be
      end

      it 'should be limitable' do
        queue.limit = 1
        queue.acquire.should be
        queue.acquire.should_not be
      end

      it 'should be resizable' do
        queue.limit = 0
        queue.acquire.should_not be
        queue.limit = nil
        queue.acquire.should be
      end

      it 'should be countable' do
        queue.limit = 3
        5.times { queue.acquire }
        queue.probed.should == 3
      end

      it 'should be releasable' do
        queue.acquire
        queue.probed.should == 1
        queue.release
        queue.probed.should == 0
      end

      it 'should tell if paused' do
        queue.should_not be_paused
        queue.pause
        queue.should be_paused
        queue.unpause
        queue.should_not be_paused
      end

      it 'should tell if blocking' do
        queue.should_not be_blocking
        queue.block
        queue.should be_blocking
        queue.unblock
        queue.should_not be_blocking
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sidekiq-limit_fetch-2.4.0 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.3.0 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.7 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.6 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.5 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.4 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.3 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.2 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.1 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.2.0 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.1.3 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.1.2 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.1.1 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.1.0 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.0.2 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.0.1 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-2.0 spec/sidekiq/extensions/queue_spec.rb
sidekiq-limit_fetch-1.7 spec/sidekiq/extensions/queue_spec.rb