sidekiq-bus 0.5.10 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module QueueBus
4
4
  describe Dispatch do
5
5
  it "should not start with any applications" do
6
- Dispatch.new("d").subscriptions.size.should == 0
6
+ expect(Dispatch.new("d").subscriptions.size).to eq(0)
7
7
  end
8
8
 
9
9
  it "should register code to run and execute it" do
@@ -12,16 +12,16 @@ module QueueBus
12
12
  Runner1.run(attrs)
13
13
  end
14
14
  sub = dispatch.subscriptions.key("my_event")
15
- sub.send(:executor).is_a?(Proc).should == true
15
+ expect(sub.send(:executor).is_a?(Proc)).to eq(true)
16
16
 
17
- Runner.value.should == 0
17
+ expect(Runner.value).to eq(0)
18
18
  dispatch.execute("my_event", {"bus_event_type" => "my_event", "ok" => true})
19
- Runner1.value.should == 1
20
- Runner1.attributes.should == {"bus_event_type" => "my_event", "ok" => true}
19
+ expect(Runner1.value).to eq(1)
20
+ expect(Runner1.attributes).to eq({"bus_event_type" => "my_event", "ok" => true})
21
21
  end
22
22
 
23
23
  it "should not crash if not there" do
24
- Dispatch.new("d").execute("fdkjh", "bus_event_type" => "fdkjh").should == nil
24
+ expect(Dispatch.new("d").execute("fdkjh", "bus_event_type" => "fdkjh")).to eq(nil)
25
25
  end
26
26
 
27
27
  describe "Top Level" do
@@ -46,24 +46,24 @@ module QueueBus
46
46
  end
47
47
 
48
48
  it "should register and run" do
49
- Runner2.value.should == 0
49
+ expect(Runner2.value).to eq(0)
50
50
  QueueBus.dispatcher_execute("testit", "event2", "bus_event_type" => "event2")
51
- Runner2.value.should == 1
51
+ expect(Runner2.value).to eq(1)
52
52
  QueueBus.dispatcher_execute("testit", "event1", "bus_event_type" => "event1")
53
- Runner2.value.should == 2
53
+ expect(Runner2.value).to eq(2)
54
54
  QueueBus.dispatcher_execute("testit", "event1", "bus_event_type" => "event1")
55
- Runner2.value.should == 3
55
+ expect(Runner2.value).to eq(3)
56
56
  end
57
57
 
58
58
  it "should return the subscriptions" do
59
59
  dispatcher = QueueBus.dispatcher_by_key("testit")
60
60
  subs = dispatcher.subscriptions.all
61
61
  tuples = subs.collect{ |sub| [sub.key, sub.queue_name]}
62
- tuples.should =~ [ ["event1", "testit_default"],
62
+ expect(tuples).to match_array([ ["event1", "testit_default"],
63
63
  ["event2", "testit_default"],
64
64
  ["event3", "testit_high"],
65
65
  [ "(?-mix:^patt.+ern)", "testit_low"]
66
- ]
66
+ ])
67
67
  end
68
68
 
69
69
  end
data/spec/driver_spec.rb CHANGED
@@ -16,21 +16,21 @@ module QueueBus
16
16
 
17
17
  describe ".subscription_matches" do
18
18
  it "return empty array when none" do
19
- Driver.subscription_matches("bus_event_type" => "else").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
20
- Driver.subscription_matches("bus_event_type" => "event").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should == []
19
+ expect(Driver.subscription_matches("bus_event_type" => "else").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to eq([])
20
+ expect(Driver.subscription_matches("bus_event_type" => "event").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to eq([])
21
21
  end
22
22
  it "should return a match" do
23
- Driver.subscription_matches("bus_event_type" => "event1").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["app1", "event1", "default", "::QueueBus::Rider"]]
24
- Driver.subscription_matches("bus_event_type" => "event6").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["app3", "event6", "default", "::QueueBus::Rider"]]
23
+ expect(Driver.subscription_matches("bus_event_type" => "event1").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to match_array([["app1", "event1", "default", "::QueueBus::Rider"]])
24
+ expect(Driver.subscription_matches("bus_event_type" => "event6").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to match_array([["app3", "event6", "default", "::QueueBus::Rider"]])
25
25
  end
26
26
  it "should match multiple apps" do
27
- Driver.subscription_matches("bus_event_type" => "event2").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["app1", "event2", "default", "::QueueBus::Rider"], ["app2", "event2", "other", "::QueueBus::Rider"]]
27
+ expect(Driver.subscription_matches("bus_event_type" => "event2").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to match_array([["app1", "event2", "default", "::QueueBus::Rider"], ["app2", "event2", "other", "::QueueBus::Rider"]])
28
28
  end
29
29
  it "should match multiple apps with patterns" do
30
- Driver.subscription_matches("bus_event_type" => "event4").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["app3", "event[45]", "default", "::QueueBus::Rider"], ["app2", "event4", "more", "::QueueBus::Rider"]]
30
+ expect(Driver.subscription_matches("bus_event_type" => "event4").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to match_array([["app3", "event[45]", "default", "::QueueBus::Rider"], ["app2", "event4", "more", "::QueueBus::Rider"]])
31
31
  end
32
32
  it "should match multiple events in same app" do
33
- Driver.subscription_matches("bus_event_type" => "event5").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}.should =~ [["app3", "event[45]", "default", "::QueueBus::Rider"], ["app3", "event5", "default", "::QueueBus::Rider"]]
33
+ expect(Driver.subscription_matches("bus_event_type" => "event5").collect{|s| [s.app_key, s.key, s.queue_name, s.class_name]}).to match_array([["app3", "event[45]", "default", "::QueueBus::Rider"], ["app3", "event5", "default", "::QueueBus::Rider"]])
34
34
  end
35
35
  end
36
36
 
@@ -38,48 +38,48 @@ module QueueBus
38
38
  let(:attributes) { {"x" => "y"} }
39
39
 
40
40
  before(:each) do
41
- QueueBus.redis { |redis| redis.smembers("queues") }.should == []
42
- QueueBus.redis { |redis| redis.lpop("queue:app1_default") }.should be_nil
43
- QueueBus.redis { |redis| redis.lpop("queue:app2_default") }.should be_nil
44
- QueueBus.redis { |redis| redis.lpop("queue:app3_default") }.should be_nil
41
+ expect(QueueBus.redis { |redis| redis.smembers("queues") }).to eq([])
42
+ expect(QueueBus.redis { |redis| redis.lpop("queue:app1_default") }).to be_nil
43
+ expect(QueueBus.redis { |redis| redis.lpop("queue:app2_default") }).to be_nil
44
+ expect(QueueBus.redis { |redis| redis.lpop("queue:app3_default") }).to be_nil
45
45
  end
46
46
 
47
47
  it "should do nothing when empty" do
48
48
  Driver.perform(attributes.merge("bus_event_type" => "else"))
49
- QueueBus.redis { |redis| redis.smembers("queues") }.should == []
49
+ expect(QueueBus.redis { |redis| redis.smembers("queues") }).to eq([])
50
50
  end
51
51
 
52
52
  it "should queue up the riders in redis" do
53
- QueueBus.redis { |redis| redis.lpop("queue:app1_default") }.should be_nil
53
+ expect(QueueBus.redis { |redis| redis.lpop("queue:app1_default") }).to be_nil
54
54
  Driver.perform(attributes.merge("bus_event_type" => "event1"))
55
- QueueBus.redis { |redis| redis.smembers("queues") }.should =~ ["default"]
55
+ expect(QueueBus.redis { |redis| redis.smembers("queues") }).to match_array(["default"])
56
56
 
57
57
  hash = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:default") })
58
- hash["class"].should == "QueueBus::Worker"
59
- hash["args"].size.should == 1
60
- JSON.parse(hash["args"].first).should == {"bus_rider_app_key"=>"app1", "x" => "y", "bus_event_type" => "event1", "bus_rider_sub_key"=>"event1", "bus_rider_queue" => "default"}.merge(bus_attrs)
58
+ expect(hash["class"]).to eq("QueueBus::Worker")
59
+ expect(hash["args"].size).to eq(1)
60
+ expect(JSON.parse(hash["args"].first)).to eq({"bus_rider_app_key"=>"app1", "x" => "y", "bus_event_type" => "event1", "bus_rider_sub_key"=>"event1", "bus_rider_queue" => "default"}.merge(bus_attrs))
61
61
  end
62
62
 
63
63
  it "should queue up to multiple" do
64
64
  Driver.perform(attributes.merge("bus_event_type" => "event4"))
65
- QueueBus.redis { |redis| redis.smembers("queues") }.should =~ ["default", "more"]
65
+ expect(QueueBus.redis { |redis| redis.smembers("queues") }).to match_array(["default", "more"])
66
66
 
67
67
  hash = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:more") })
68
- hash["class"].should == "QueueBus::Worker"
69
- hash["args"].size.should == 1
70
- JSON.parse(hash["args"].first).should == {"bus_rider_app_key"=>"app2", "x" => "y", "bus_event_type" => "event4", "bus_rider_sub_key"=>"event4", "bus_rider_queue" => "more"}.merge(bus_attrs)
68
+ expect(hash["class"]).to eq("QueueBus::Worker")
69
+ expect(hash["args"].size).to eq(1)
70
+ expect(JSON.parse(hash["args"].first)).to eq({"bus_rider_app_key"=>"app2", "x" => "y", "bus_event_type" => "event4", "bus_rider_sub_key"=>"event4", "bus_rider_queue" => "more"}.merge(bus_attrs))
71
71
 
72
72
  hash = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:default") })
73
- hash["class"].should == "QueueBus::Worker"
74
- hash["args"].size.should == 1
75
- JSON.parse(hash["args"].first).should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event4", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs)
73
+ expect(hash["class"]).to eq("QueueBus::Worker")
74
+ expect(hash["args"].size).to eq(1)
75
+ expect(JSON.parse(hash["args"].first)).to eq({"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event4", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs))
76
76
  end
77
77
 
78
78
  it "should queue up to the same" do
79
79
  Driver.perform(attributes.merge("bus_event_type" => "event5"))
80
- QueueBus.redis { |redis| redis.smembers("queues") }.should =~ ["default"]
80
+ expect(QueueBus.redis { |redis| redis.smembers("queues") }).to match_array(["default"])
81
81
 
82
- QueueBus.redis { |redis| redis.llen("queue:default") }.should == 2
82
+ expect(QueueBus.redis { |redis| redis.llen("queue:default") }).to eq(2)
83
83
 
84
84
  pop1 = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:default") })
85
85
  pop2 = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:default") })
@@ -98,11 +98,11 @@ module QueueBus
98
98
  args2 = pargs1
99
99
  end
100
100
 
101
- hash1["class"].should == "QueueBus::Worker"
102
- args1.should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event5", "bus_rider_queue" => "default"}.merge(bus_attrs)
101
+ expect(hash1["class"]).to eq("QueueBus::Worker")
102
+ expect(args1).to eq({"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event5", "bus_rider_queue" => "default"}.merge(bus_attrs))
103
103
 
104
- hash2["class"].should == "QueueBus::Worker"
105
- args2.should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs)
104
+ expect(hash2["class"]).to eq("QueueBus::Worker")
105
+ expect(args2).to eq({"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs))
106
106
  end
107
107
  end
108
108
  end
@@ -20,7 +20,7 @@ module QueueBus
20
20
 
21
21
  it "should publish the current time once" do
22
22
  Timecop.freeze "12/12/2013 12:01:19" do
23
- QueueBus.should_receive(:publish).with("heartbeat_minutes", now_attributes)
23
+ expect(QueueBus).to receive(:publish).with("heartbeat_minutes", now_attributes)
24
24
  Heartbeat.perform
25
25
  end
26
26
 
@@ -31,12 +31,12 @@ module QueueBus
31
31
 
32
32
  it "should publish a minute later" do
33
33
  Timecop.freeze "12/12/2013 12:01:19" do
34
- QueueBus.should_receive(:publish).with("heartbeat_minutes", now_attributes)
34
+ expect(QueueBus).to receive(:publish).with("heartbeat_minutes", now_attributes)
35
35
  Heartbeat.perform
36
36
  end
37
37
 
38
38
  Timecop.freeze "12/12/2013 12:02:01" do
39
- QueueBus.should_receive(:publish).with("heartbeat_minutes", now_attributes)
39
+ expect(QueueBus).to receive(:publish).with("heartbeat_minutes", now_attributes)
40
40
  Heartbeat.perform
41
41
  end
42
42
  end
@@ -6,15 +6,15 @@ module QueueBus
6
6
  write1 = Subscription.new("default", "key1", "MyClass1", {"bus_event_type" => "event_one"})
7
7
  write2 = Subscription.new("else_ok", "key2", "MyClass2", {"bus_event_type" => /^[ab]here/}) #regex
8
8
 
9
- write1.matches?("bus_event_type" => "event_one").should == true
10
- write1.matches?("bus_event_type" => "event_one1").should == false
11
- write1.matches?("bus_event_type" => "aevent_one").should == false
9
+ expect(write1.matches?("bus_event_type" => "event_one")).to eq(true)
10
+ expect(write1.matches?("bus_event_type" => "event_one1")).to eq(false)
11
+ expect(write1.matches?("bus_event_type" => "aevent_one")).to eq(false)
12
12
 
13
- write2.matches?("bus_event_type" => "ahere").should == true
14
- write2.matches?("bus_event_type" => "bhere").should == true
15
- write2.matches?("bus_event_type" => "qhere").should == false
16
- write2.matches?("bus_event_type" => "abhere").should == false
17
- write2.matches?("bus_event_type" => "[ab]here").should == false
13
+ expect(write2.matches?("bus_event_type" => "ahere")).to eq(true)
14
+ expect(write2.matches?("bus_event_type" => "bhere")).to eq(true)
15
+ expect(write2.matches?("bus_event_type" => "qhere")).to eq(false)
16
+ expect(write2.matches?("bus_event_type" => "abhere")).to eq(false)
17
+ expect(write2.matches?("bus_event_type" => "[ab]here")).to eq(false)
18
18
 
19
19
  write = SubscriptionList.new
20
20
  write.add(write1)
@@ -27,26 +27,26 @@ module QueueBus
27
27
  app = Application.new("test")
28
28
  read = app.send(:subscriptions)
29
29
 
30
- read.size.should == 2
30
+ expect(read.size).to eq(2)
31
31
  read1 = read.key("key1")
32
32
  read2 = read.key("key2")
33
- read1.should_not be_nil
34
- read2.should_not be_nil
33
+ expect(read1).not_to be_nil
34
+ expect(read2).not_to be_nil
35
35
 
36
- read1.queue_name.should == "default"
37
- read1.class_name.should == "MyClass1"
38
- read2.queue_name.should == "else_ok"
39
- read2.class_name.should == "MyClass2"
36
+ expect(read1.queue_name).to eq("default")
37
+ expect(read1.class_name).to eq("MyClass1")
38
+ expect(read2.queue_name).to eq("else_ok")
39
+ expect(read2.class_name).to eq("MyClass2")
40
40
 
41
- read1.matches?("bus_event_type" => "event_one").should == true
42
- read1.matches?("bus_event_type" => "event_one1").should == false
43
- read1.matches?("bus_event_type" => "aevent_one").should == false
41
+ expect(read1.matches?("bus_event_type" => "event_one")).to eq(true)
42
+ expect(read1.matches?("bus_event_type" => "event_one1")).to eq(false)
43
+ expect(read1.matches?("bus_event_type" => "aevent_one")).to eq(false)
44
44
 
45
- read2.matches?("bus_event_type" => "ahere").should == true
46
- read2.matches?("bus_event_type" => "bhere").should == true
47
- read2.matches?("bus_event_type" => "qhere").should == false
48
- read2.matches?("bus_event_type" => "abhere").should == false
49
- read2.matches?("bus_event_type" => "[ab]here").should == false
45
+ expect(read2.matches?("bus_event_type" => "ahere")).to eq(true)
46
+ expect(read2.matches?("bus_event_type" => "bhere")).to eq(true)
47
+ expect(read2.matches?("bus_event_type" => "qhere")).to eq(false)
48
+ expect(read2.matches?("bus_event_type" => "abhere")).to eq(false)
49
+ expect(read2.matches?("bus_event_type" => "[ab]here")).to eq(false)
50
50
 
51
51
  end
52
52
  end
data/spec/matcher_spec.rb CHANGED
@@ -4,140 +4,140 @@ module QueueBus
4
4
  describe Matcher do
5
5
  it "should already return false on empty filters" do
6
6
  matcher = Matcher.new({})
7
- matcher.matches?({}).should == false
8
- matcher.matches?(nil).should == false
9
- matcher.matches?("name" => "val").should == false
7
+ expect(matcher.matches?({})).to eq(false)
8
+ expect(matcher.matches?(nil)).to eq(false)
9
+ expect(matcher.matches?("name" => "val")).to eq(false)
10
10
  end
11
11
 
12
12
  it "should not crash if nil inputs" do
13
13
  matcher = Matcher.new("name" => "val")
14
- matcher.matches?(nil).should == false
14
+ expect(matcher.matches?(nil)).to eq(false)
15
15
  end
16
16
 
17
17
  it "string filter to/from redis" do
18
18
  matcher = Matcher.new("name" => "val")
19
- matcher.matches?("name" => "val").should == true
20
- matcher.matches?("name" => " val").should == false
21
- matcher.matches?("name" => "zval").should == false
19
+ expect(matcher.matches?("name" => "val")).to eq(true)
20
+ expect(matcher.matches?("name" => " val")).to eq(false)
21
+ expect(matcher.matches?("name" => "zval")).to eq(false)
22
22
  end
23
23
 
24
24
  it "regex filter" do
25
25
  matcher = Matcher.new("name" => /^[cb]a+t/)
26
- matcher.matches?("name" => "cat").should == true
27
- matcher.matches?("name" => "bat").should == true
28
- matcher.matches?("name" => "caaaaat").should == true
29
- matcher.matches?("name" => "ct").should == false
30
- matcher.matches?("name" => "bcat").should == false
26
+ expect(matcher.matches?("name" => "cat")).to eq(true)
27
+ expect(matcher.matches?("name" => "bat")).to eq(true)
28
+ expect(matcher.matches?("name" => "caaaaat")).to eq(true)
29
+ expect(matcher.matches?("name" => "ct")).to eq(false)
30
+ expect(matcher.matches?("name" => "bcat")).to eq(false)
31
31
  end
32
32
 
33
33
  it "present filter" do
34
34
  matcher = Matcher.new("name" => :present)
35
- matcher.matches?("name" => "").should == false
36
- matcher.matches?("name" => "cat").should == true
37
- matcher.matches?("name" => "bear").should == true
38
- matcher.matches?("other" => "bear").should == false
35
+ expect(matcher.matches?("name" => "")).to eq(false)
36
+ expect(matcher.matches?("name" => "cat")).to eq(true)
37
+ expect(matcher.matches?("name" => "bear")).to eq(true)
38
+ expect(matcher.matches?("other" => "bear")).to eq(false)
39
39
  end
40
40
 
41
41
  it "blank filter" do
42
42
  matcher = Matcher.new("name" => :blank)
43
- matcher.matches?("name" => nil).should == true
44
- matcher.matches?("other" => "bear").should == true
45
- matcher.matches?("name" => "").should == true
46
- matcher.matches?("name" => " ").should == true
47
- matcher.matches?("name" => "bear").should == false
48
- matcher.matches?("name" => " s ").should == false
43
+ expect(matcher.matches?("name" => nil)).to eq(true)
44
+ expect(matcher.matches?("other" => "bear")).to eq(true)
45
+ expect(matcher.matches?("name" => "")).to eq(true)
46
+ expect(matcher.matches?("name" => " ")).to eq(true)
47
+ expect(matcher.matches?("name" => "bear")).to eq(false)
48
+ expect(matcher.matches?("name" => " s ")).to eq(false)
49
49
  end
50
50
 
51
51
  it "nil filter" do
52
52
  matcher = Matcher.new("name" => :nil)
53
- matcher.matches?("name" => nil).should == true
54
- matcher.matches?("other" => "bear").should == true
55
- matcher.matches?("name" => "").should == false
56
- matcher.matches?("name" => " ").should == false
57
- matcher.matches?("name" => "bear").should == false
53
+ expect(matcher.matches?("name" => nil)).to eq(true)
54
+ expect(matcher.matches?("other" => "bear")).to eq(true)
55
+ expect(matcher.matches?("name" => "")).to eq(false)
56
+ expect(matcher.matches?("name" => " ")).to eq(false)
57
+ expect(matcher.matches?("name" => "bear")).to eq(false)
58
58
  end
59
59
 
60
60
  it "key filter" do
61
61
  matcher = Matcher.new("name" => :key)
62
- matcher.matches?("name" => nil).should == true
63
- matcher.matches?("other" => "bear").should == false
64
- matcher.matches?("name" => "").should == true
65
- matcher.matches?("name" => " ").should == true
66
- matcher.matches?("name" => "bear").should == true
62
+ expect(matcher.matches?("name" => nil)).to eq(true)
63
+ expect(matcher.matches?("other" => "bear")).to eq(false)
64
+ expect(matcher.matches?("name" => "")).to eq(true)
65
+ expect(matcher.matches?("name" => " ")).to eq(true)
66
+ expect(matcher.matches?("name" => "bear")).to eq(true)
67
67
  end
68
68
 
69
69
  it "empty filter" do
70
70
  matcher = Matcher.new("name" => :empty)
71
- matcher.matches?("name" => nil).should == false
72
- matcher.matches?("other" => "bear").should == false
73
- matcher.matches?("name" => "").should == true
74
- matcher.matches?("name" => " ").should == false
75
- matcher.matches?("name" => "bear").should == false
76
- matcher.matches?("name" => " s ").should == false
71
+ expect(matcher.matches?("name" => nil)).to eq(false)
72
+ expect(matcher.matches?("other" => "bear")).to eq(false)
73
+ expect(matcher.matches?("name" => "")).to eq(true)
74
+ expect(matcher.matches?("name" => " ")).to eq(false)
75
+ expect(matcher.matches?("name" => "bear")).to eq(false)
76
+ expect(matcher.matches?("name" => " s ")).to eq(false)
77
77
  end
78
78
 
79
79
  it "value filter" do
80
80
  matcher = Matcher.new("name" => :value)
81
- matcher.matches?("name" => nil).should == false
82
- matcher.matches?("other" => "bear").should == false
83
- matcher.matches?("name" => "").should == true
84
- matcher.matches?("name" => " ").should == true
85
- matcher.matches?("name" => "bear").should == true
86
- matcher.matches?("name" => " s ").should == true
81
+ expect(matcher.matches?("name" => nil)).to eq(false)
82
+ expect(matcher.matches?("other" => "bear")).to eq(false)
83
+ expect(matcher.matches?("name" => "")).to eq(true)
84
+ expect(matcher.matches?("name" => " ")).to eq(true)
85
+ expect(matcher.matches?("name" => "bear")).to eq(true)
86
+ expect(matcher.matches?("name" => " s ")).to eq(true)
87
87
  end
88
88
 
89
89
  it "multiple filters" do
90
90
  matcher = Matcher.new("name" => /^[cb]a+t/, "state" => "sleeping")
91
- matcher.matches?("state" => "sleeping", "name" => "cat").should == true
92
- matcher.matches?("state" => "awake", "name" => "cat").should == false
93
- matcher.matches?("state" => "sleeping", "name" => "bat").should == true
94
- matcher.matches?("state" => "sleeping", "name" => "bear").should == false
95
- matcher.matches?("state" => "awake", "name" => "bear").should == false
91
+ expect(matcher.matches?("state" => "sleeping", "name" => "cat")).to eq(true)
92
+ expect(matcher.matches?("state" => "awake", "name" => "cat")).to eq(false)
93
+ expect(matcher.matches?("state" => "sleeping", "name" => "bat")).to eq(true)
94
+ expect(matcher.matches?("state" => "sleeping", "name" => "bear")).to eq(false)
95
+ expect(matcher.matches?("state" => "awake", "name" => "bear")).to eq(false)
96
96
  end
97
97
 
98
98
  it "regex should go back and forth into redis" do
99
99
  matcher = Matcher.new("name" => /^[cb]a+t/)
100
- matcher.matches?("name" => "cat").should == true
101
- matcher.matches?("name" => "bat").should == true
102
- matcher.matches?("name" => "caaaaat").should == true
103
- matcher.matches?("name" => "ct").should == false
104
- matcher.matches?("name" => "bcat").should == false
100
+ expect(matcher.matches?("name" => "cat")).to eq(true)
101
+ expect(matcher.matches?("name" => "bat")).to eq(true)
102
+ expect(matcher.matches?("name" => "caaaaat")).to eq(true)
103
+ expect(matcher.matches?("name" => "ct")).to eq(false)
104
+ expect(matcher.matches?("name" => "bcat")).to eq(false)
105
105
 
106
106
  QueueBus.redis { |redis| redis.set("temp1", QueueBus::Util.encode(matcher.to_redis) ) }
107
107
  redis = QueueBus.redis { |redis| redis.get("temp1") }
108
108
  matcher = Matcher.new(QueueBus::Util.decode(redis))
109
- matcher.matches?("name" => "cat").should == true
110
- matcher.matches?("name" => "bat").should == true
111
- matcher.matches?("name" => "caaaaat").should == true
112
- matcher.matches?("name" => "ct").should == false
113
- matcher.matches?("name" => "bcat").should == false
109
+ expect(matcher.matches?("name" => "cat")).to eq(true)
110
+ expect(matcher.matches?("name" => "bat")).to eq(true)
111
+ expect(matcher.matches?("name" => "caaaaat")).to eq(true)
112
+ expect(matcher.matches?("name" => "ct")).to eq(false)
113
+ expect(matcher.matches?("name" => "bcat")).to eq(false)
114
114
 
115
115
  QueueBus.redis { |redis| redis.set("temp2", QueueBus::Util.encode(matcher.to_redis) ) }
116
116
  redis = QueueBus.redis { |redis| redis.get("temp2") }
117
117
  matcher = Matcher.new(QueueBus::Util.decode(redis))
118
- matcher.matches?("name" => "cat").should == true
119
- matcher.matches?("name" => "bat").should == true
120
- matcher.matches?("name" => "caaaaat").should == true
121
- matcher.matches?("name" => "ct").should == false
122
- matcher.matches?("name" => "bcat").should == false
118
+ expect(matcher.matches?("name" => "cat")).to eq(true)
119
+ expect(matcher.matches?("name" => "bat")).to eq(true)
120
+ expect(matcher.matches?("name" => "caaaaat")).to eq(true)
121
+ expect(matcher.matches?("name" => "ct")).to eq(false)
122
+ expect(matcher.matches?("name" => "bcat")).to eq(false)
123
123
  end
124
124
 
125
125
  it "special value should go back and forth into redis" do
126
126
  matcher = Matcher.new("name" => :blank)
127
- matcher.matches?("name" => "cat").should == false
128
- matcher.matches?("name" => "").should == true
127
+ expect(matcher.matches?("name" => "cat")).to eq(false)
128
+ expect(matcher.matches?("name" => "")).to eq(true)
129
129
 
130
130
  QueueBus.redis { |redis| redis.set("temp1", QueueBus::Util.encode(matcher.to_redis) ) }
131
131
  redis= QueueBus.redis { |redis| redis.get("temp1") }
132
132
  matcher = Matcher.new(QueueBus::Util.decode(redis))
133
- matcher.matches?("name" => "cat").should == false
134
- matcher.matches?("name" => "").should == true
133
+ expect(matcher.matches?("name" => "cat")).to eq(false)
134
+ expect(matcher.matches?("name" => "")).to eq(true)
135
135
 
136
136
  QueueBus.redis { |redis| redis.set("temp2", QueueBus::Util.encode(matcher.to_redis) ) }
137
137
  redis= QueueBus.redis { |redis| redis.get("temp2") }
138
138
  matcher = Matcher.new(QueueBus::Util.decode(redis))
139
- matcher.matches?("name" => "cat").should == false
140
- matcher.matches?("name" => "").should == true
139
+ expect(matcher.matches?("name" => "cat")).to eq(false)
140
+ expect(matcher.matches?("name" => "")).to eq(true)
141
141
  end
142
142
  end
143
143
  end