Sha256: 0c2bbf716a7f95f6a5b0d429b6f2e7cb0664fc8d7a44d17e2b196798c11ef004

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require 'unit_spec_helper'

describe Rpush::Daemon::DispatcherLoopCollection do
  let(:dispatcher_loop) { double.as_null_object }
  let(:collection) { Rpush::Daemon::DispatcherLoopCollection.new }

  it 'returns the size of the collection' do
    collection.push(dispatcher_loop)
    collection.size.should eq 1
  end

  it 'pops a dispatcher loop from the collection' do
    collection.push(dispatcher_loop)
    dispatcher_loop.should_receive(:stop)
    dispatcher_loop.should_receive(:wakeup)
    dispatcher_loop.should_receive(:wait)
    collection.pop
    collection.size.should eq 0
  end

  it 'wakes up all dispatcher loops when popping a single dispatcher_loop' do
    collection.push(dispatcher_loop)
    dispatcher_loop2 = double.as_null_object
    collection.push(dispatcher_loop2)
    dispatcher_loop.should_receive(:wakeup)
    dispatcher_loop2.should_receive(:wakeup)
    collection.pop
  end

  it 'stops all dispatcher  detetcloops' do
    collection.push(dispatcher_loop)
    dispatcher_loop.should_receive(:stop)
    dispatcher_loop.should_receive(:wakeup)
    dispatcher_loop.should_receive(:wait)
    collection.stop
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rpush-2.0.0.beta1 spec/unit/daemon/dispatcher_loop_collection_spec.rb
rpush-1.0.0-java spec/unit/daemon/dispatcher_loop_collection_spec.rb
rpush-1.0.0 spec/unit/daemon/dispatcher_loop_collection_spec.rb