Sha256: ca9d7d444529c34295c827b14ca2e1a09dbdf47c6cc58c8167258a93eb13e892

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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

module RosettaQueue
  describe BaseManager do
    
    describe "#add" do
      it "allows adding a handler" do
        BaseManager.new.add(Object.new)
      end
      
      it "wraps the handler with a consumer and stores it" do
        handler = Object.new
        Consumer.should_receive(:new).with(handler)
        BaseManager.new.add(handler)
      end
      
      describe "storing the consumer" do
        it "uses the class name as the key by default" do
          handler = Object.new
          manager = BaseManager.new
          manager.add(handler)
          manager.consumers.keys.should == [:object]
        end
        
        it "allows overriding the key name for cases where you have multiple instances of the same handler class" do
          handler = Object.new
          manager = BaseManager.new
          manager.add(handler, :object_1)
          manager.add(handler, :object_2)
          manager.consumers.keys.should =~ [:object_1, :object_2]
        end
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rosetta_queue-0.5.2 spec/rosetta_queue/consumer_managers/base_spec.rb
rosetta_queue-0.5.0 spec/rosetta_queue/consumer_managers/base_spec.rb