sidekiq-bus 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +1,43 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module QueueBus
4
6
  describe SubscriptionList do
5
- describe ".from_redis" do
6
- it "should return from attributes" do
7
- mult = {"event_one" => {"class" => "MyClass", "queue_name" => "default", "key" => "event_one", "matcher" => {"bus_event_type" => "event_one"}},
8
- "event_two" => {"class" => "MyClass", "queue_name" => "else", "key" => "event_two", "matcher" => {"bus_event_type" => "event_two"}}}
7
+ describe '.from_redis' do
8
+ it 'should return from attributes' do
9
+ mult = { 'event_one' => { 'class' => 'MyClass', 'queue_name' => 'default', 'key' => 'event_one', 'matcher' => { 'bus_event_type' => 'event_one' } },
10
+ 'event_two' => { 'class' => 'MyClass', 'queue_name' => 'else', 'key' => 'event_two', 'matcher' => { 'bus_event_type' => 'event_two' } } }
9
11
 
10
12
  list = SubscriptionList.from_redis(mult)
11
13
  expect(list.size).to eq(2)
12
- one = list.key("event_one")
13
- two = list.key("event_two")
14
-
15
- expect(one.key).to eq("event_one")
16
- expect(one.key).to eq("event_one")
17
- expect(one.queue_name).to eq("default")
18
- expect(one.class_name).to eq("MyClass")
19
- expect(one.matcher.filters).to eq({"bus_event_type" => "event_one"})
20
-
21
- expect(two.key).to eq("event_two")
22
- expect(two.key).to eq("event_two")
23
- expect(two.queue_name).to eq("else")
24
- expect(two.class_name).to eq("MyClass")
25
- expect(two.matcher.filters).to eq({"bus_event_type" => "event_two"})
14
+ one = list.key('event_one')
15
+ two = list.key('event_two')
16
+
17
+ expect(one.key).to eq('event_one')
18
+ expect(one.key).to eq('event_one')
19
+ expect(one.queue_name).to eq('default')
20
+ expect(one.class_name).to eq('MyClass')
21
+ expect(one.matcher.filters).to eq('bus_event_type' => 'event_one')
22
+
23
+ expect(two.key).to eq('event_two')
24
+ expect(two.key).to eq('event_two')
25
+ expect(two.queue_name).to eq('else')
26
+ expect(two.class_name).to eq('MyClass')
27
+ expect(two.matcher.filters).to eq('bus_event_type' => 'event_two')
26
28
  end
27
29
  end
28
-
29
- describe "#to_redis" do
30
- it "should generate what to store" do
30
+
31
+ describe '#to_redis' do
32
+ it 'should generate what to store' do
31
33
  list = SubscriptionList.new
32
- list.add(Subscription.new("default", "key1", "MyClass", {"bus_event_type" => "event_one"}))
33
- list.add(Subscription.new("else_ok", "key2", "MyClass", {"bus_event_type" => "event_two"}))
34
-
34
+ list.add(Subscription.new('default', 'key1', 'MyClass', 'bus_event_type' => 'event_one'))
35
+ list.add(Subscription.new('else_ok', 'key2', 'MyClass', 'bus_event_type' => 'event_two'))
36
+
35
37
  hash = list.to_redis
36
- expect(hash).to eq({ "key1" => {"queue_name" => "default", "key" => "key1", "class" => "MyClass", "matcher" => {"bus_event_type" => "event_one"}},
37
- "key2" => {"queue_name" => "else_ok", "key" => "key2", "class" => "MyClass", "matcher" => {"bus_event_type" => "event_two"}}
38
- })
39
-
38
+ expect(hash).to eq('key1' => { 'queue_name' => 'default', 'key' => 'key1', 'class' => 'MyClass', 'matcher' => { 'bus_event_type' => 'event_one' } },
39
+ 'key2' => { 'queue_name' => 'else_ok', 'key' => 'key2', 'class' => 'MyClass', 'matcher' => { 'bus_event_type' => 'event_two' } })
40
40
  end
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -1,53 +1,54 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module QueueBus
4
6
  describe Subscription do
5
- it "should normalize the queue name" do
6
- expect(Subscription.new("test", "my_event", "MyClass", {}, nil).queue_name).to eq("test")
7
- expect(Subscription.new("tes t", "my_event", "MyClass", {}, nil).queue_name).to eq("tes_t")
8
- expect(Subscription.new("t%s", "my_event", "MyClass", {}, nil).queue_name).to eq("t_s")
7
+ it 'should normalize the queue name' do
8
+ expect(Subscription.new('test', 'my_event', 'MyClass', {}, nil).queue_name).to eq('test')
9
+ expect(Subscription.new('tes t', 'my_event', 'MyClass', {}, nil).queue_name).to eq('tes_t')
10
+ expect(Subscription.new('t%s', 'my_event', 'MyClass', {}, nil).queue_name).to eq('t_s')
9
11
  end
10
-
11
- describe ".register" do
12
- it "should take in args from dispatcher" do
13
- executor = Proc.new { |attributes| }
14
- sub = Subscription.register("queue_name", "mykey", "MyClass", {"bus_event_type" => "my_event"}, executor)
12
+
13
+ describe '.register' do
14
+ it 'should take in args from dispatcher' do
15
+ executor = proc { |attributes| }
16
+ sub = Subscription.register('queue_name', 'mykey', 'MyClass', { 'bus_event_type' => 'my_event' }, executor)
15
17
  expect(sub.send(:executor)).to eq(executor)
16
- expect(sub.matcher.filters).to eq({"bus_event_type" => "my_event"})
17
- expect(sub.queue_name).to eq("queue_name")
18
- expect(sub.key).to eq("mykey")
19
- expect(sub.class_name).to eq("MyClass")
18
+ expect(sub.matcher.filters).to eq('bus_event_type' => 'my_event')
19
+ expect(sub.queue_name).to eq('queue_name')
20
+ expect(sub.key).to eq('mykey')
21
+ expect(sub.class_name).to eq('MyClass')
20
22
  end
21
23
  end
22
-
23
- describe "#execute!" do
24
- it "should call the executor with the attributes" do
24
+
25
+ describe '#execute!' do
26
+ it 'should call the executor with the attributes' do
25
27
  exec = Object.new
26
28
  expect(exec).to receive(:call)
27
-
28
- sub = Subscription.new("x", "y", "ClassName", {}, exec)
29
- sub.execute!({"ok" => true})
29
+
30
+ sub = Subscription.new('x', 'y', 'ClassName', {}, exec)
31
+ sub.execute!('ok' => true)
30
32
  end
31
33
  end
32
-
33
- describe "#to_redis" do
34
- it "should return what to store for this subscription" do
35
- sub = Subscription.new("queue_one", "xyz", "ClassName", {"bus_event_type" => "my_event"}, nil)
36
- expect(sub.to_redis).to eq({"queue_name" => "queue_one", "key" => "xyz", "class" => "ClassName", "matcher" => {"bus_event_type" => "my_event"}})
34
+
35
+ describe '#to_redis' do
36
+ it 'should return what to store for this subscription' do
37
+ sub = Subscription.new('queue_one', 'xyz', 'ClassName', { 'bus_event_type' => 'my_event' }, nil)
38
+ expect(sub.to_redis).to eq('queue_name' => 'queue_one', 'key' => 'xyz', 'class' => 'ClassName', 'matcher' => { 'bus_event_type' => 'my_event' })
37
39
  end
38
40
  end
39
-
40
- describe "#matches?" do
41
- it "should do pattern stuff" do
42
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "one"}).matches?("bus_event_type" => "one")).to eq(true)
43
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "one"}).matches?("bus_event_type" => "onex")).to eq(false)
44
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "^one.*$"}).matches?("bus_event_type" => "onex")).to eq(true)
45
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "one.*"}).matches?("bus_event_type" => "onex")).to eq(true)
46
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "one.?"}).matches?("bus_event_type" => "onex")).to eq(true)
47
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "one.?"}).matches?("bus_event_type" => "one")).to eq(true)
48
- expect(Subscription.new("x", "id", "ClassName", {"bus_event_type" => "\\"}).matches?("bus_event_type" => "one")).to eq(false)
41
+
42
+ describe '#matches?' do
43
+ it 'should do pattern stuff' do
44
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => 'one').matches?('bus_event_type' => 'one')).to eq(true)
45
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => 'one').matches?('bus_event_type' => 'onex')).to eq(false)
46
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => '^one.*$').matches?('bus_event_type' => 'onex')).to eq(true)
47
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => 'one.*').matches?('bus_event_type' => 'onex')).to eq(true)
48
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => 'one.?').matches?('bus_event_type' => 'onex')).to eq(true)
49
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => 'one.?').matches?('bus_event_type' => 'one')).to eq(true)
50
+ expect(Subscription.new('x', 'id', 'ClassName', 'bus_event_type' => '\\').matches?('bus_event_type' => 'one')).to eq(false)
49
51
  end
50
52
  end
51
-
52
53
  end
53
- end
54
+ end
@@ -1,31 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module QueueBus
4
6
  describe Worker do
5
- it "should proxy to given class" do
6
- hash = {"bus_class_proxy" => "QueueBus::Driver", "ok" => true}
7
+ it 'should proxy to given class' do
8
+ hash = { 'bus_class_proxy' => 'QueueBus::Driver', 'ok' => true }
7
9
  expect(QueueBus::Driver).to receive(:perform).with(hash)
8
10
  QueueBus::Worker.perform(JSON.generate(hash))
9
11
  end
10
12
 
11
- it "should use instance" do
12
- hash = {"bus_class_proxy" => "QueueBus::Rider", "ok" => true}
13
+ it 'should use instance' do
14
+ hash = { 'bus_class_proxy' => 'QueueBus::Rider', 'ok' => true }
13
15
  expect(QueueBus::Rider).to receive(:perform).with(hash)
14
16
  QueueBus::Worker.new.perform(JSON.generate(hash))
15
17
  end
16
18
 
17
- it "should not freak out if class not there anymore" do
18
- hash = {"bus_class_proxy" => "QueueBus::BadClass", "ok" => true}
19
+ it 'should not freak out if class not there anymore' do
20
+ hash = { 'bus_class_proxy' => 'QueueBus::BadClass', 'ok' => true }
19
21
 
20
22
  expect(QueueBus::Worker.perform(JSON.generate(hash))).to eq(nil)
21
23
  end
22
24
 
23
- it "should raise error if proxy raises error" do
24
- hash = {"bus_class_proxy" => "QueueBus::Rider", "ok" => true}
25
- expect(QueueBus::Rider).to receive(:perform).with(hash).and_raise("rider crash")
26
- expect {
25
+ it 'should raise error if proxy raises error' do
26
+ hash = { 'bus_class_proxy' => 'QueueBus::Rider', 'ok' => true }
27
+ expect(QueueBus::Rider).to receive(:perform).with(hash).and_raise('rider crash')
28
+ expect do
27
29
  QueueBus::Worker.perform(JSON.generate(hash))
28
- }.to raise_error("rider crash")
30
+ end.to raise_error('rider crash')
29
31
  end
30
32
  end
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Leonard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-05 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: queue-bus