Sha256: 97ce24f17cd02b4ef729a15bbe4145aa2e328aaf0b6987f692423190c5f2e113

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/shared_manager_behavior'

module RosettaQueue

  describe EventedManager do

    before(:each) do
      Stomp::Connection.stub!(:open).and_return(nil)
      @consumer = mock("test_consumer_1", :receive => true, 
                                          :connection => mock("AmqpAdapter", :subscribe => true, :unsubscribe => nil, :disconnect => nil),
                                          :unsubscribe => true, :disconnect => true)
      Consumer.stub!(:new).and_return(@consumer)
      @manager = EventedManager.new
      @manager.add(@message_handler = mock("message_handler", :destination => "/queue/foo", :option_hash => {}))
    end

    it_should_behave_like "a consumer manager"

    describe "running" do

      before(:each) do
        EM.stub!(:run).and_yield
      end

      describe "starting" do
        
        def do_process
          @manager.start
        end

        it "should start consumers" do
          during_process {
            @manager.consumers.each_value { |cons| cons.should_receive(:receive) }
          }
        end
        
      end

      describe "stopping" do

        def do_process
          @manager.stop
        end
        
        it "should stop consumers" do
          during_process {
            EM.should_receive(:stop)
          }
        end
        
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
bmabey-rosetta_queue-0.1.3 spec/rosetta_queue/consumer_managers/evented_spec.rb
bmabey-rosetta_queue-0.2.0 spec/rosetta_queue/consumer_managers/evented_spec.rb
cwyckoff-rosetta_queue-0.3.3 spec/rosetta_queue/consumer_managers/evented_spec.rb