tengine_event 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
+
4
+ require 'amqp'
5
+
6
+ config_filepath = File.expand_path("../../mq_config.yml", File.dirname(__FILE__))
7
+
8
+ if File.exist?(config_filepath) && (ENV['TENGINE_EVENT_MQ_TEST'] =~ /true|on/i)
9
+ describe "Tengine::Mq::Suite" do
10
+ before do
11
+ # キューをsubscribeすることで、キューを作ります
12
+ @config = YAML.load_file(config_filepath)
13
+ EM.run do
14
+ @mq_suite = Tengine::Mq::Suite.new(@config)
15
+ @mq_suite.queue.subscribe do |metadata, msg|
16
+ # 何もしません
17
+ end
18
+ EM.add_timer(1) do
19
+ @mq_suite.connection.close{ EM.stop_event_loop }
20
+ end
21
+ end
22
+ end
23
+
24
+ it "EM.run{...} を複数回実行できる" do
25
+ EM.run{
26
+ @mq_suite.exchange.publish("foo"){
27
+ @mq_suite.connection.close{ EM.stop_event_loop }
28
+ }
29
+ }
30
+ EM.run{
31
+ @mq_suite.exchange.publish("foo"){
32
+ @mq_suite.connection.close{ EM.stop_event_loop }
33
+ }
34
+ }
35
+ end
36
+
37
+ end
38
+ end