spec/sneakers/queue_spec.rb in sneakers-0.0.7 vs spec/sneakers/queue_spec.rb in sneakers-0.1.0.pre
- old
+ new
@@ -7,34 +7,52 @@
before do
Sneakers.configure(:env => 'test')
end
describe "#subscribe" do
- it "should setup a bunny queue according to configuration values" do
- q = Sneakers::Queue.new("downloads",
+ let :queue_vars do
+ {
:prefetch => 25,
:durable => true,
:ack => true,
:heartbeat => 2,
:vhost => '/',
:exchange => "sneakers",
:exchange_type => :direct
- )
- mkbunny = Object.new
- mkchan = Object.new
- mkex = Object.new
- mkqueue = Object.new
+ }
+ end
- mock(mkbunny).start {}
- mock(mkbunny).create_channel{ mkchan }
- mock(Bunny).new(anything, :vhost => '/', :heartbeat => 2){ mkbunny }
+ before do
+ @mkbunny = Object.new
+ @mkchan = Object.new
+ @mkex = Object.new
+ @mkqueue = Object.new
- mock(mkchan).prefetch(25)
- mock(mkchan).exchange("sneakers", :type => :direct, :durable => true){ mkex }
- mock(mkchan).queue("downloads", :durable => true){ mkqueue }
+ mock(@mkbunny).start {}
+ mock(@mkbunny).create_channel{ @mkchan }
+ mock(Bunny).new(anything, :vhost => '/', :heartbeat => 2){ @mkbunny }
- mock(mkqueue).bind(mkex, :routing_key => "downloads")
- mock(mkqueue).subscribe(:block => false, :ack => true)
+ mock(@mkchan).prefetch(25)
+ mock(@mkchan).exchange("sneakers", :type => :direct, :durable => true){ @mkex }
+ mock(@mkchan).queue("downloads", :durable => true){ @mkqueue }
+ end
+
+ it "should setup a bunny queue according to configuration values" do
+ q = Sneakers::Queue.new("downloads", queue_vars)
+
+ mock(@mkqueue).bind(@mkex, :routing_key => "downloads")
+ mock(@mkqueue).subscribe(:block => false, :ack => true)
+
+ q.subscribe(Object.new)
+ end
+
+ it "supports multiple routing_keys" do
+ q = Sneakers::Queue.new("downloads",
+ queue_vars.merge(:routing_key => ["alpha", "beta"]))
+
+ mock(@mkqueue).bind(@mkex, :routing_key => "alpha")
+ mock(@mkqueue).bind(@mkex, :routing_key => "beta")
+ mock(@mkqueue).subscribe(:block => false, :ack => true)
q.subscribe(Object.new)
end
end