Sha256: c0c5fd236e729cf9ae783efadd4be1c2cb52f92d1b09693ed5494c1ae765cc12
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' module RosettaQueue class TestProducer < Producer publishes_to :test_queue options :persistent => false end describe Producer do before(:each) do @adapter = mock("adapter", :send_message => nil, :disconnect => nil) RosettaQueue::Adapter.stub!(:open).and_yield(@adapter) @gateway = TestProducer.new Destinations.stub!(:lookup).and_return("/queue/test_queue") end attr_reader :adapter, :gateway describe ".publish" do it "should send the message to the adapter along with the options" do # expect @adapter.should_receive(:send_message).with("/queue/test_queue", "Hello World!", {:persistent => true}) # when Producer.publish(:test_queue, "Hello World!", {:persistent => true}) end it "delegates exception handling to the ExceptionHandler for :publishing" do ExceptionHandler.should_receive(:handle).with(:publishing, anything) Producer.publish(:test_queue, "Hello World!", {:persistent => true}) end it "wraps the publishing in an ExceptionHandler::handler block" do @adapter.should_not_receive(:send_message) ExceptionHandler.stub!(:handle).and_return("I was wrapped") Producer.publish(:test_queue, "m").should == "I was wrapped" end it "provides additional message information to the ExceptionHandler" do ExceptionHandler.should_receive(:handle).with do |_, hash_proc| hash_proc.call.should == { :message => "message", :action => :publishing, :destination => :test_queue, :options => {:persistent => true}} end Producer.publish(:test_queue, "message", {:persistent => true}) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rosetta_queue-0.5.2 | spec/rosetta_queue/producer_spec.rb |
rosetta_queue-0.5.0 | spec/rosetta_queue/producer_spec.rb |