spec/lolitra_spec.rb in lolitra-0.0.4 vs spec/lolitra_spec.rb in lolitra-0.0.5
- old
+ new
@@ -69,12 +69,17 @@
class TestMessageHandlerAmqp1
include Lolitra::MessageHandler
message_handler TestMessage
+ message_handler TestMessage1
stateful false
+
+ def test_message(message)
+ "handled"
+ end
end
describe Lolitra::MessageHandler,'#create_handler' do
it "returns old instance of the handler for the same message id" do
handler = TestMessageHandler.new
@@ -119,11 +124,11 @@
Lolitra::MessageHandlerManager.bus = bus
Lolitra::MessageHandlerManager.register_subscriber(TestMessageHandler)
TestMessageHandler.should_receive(:handle).with(message)
- TestMessageHandler.publish(message)
+ TestMessageHandler.publish message
end
end
describe Lolitra::MessageHandlerManager, '#publish' do
it "can send message to the bus" do
@@ -204,17 +209,20 @@
end
end
describe Lolitra::AmqpBus do
it "should send all messages to all subscribers in non pull mode" do
+ EM.run
+
Lolitra::MessageHandlerManager.bus = Lolitra::AmqpBus.new(:host => "127.0.0.1", :exchange => "test_exchange")
Lolitra::MessageHandlerManager.register_subscriber(TestMessageHandlerAmqp)
Lolitra::MessageHandlerManager.register_subscriber(TestMessageHandlerAmqp1)
@handled_message_1 = false
@handled_message_2 = false
+
TestMessageHandlerAmqp.should_receive(:handle) do |message|
message.should be_an_instance_of TestMessage
@handled_message_1 = true
EM.stop { exit } if @handled_message_1 && @handled_message_2
end
@@ -232,16 +240,5 @@
EM.next_tick{ EM.add_timer(60) { EM.stop { exit } }}
AMQP::Utilities::EventLoopHelper.eventmachine_thread.join
end
end
-describe Lolitra::Future,"#wait_message" do
- it "should return the message" do
- Lolitra::MessageHandlerManager.bus = Lolitra::AmqpBus.new(:host => "127.0.0.1", :exchange => "test_exchange")
- EM.next_tick{
- Lolitra::MessageHandlerManager.publish(TestMessage.new)
- }
- future = Lolitra::Future.new
- message = future.wait_for(TestMessage)
- message.should be_an_instance_of TestMessage
- end
-end