resque-bus 0.3.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile +2 -3
  6. data/README.mdown +50 -64
  7. data/Rakefile +0 -1
  8. data/lib/resque-bus.rb +21 -283
  9. data/lib/resque_bus/adapter.rb +66 -0
  10. data/lib/resque_bus/compatibility/deprecated.rb +38 -0
  11. data/lib/resque_bus/compatibility/driver.rb +10 -0
  12. data/lib/resque_bus/compatibility/heartbeat.rb +10 -0
  13. data/lib/resque_bus/compatibility/publisher.rb +13 -0
  14. data/lib/resque_bus/compatibility/rider.rb +32 -0
  15. data/lib/resque_bus/compatibility/subscriber.rb +8 -0
  16. data/lib/resque_bus/compatibility/task_manager.rb +8 -0
  17. data/lib/resque_bus/server.rb +6 -5
  18. data/lib/resque_bus/server/views/bus.erb +2 -2
  19. data/lib/resque_bus/tasks.rb +46 -46
  20. data/lib/resque_bus/version.rb +2 -4
  21. data/resque-bus.gemspec +5 -12
  22. data/spec/adapter/compatibility_spec.rb +97 -0
  23. data/spec/adapter/integration_spec.rb +111 -0
  24. data/spec/adapter/publish_at_spec.rb +50 -0
  25. data/spec/adapter/retry_spec.rb +47 -0
  26. data/spec/adapter/support.rb +23 -0
  27. data/spec/adapter_spec.rb +14 -0
  28. data/spec/application_spec.rb +62 -62
  29. data/spec/config_spec.rb +83 -0
  30. data/spec/dispatch_spec.rb +6 -6
  31. data/spec/driver_spec.rb +62 -53
  32. data/spec/heartbeat_spec.rb +4 -4
  33. data/spec/integration_spec.rb +2 -2
  34. data/spec/matcher_spec.rb +29 -29
  35. data/spec/publish_spec.rb +62 -38
  36. data/spec/publisher_spec.rb +7 -0
  37. data/spec/rider_spec.rb +14 -66
  38. data/spec/spec_helper.rb +25 -28
  39. data/spec/subscriber_spec.rb +194 -176
  40. data/spec/subscription_list_spec.rb +1 -1
  41. data/spec/subscription_spec.rb +1 -1
  42. data/spec/worker_spec.rb +32 -0
  43. metadata +75 -91
  44. data/lib/resque_bus/application.rb +0 -115
  45. data/lib/resque_bus/dispatch.rb +0 -61
  46. data/lib/resque_bus/driver.rb +0 -30
  47. data/lib/resque_bus/heartbeat.rb +0 -106
  48. data/lib/resque_bus/local.rb +0 -34
  49. data/lib/resque_bus/matcher.rb +0 -81
  50. data/lib/resque_bus/publisher.rb +0 -12
  51. data/lib/resque_bus/rider.rb +0 -54
  52. data/lib/resque_bus/subscriber.rb +0 -63
  53. data/lib/resque_bus/subscription.rb +0 -55
  54. data/lib/resque_bus/subscription_list.rb +0 -53
  55. data/lib/resque_bus/task_manager.rb +0 -52
  56. data/lib/resque_bus/util.rb +0 -42
  57. data/lib/tasks/resquebus.rake +0 -2
  58. data/spec/publish_at_spec.rb +0 -74
  59. data/spec/redis_spec.rb +0 -13
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Resque Integration" do
4
+ describe "Happy Path" do
5
+ before(:each) do
6
+ QueueBus.dispatch("r1") do
7
+ subscribe "event_name" do |attributes|
8
+ QueueBus::Runner1.run(attributes)
9
+ end
10
+ end
11
+
12
+ QueueBus::TaskManager.new(false).subscribe!
13
+
14
+ @incoming = Resque::Worker.new(:bus_incoming)
15
+ @incoming.register_worker
16
+
17
+ @rider = Resque::Worker.new(:r1_default)
18
+ @rider.register_worker
19
+ end
20
+
21
+ it "should publish and receive" do
22
+ QueueBus::Runner1.value.should == 0
23
+
24
+ QueueBus.publish("event_name", "ok" => true)
25
+ QueueBus::Runner1.value.should == 0
26
+
27
+ perform_next_job @incoming
28
+
29
+ QueueBus::Runner1.value.should == 0
30
+
31
+ perform_next_job @rider
32
+
33
+ QueueBus::Runner1.value.should == 1
34
+ end
35
+ end
36
+
37
+ describe "Delayed Publishing" do
38
+ before(:each) do
39
+ Timecop.freeze(now)
40
+ QueueBus.stub(:generate_uuid).and_return("idfhlkj")
41
+ end
42
+ after(:each) do
43
+ Timecop.return
44
+ end
45
+ let(:delayed_attrs) { {"bus_delayed_until" => future.to_i,
46
+ "bus_id" => "#{now.to_i}-idfhlkj",
47
+ "bus_app_hostname" => `hostname 2>&1`.strip.sub(/.local/,'')} }
48
+
49
+ let(:bus_attrs) { delayed_attrs.merge({"bus_published_at" => worktime.to_i})}
50
+ let(:now) { Time.parse("01/01/2013 5:00")}
51
+ let(:future) { Time.at(now.to_i + 60) }
52
+ let(:worktime) {Time.at(future.to_i + 1)}
53
+
54
+ it "should add it to Redis" do
55
+ hash = {:one => 1, "two" => "here", "id" => 12 }
56
+ event_name = "event_name"
57
+ QueueBus.publish_at(future, event_name, hash)
58
+
59
+ schedule = QueueBus.redis { |redis| redis.zrange("delayed_queue_schedule", 0, 1) }
60
+ schedule.should == [future.to_i.to_s]
61
+
62
+ val = QueueBus.redis { |redis| redis.lpop("delayed:#{future.to_i}") }
63
+ hash = JSON.parse(val)
64
+
65
+ hash["class"].should == "QueueBus::Worker"
66
+ hash["args"].size.should == 1
67
+ JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(delayed_attrs)
68
+ hash["queue"].should == "bus_incoming"
69
+ end
70
+
71
+ it "should move it to the real queue when processing" do
72
+ hash = {:one => 1, "two" => "here", "id" => 12 }
73
+ event_name = "event_name"
74
+
75
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
76
+ val.should == nil
77
+
78
+ QueueBus.publish_at(future, event_name, hash)
79
+
80
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
81
+ val.should == nil # nothing really added
82
+
83
+ # process sceduler now
84
+ Resque::Scheduler.handle_delayed_items
85
+
86
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
87
+ val.should == nil # nothing added yet
88
+
89
+ # process scheduler in future
90
+ Timecop.freeze(worktime) do
91
+ Resque::Scheduler.handle_delayed_items
92
+
93
+ # added
94
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
95
+ hash = JSON.parse(val)
96
+ hash["class"].should == "QueueBus::Worker"
97
+ hash["args"].size.should == 1
98
+ JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(delayed_attrs)
99
+
100
+ QueueBus::Publisher.perform(JSON.parse(hash["args"].first))
101
+
102
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
103
+ hash = JSON.parse(val)
104
+ hash["class"].should == "QueueBus::Worker"
105
+ hash["args"].size.should == 1
106
+ JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Driver", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(bus_attrs)
107
+ end
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Publishing an event in the future" do
4
+
5
+ before(:each) do
6
+ Timecop.freeze(now)
7
+ QueueBus.stub(:generate_uuid).and_return("idfhlkj")
8
+ end
9
+ after(:each) do
10
+ Timecop.return
11
+ end
12
+ let(:delayed_attrs) { {"bus_delayed_until" => future.to_i,
13
+ "bus_id" => "#{now.to_i}-idfhlkj",
14
+ "bus_app_hostname" => `hostname 2>&1`.strip.sub(/.local/,'')} }
15
+
16
+ let(:bus_attrs) { delayed_attrs.merge({"bus_published_at" => worktime.to_i})}
17
+ let(:now) { Time.parse("01/01/2013 5:00")}
18
+ let(:future) { Time.at(now.to_i + 60) }
19
+ let(:worktime) {Time.at(future.to_i + 1)}
20
+
21
+ it "should add it to Redis then to the real queue" do
22
+ hash = {:one => 1, "two" => "here", "id" => 12 }
23
+ event_name = "event_name"
24
+ QueueBus.publish_at(future, event_name, hash)
25
+
26
+ schedule = QueueBus.redis { |redis| redis.zrange("delayed_queue_schedule", 0, 1) }
27
+ schedule.should == [future.to_i.to_s]
28
+
29
+ val = QueueBus.redis { |redis| redis.lpop("delayed:#{future.to_i}") }
30
+ hash = JSON.parse(val)
31
+
32
+ hash["class"].should == "QueueBus::Worker"
33
+ hash["args"].size.should == 1
34
+ JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(delayed_attrs)
35
+ hash["queue"].should == "bus_incoming"
36
+
37
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
38
+ val.should == nil # nothing really added
39
+
40
+ Timecop.freeze(worktime)
41
+ QueueBus::Publisher.perform(JSON.parse(hash["args"].first))
42
+
43
+ val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
44
+ hash = JSON.parse(val)
45
+ hash["class"].should == "QueueBus::Worker"
46
+ hash["args"].size.should == 1
47
+ JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Driver", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(bus_attrs)
48
+ end
49
+
50
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Retry" do
4
+ class RetryTest1
5
+ include QueueBus::Subscriber
6
+ application :my_thing
7
+ subscribe :event_sub
8
+ def event_sub(attributes)
9
+ QueueBus::Runner1.run(attributes)
10
+ end
11
+ end
12
+
13
+ it "should have the methods" do
14
+ ::QueueBus::Worker.methods.should include(:on_failure_aaa)
15
+ ::QueueBus::Worker.methods.should include(:on_failure_zzz)
16
+ end
17
+
18
+ # it "should retry failed riders"
19
+
20
+ describe "Failed Jobs" do
21
+ before(:each) do
22
+ QueueBus.enqueue_to("testing", "QueueBus::Worker", { "bus_class_proxy" => "QueueBus::Rider", "bus_rider_app_key" => "r2", "bus_rider_sub_key" => "event_name", "bus_event_type" => "event_name", "ok" => true, "bus_rider_queue" => "testing" })
23
+
24
+ @worker = Resque::Worker.new(:testing)
25
+ @worker.register_worker
26
+ end
27
+
28
+ it "should put it in the failed jobs" do
29
+
30
+ QueueBus.dispatch("r2") do
31
+ subscribe "event_name" do |attributes|
32
+ raise "boo!"
33
+ end
34
+ end
35
+
36
+ perform_next_job @worker
37
+ Resque.info[:processed].should == 1
38
+ Resque.info[:failed].should == 1
39
+ Resque.info[:pending].should == 1 # requeued
40
+
41
+ perform_next_job @worker
42
+ Resque.info[:processed].should == 2
43
+ Resque.info[:failed].should == 2
44
+ Resque.info[:pending].should == 0
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ require 'resque-bus'
2
+ require 'resque'
3
+ require 'resque/scheduler'
4
+
5
+ def reset_test_adapter
6
+ QueueBus.send(:reset)
7
+ QueueBus.adapter = QueueBus::Adapters::Resque.new
8
+ end
9
+
10
+ def adapter_under_test_class
11
+ QueueBus::Adapters::Resque
12
+ end
13
+
14
+ def adapter_under_test_symbol
15
+ :resque
16
+ end
17
+
18
+ def perform_next_job(worker, &block)
19
+ return unless job = worker.reserve
20
+ worker.perform(job, &block)
21
+ worker.done_working
22
+ end
23
+
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "adapter is set" do
4
+ it "should call it's enabled! method on init" do
5
+ QueueBus.send(:reset)
6
+ adapter_under_test_class.any_instance.should_receive(:enabled!)
7
+ instance = adapter_under_test_class.new
8
+ QueueBus.send(:reset)
9
+ end
10
+
11
+ it "should be defaulting to Data from spec_helper" do
12
+ QueueBus.adapter.is_a?(adapter_under_test_class).should == true
13
+ end
14
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module ResqueBus
3
+ module QueueBus
4
4
  describe Application do
5
5
  describe ".all" do
6
6
  it "should return empty array when none" do
@@ -10,143 +10,143 @@ module ResqueBus
10
10
  Application.new("One").subscribe(test_list(test_sub("fdksjh")))
11
11
  Application.new("Two").subscribe(test_list(test_sub("fdklhf")))
12
12
  Application.new("Three").subscribe(test_list(test_sub("fkld")))
13
-
13
+
14
14
  Application.all.collect(&:app_key).should =~ ["one", "two", "three"]
15
-
15
+
16
16
  Application.new("two").unsubscribe
17
17
  Application.all.collect(&:app_key).should =~ ["one", "three"]
18
18
  end
19
19
  end
20
-
20
+
21
21
  describe ".new" do
22
22
  it "should have a key" do
23
23
  Application.new("something").app_key.should == "something"
24
-
24
+
25
25
  Application.new("some thing").app_key.should == "some_thing"
26
26
  Application.new("some-thing").app_key.should == "some_thing"
27
27
  Application.new("some_thing").app_key.should == "some_thing"
28
28
  Application.new("Some Thing").app_key.should == "some_thing"
29
29
  end
30
-
30
+
31
31
  it "should raise an error if not valid" do
32
32
  lambda {
33
33
  Application.new("")
34
34
  }.should raise_error
35
-
35
+
36
36
  lambda {
37
37
  Application.new(nil)
38
38
  }.should raise_error
39
-
39
+
40
40
  lambda {
41
41
  Application.new("/")
42
42
  }.should raise_error
43
43
  end
44
44
  end
45
-
45
+
46
46
  describe "#read_redis_hash" do
47
47
  it "should handle old and new values" do
48
-
49
- ResqueBus.redis.hset("resquebus_app:myapp", "new_one", Resque.encode("queue_name" => "x", "bus_event_type" => "event_name"))
50
- ResqueBus.redis.hset("resquebus_app:myapp", "old_one", "oldqueue_name")
48
+
49
+ QueueBus.redis { |redis| redis.hset("bus_app:myapp", "new_one", QueueBus::Util.encode("queue_name" => "x", "bus_event_type" => "event_name") ) }
50
+ QueueBus.redis { |redis| redis.hset("bus_app:myapp", "old_one", "oldqueue_name") }
51
51
  app = Application.new("myapp")
52
52
  val = app.send(:read_redis_hash)
53
53
  val.should == {"new_one" => {"queue_name" => "x", "bus_event_type" => "event_name"}, "old_one" => "oldqueue_name"}
54
54
  end
55
55
  end
56
-
56
+
57
57
  describe "#subscribe" do
58
58
  let(:sub1) { test_sub("event_one", "default") }
59
59
  let(:sub2) { test_sub("event_two", "default") }
60
60
  let(:sub3) { test_sub("event_three", "other") }
61
61
  it "should add array to redis" do
62
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
62
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
63
63
  Application.new("myapp").subscribe(test_list(sub1, sub2))
64
-
65
- ResqueBus.redis.hgetall("resquebus_app:myapp").should == {"event_two"=>"{\"queue_name\":\"default\",\"key\":\"event_two\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_two\"}}",
66
- "event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}"}
67
- ResqueBus.redis.hkeys("resquebus_app:myapp").should =~ ["event_one", "event_two"]
68
- ResqueBus.redis.smembers("resquebus_apps").should =~ ["myapp"]
64
+
65
+ QueueBus.redis { |redis| redis.hgetall("bus_app:myapp") }.should == {"event_two"=>"{\"queue_name\":\"default\",\"key\":\"event_two\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_two\"}}",
66
+ "event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}"}
67
+ QueueBus.redis { |redis| redis.hkeys("bus_app:myapp") }.should =~ ["event_one", "event_two"]
68
+ QueueBus.redis { |redis| redis.smembers("bus_apps") }.should =~ ["myapp"]
69
69
  end
70
70
  it "should add string to redis" do
71
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
71
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
72
72
  Application.new("myapp").subscribe(test_list(sub1))
73
-
74
- ResqueBus.redis.hgetall("resquebus_app:myapp").should == {"event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}"}
75
- ResqueBus.redis.hkeys("resquebus_app:myapp").should =~ ["event_one"]
76
- ResqueBus.redis.smembers("resquebus_apps").should =~ ["myapp"]
73
+
74
+ QueueBus.redis { |redis| redis.hgetall("bus_app:myapp") }.should == {"event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}"}
75
+ QueueBus.redis { |redis| redis.hkeys("bus_app:myapp") }.should =~ ["event_one"]
76
+ QueueBus.redis { |redis| redis.smembers("bus_apps") }.should =~ ["myapp"]
77
77
  end
78
78
  it "should multiple queues to redis" do
79
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
79
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
80
80
  Application.new("myapp").subscribe(test_list(sub1, sub2, sub3))
81
- ResqueBus.redis.hgetall("resquebus_app:myapp").should == {"event_two"=>"{\"queue_name\":\"default\",\"key\":\"event_two\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_two\"}}", "event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}",
82
- "event_three"=>"{\"queue_name\":\"other\",\"key\":\"event_three\",\"class\":\"::ResqueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_three\"}}"}
83
- ResqueBus.redis.hkeys("resquebus_app:myapp").should =~ ["event_three", "event_two", "event_one"]
84
- ResqueBus.redis.smembers("resquebus_apps").should =~ ["myapp"]
81
+ QueueBus.redis { |redis| redis.hgetall("bus_app:myapp") }.should == {"event_two"=>"{\"queue_name\":\"default\",\"key\":\"event_two\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_two\"}}", "event_one"=>"{\"queue_name\":\"default\",\"key\":\"event_one\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_one\"}}",
82
+ "event_three"=>"{\"queue_name\":\"other\",\"key\":\"event_three\",\"class\":\"::QueueBus::Rider\",\"matcher\":{\"bus_event_type\":\"event_three\"}}"}
83
+ QueueBus.redis { |redis| redis.hkeys("bus_app:myapp") }.should =~ ["event_three", "event_two", "event_one"]
84
+ QueueBus.redis { |redis| redis.smembers("bus_apps") }.should =~ ["myapp"]
85
85
  end
86
-
86
+
87
87
  it "should do nothing if nil or empty" do
88
-
89
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
90
-
88
+
89
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
90
+
91
91
  Application.new("myapp").subscribe(nil)
92
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
93
-
92
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
93
+
94
94
  Application.new("myapp").subscribe([])
95
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
95
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
96
96
  end
97
-
97
+
98
98
  it "should call unsubscribe" do
99
99
  app = Application.new("myapp")
100
100
  app.should_receive(:unsubscribe)
101
101
  app.subscribe([])
102
102
  end
103
103
  end
104
-
104
+
105
105
  describe "#unsubscribe" do
106
106
  it "should remove items" do
107
- ResqueBus.redis.sadd("resquebus_apps", "myapp")
108
- ResqueBus.redis.sadd("resquebus_apps", "other")
109
- ResqueBus.redis.hset("resquebus_app:myapp", "event_one", "myapp_default")
110
-
107
+ QueueBus.redis { |redis| redis.sadd("bus_apps", "myapp") }
108
+ QueueBus.redis { |redis| redis.sadd("bus_apps", "other") }
109
+ QueueBus.redis { |redis| redis.hset("bus_app:myapp", "event_one", "myapp_default") }
110
+
111
111
  Application.new("myapp").unsubscribe
112
-
113
- ResqueBus.redis.smembers("resquebus_apps").should == ["other"]
114
- ResqueBus.redis.get("resquebus_app:myapp").should be_nil
112
+
113
+ QueueBus.redis { |redis| redis.smembers("bus_apps") }.should == ["other"]
114
+ QueueBus.redis { |redis| redis.get("bus_app:myapp") }.should be_nil
115
115
  end
116
116
  end
117
-
117
+
118
118
  describe "#subscription_matches" do
119
119
  it "should return if it is there" do
120
120
  Application.new("myapp").subscription_matches("bus_event_type"=>"three").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
121
-
121
+
122
122
  subs = test_list(test_sub("one_x"), test_sub("one_y"), test_sub("one"), test_sub("two"))
123
123
  Application.new("myapp").subscribe(subs)
124
124
  Application.new("myapp").subscription_matches("bus_event_type"=>"three").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
125
-
126
- Application.new("myapp").subscription_matches("bus_event_type"=>"two").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "two", "default", "::ResqueBus::Rider"]]
127
- Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one", "default", "::ResqueBus::Rider"]]
125
+
126
+ Application.new("myapp").subscription_matches("bus_event_type"=>"two").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "two", "default", "::QueueBus::Rider"]]
127
+ Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one", "default", "::QueueBus::Rider"]]
128
128
  end
129
-
129
+
130
130
  it "should handle * wildcards" do
131
131
  subs = test_list(test_sub("one.+"), test_sub("one"), test_sub("one_.*"), test_sub("two"))
132
132
  Application.new("myapp").subscribe(subs)
133
133
  Application.new("myapp").subscription_matches("bus_event_type"=>"three").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
134
-
135
- Application.new("myapp").subscription_matches("bus_event_type"=>"onex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one.+", "default", "::ResqueBus::Rider"]]
136
- Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one", "default", "::ResqueBus::Rider"]]
137
- Application.new("myapp").subscription_matches("bus_event_type"=>"one_x").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one.+","default", "::ResqueBus::Rider"], ["myapp", "one_.*", "default", "::ResqueBus::Rider"]]
134
+
135
+ Application.new("myapp").subscription_matches("bus_event_type"=>"onex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one.+", "default", "::QueueBus::Rider"]]
136
+ Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one", "default", "::QueueBus::Rider"]]
137
+ Application.new("myapp").subscription_matches("bus_event_type"=>"one_x").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one.+","default", "::QueueBus::Rider"], ["myapp", "one_.*", "default", "::QueueBus::Rider"]]
138
138
  end
139
-
139
+
140
140
  it "should handle actual regular expressions" do
141
141
  subs = test_list(test_sub(/one.+/), test_sub("one"), test_sub(/one_.*/), test_sub("two"))
142
142
  Application.new("myapp").subscribe(subs)
143
143
  Application.new("myapp").subscription_matches("bus_event_type"=>"three").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
144
-
145
- Application.new("myapp").subscription_matches("bus_event_type"=>"onex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::ResqueBus::Rider"]]
146
- Application.new("myapp").subscription_matches("bus_event_type"=>"donex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::ResqueBus::Rider"]]
147
- Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one" ,"default", "::ResqueBus::Rider"]]
148
- Application.new("myapp").subscription_matches("bus_event_type"=>"one_x").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::ResqueBus::Rider"], ["myapp", "(?-mix:one_.*)", "default", "::ResqueBus::Rider"]]
144
+
145
+ Application.new("myapp").subscription_matches("bus_event_type"=>"onex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::QueueBus::Rider"]]
146
+ Application.new("myapp").subscription_matches("bus_event_type"=>"donex").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::QueueBus::Rider"]]
147
+ Application.new("myapp").subscription_matches("bus_event_type"=>"one").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "one" ,"default", "::QueueBus::Rider"]]
148
+ Application.new("myapp").subscription_matches("bus_event_type"=>"one_x").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["myapp", "(?-mix:one.+)", "default", "::QueueBus::Rider"], ["myapp", "(?-mix:one_.*)", "default", "::QueueBus::Rider"]]
149
149
  end
150
150
  end
151
151
  end
152
- end
152
+ end