sidekiq-bus 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +1,54 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module QueueBus
4
- describe "Integration" do
5
- it "should round trip attributes" do
6
- write1 = Subscription.new("default", "key1", "MyClass1", {"bus_event_type" => "event_one"})
7
- write2 = Subscription.new("else_ok", "key2", "MyClass2", {"bus_event_type" => /^[ab]here/}) #regex
8
-
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
-
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
-
6
+ describe 'Integration' do
7
+ it 'should round trip attributes' do
8
+ write1 = Subscription.new('default', 'key1', 'MyClass1', 'bus_event_type' => 'event_one')
9
+ write2 = Subscription.new('else_ok', 'key2', 'MyClass2', 'bus_event_type' => /^[ab]here/) # regex
10
+
11
+ expect(write1.matches?('bus_event_type' => 'event_one')).to eq(true)
12
+ expect(write1.matches?('bus_event_type' => 'event_one1')).to eq(false)
13
+ expect(write1.matches?('bus_event_type' => 'aevent_one')).to eq(false)
14
+
15
+ expect(write2.matches?('bus_event_type' => 'ahere')).to eq(true)
16
+ expect(write2.matches?('bus_event_type' => 'bhere')).to eq(true)
17
+ expect(write2.matches?('bus_event_type' => 'qhere')).to eq(false)
18
+ expect(write2.matches?('bus_event_type' => 'abhere')).to eq(false)
19
+ expect(write2.matches?('bus_event_type' => '[ab]here')).to eq(false)
20
+
19
21
  write = SubscriptionList.new
20
22
  write.add(write1)
21
23
  write.add(write2)
22
-
23
- app = Application.new("test")
24
+
25
+ app = Application.new('test')
24
26
  app.subscribe(write)
25
-
26
- reset_test_adapter # reset to make sure we read from redis
27
- app = Application.new("test")
27
+
28
+ reset_test_adapter # reset to make sure we read from redis
29
+ app = Application.new('test')
28
30
  read = app.send(:subscriptions)
29
-
31
+
30
32
  expect(read.size).to eq(2)
31
- read1 = read.key("key1")
32
- read2 = read.key("key2")
33
+ read1 = read.key('key1')
34
+ read2 = read.key('key2')
33
35
  expect(read1).not_to be_nil
34
36
  expect(read2).not_to be_nil
35
-
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
-
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
-
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
-
37
+
38
+ expect(read1.queue_name).to eq('default')
39
+ expect(read1.class_name).to eq('MyClass1')
40
+ expect(read2.queue_name).to eq('else_ok')
41
+ expect(read2.class_name).to eq('MyClass2')
42
+
43
+ expect(read1.matches?('bus_event_type' => 'event_one')).to eq(true)
44
+ expect(read1.matches?('bus_event_type' => 'event_one1')).to eq(false)
45
+ expect(read1.matches?('bus_event_type' => 'aevent_one')).to eq(false)
46
+
47
+ expect(read2.matches?('bus_event_type' => 'ahere')).to eq(true)
48
+ expect(read2.matches?('bus_event_type' => 'bhere')).to eq(true)
49
+ expect(read2.matches?('bus_event_type' => 'qhere')).to eq(false)
50
+ expect(read2.matches?('bus_event_type' => 'abhere')).to eq(false)
51
+ expect(read2.matches?('bus_event_type' => '[ab]here')).to eq(false)
51
52
  end
52
53
  end
53
- end
54
+ end
@@ -1,143 +1,145 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module QueueBus
4
6
  describe Matcher do
5
- it "should already return false on empty filters" do
7
+ it 'should already return false on empty filters' do
6
8
  matcher = Matcher.new({})
7
- expect(matcher.matches?({})).to eq(false)
9
+ expect(matcher.matches?({})).to eq(false)
8
10
  expect(matcher.matches?(nil)).to eq(false)
9
- expect(matcher.matches?("name" => "val")).to eq(false)
11
+ expect(matcher.matches?('name' => 'val')).to eq(false)
10
12
  end
11
13
 
12
- it "should not crash if nil inputs" do
13
- matcher = Matcher.new("name" => "val")
14
+ it 'should not crash if nil inputs' do
15
+ matcher = Matcher.new('name' => 'val')
14
16
  expect(matcher.matches?(nil)).to eq(false)
15
17
  end
16
18
 
17
- it "string filter to/from redis" do
18
- matcher = Matcher.new("name" => "val")
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)
19
+ it 'string filter to/from redis' do
20
+ matcher = Matcher.new('name' => 'val')
21
+ expect(matcher.matches?('name' => 'val')).to eq(true)
22
+ expect(matcher.matches?('name' => ' val')).to eq(false)
23
+ expect(matcher.matches?('name' => 'zval')).to eq(false)
22
24
  end
23
25
 
24
- it "regex filter" do
25
- matcher = Matcher.new("name" => /^[cb]a+t/)
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)
26
+ it 'regex filter' do
27
+ matcher = Matcher.new('name' => /^[cb]a+t/)
28
+ expect(matcher.matches?('name' => 'cat')).to eq(true)
29
+ expect(matcher.matches?('name' => 'bat')).to eq(true)
30
+ expect(matcher.matches?('name' => 'caaaaat')).to eq(true)
31
+ expect(matcher.matches?('name' => 'ct')).to eq(false)
32
+ expect(matcher.matches?('name' => 'bcat')).to eq(false)
31
33
  end
32
34
 
33
- it "present filter" do
34
- matcher = Matcher.new("name" => :present)
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)
35
+ it 'present filter' do
36
+ matcher = Matcher.new('name' => :present)
37
+ expect(matcher.matches?('name' => '')).to eq(false)
38
+ expect(matcher.matches?('name' => 'cat')).to eq(true)
39
+ expect(matcher.matches?('name' => 'bear')).to eq(true)
40
+ expect(matcher.matches?('other' => 'bear')).to eq(false)
39
41
  end
40
42
 
41
- it "blank filter" do
42
- matcher = Matcher.new("name" => :blank)
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)
43
+ it 'blank filter' do
44
+ matcher = Matcher.new('name' => :blank)
45
+ expect(matcher.matches?('name' => nil)).to eq(true)
46
+ expect(matcher.matches?('other' => 'bear')).to eq(true)
47
+ expect(matcher.matches?('name' => '')).to eq(true)
48
+ expect(matcher.matches?('name' => ' ')).to eq(true)
49
+ expect(matcher.matches?('name' => 'bear')).to eq(false)
50
+ expect(matcher.matches?('name' => ' s ')).to eq(false)
49
51
  end
50
52
 
51
- it "nil filter" do
52
- matcher = Matcher.new("name" => :nil)
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)
53
+ it 'nil filter' do
54
+ matcher = Matcher.new('name' => :nil)
55
+ expect(matcher.matches?('name' => nil)).to eq(true)
56
+ expect(matcher.matches?('other' => 'bear')).to eq(true)
57
+ expect(matcher.matches?('name' => '')).to eq(false)
58
+ expect(matcher.matches?('name' => ' ')).to eq(false)
59
+ expect(matcher.matches?('name' => 'bear')).to eq(false)
58
60
  end
59
61
 
60
- it "key filter" do
61
- matcher = Matcher.new("name" => :key)
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)
62
+ it 'key filter' do
63
+ matcher = Matcher.new('name' => :key)
64
+ expect(matcher.matches?('name' => nil)).to eq(true)
65
+ expect(matcher.matches?('other' => 'bear')).to eq(false)
66
+ expect(matcher.matches?('name' => '')).to eq(true)
67
+ expect(matcher.matches?('name' => ' ')).to eq(true)
68
+ expect(matcher.matches?('name' => 'bear')).to eq(true)
67
69
  end
68
70
 
69
- it "empty filter" do
70
- matcher = Matcher.new("name" => :empty)
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)
71
+ it 'empty filter' do
72
+ matcher = Matcher.new('name' => :empty)
73
+ expect(matcher.matches?('name' => nil)).to eq(false)
74
+ expect(matcher.matches?('other' => 'bear')).to eq(false)
75
+ expect(matcher.matches?('name' => '')).to eq(true)
76
+ expect(matcher.matches?('name' => ' ')).to eq(false)
77
+ expect(matcher.matches?('name' => 'bear')).to eq(false)
78
+ expect(matcher.matches?('name' => ' s ')).to eq(false)
77
79
  end
78
80
 
79
- it "value filter" do
80
- matcher = Matcher.new("name" => :value)
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)
81
+ it 'value filter' do
82
+ matcher = Matcher.new('name' => :value)
83
+ expect(matcher.matches?('name' => nil)).to eq(false)
84
+ expect(matcher.matches?('other' => 'bear')).to eq(false)
85
+ expect(matcher.matches?('name' => '')).to eq(true)
86
+ expect(matcher.matches?('name' => ' ')).to eq(true)
87
+ expect(matcher.matches?('name' => 'bear')).to eq(true)
88
+ expect(matcher.matches?('name' => ' s ')).to eq(true)
87
89
  end
88
90
 
89
- it "multiple filters" do
90
- matcher = Matcher.new("name" => /^[cb]a+t/, "state" => "sleeping")
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)
91
+ it 'multiple filters' do
92
+ matcher = Matcher.new('name' => /^[cb]a+t/, 'state' => 'sleeping')
93
+ expect(matcher.matches?('state' => 'sleeping', 'name' => 'cat')).to eq(true)
94
+ expect(matcher.matches?('state' => 'awake', 'name' => 'cat')).to eq(false)
95
+ expect(matcher.matches?('state' => 'sleeping', 'name' => 'bat')).to eq(true)
96
+ expect(matcher.matches?('state' => 'sleeping', 'name' => 'bear')).to eq(false)
97
+ expect(matcher.matches?('state' => 'awake', 'name' => 'bear')).to eq(false)
96
98
  end
97
99
 
98
- it "regex should go back and forth into redis" do
99
- matcher = Matcher.new("name" => /^[cb]a+t/)
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)
100
+ it 'regex should go back and forth into redis' do
101
+ matcher = Matcher.new('name' => /^[cb]a+t/)
102
+ expect(matcher.matches?('name' => 'cat')).to eq(true)
103
+ expect(matcher.matches?('name' => 'bat')).to eq(true)
104
+ expect(matcher.matches?('name' => 'caaaaat')).to eq(true)
105
+ expect(matcher.matches?('name' => 'ct')).to eq(false)
106
+ expect(matcher.matches?('name' => 'bcat')).to eq(false)
105
107
 
106
- QueueBus.redis { |redis| redis.set("temp1", QueueBus::Util.encode(matcher.to_redis) ) }
107
- redis = QueueBus.redis { |redis| redis.get("temp1") }
108
+ QueueBus.redis { |redis| redis.set('temp1', QueueBus::Util.encode(matcher.to_redis)) }
109
+ redis = QueueBus.redis { |redis| redis.get('temp1') }
108
110
  matcher = Matcher.new(QueueBus::Util.decode(redis))
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
-
115
- QueueBus.redis { |redis| redis.set("temp2", QueueBus::Util.encode(matcher.to_redis) ) }
116
- redis = QueueBus.redis { |redis| redis.get("temp2") }
111
+ expect(matcher.matches?('name' => 'cat')).to eq(true)
112
+ expect(matcher.matches?('name' => 'bat')).to eq(true)
113
+ expect(matcher.matches?('name' => 'caaaaat')).to eq(true)
114
+ expect(matcher.matches?('name' => 'ct')).to eq(false)
115
+ expect(matcher.matches?('name' => 'bcat')).to eq(false)
116
+
117
+ QueueBus.redis { |redis| redis.set('temp2', QueueBus::Util.encode(matcher.to_redis)) }
118
+ redis = QueueBus.redis { |redis| redis.get('temp2') }
117
119
  matcher = Matcher.new(QueueBus::Util.decode(redis))
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)
120
+ expect(matcher.matches?('name' => 'cat')).to eq(true)
121
+ expect(matcher.matches?('name' => 'bat')).to eq(true)
122
+ expect(matcher.matches?('name' => 'caaaaat')).to eq(true)
123
+ expect(matcher.matches?('name' => 'ct')).to eq(false)
124
+ expect(matcher.matches?('name' => 'bcat')).to eq(false)
123
125
  end
124
126
 
125
- it "special value should go back and forth into redis" do
126
- matcher = Matcher.new("name" => :blank)
127
- expect(matcher.matches?("name" => "cat")).to eq(false)
128
- expect(matcher.matches?("name" => "")).to eq(true)
127
+ it 'special value should go back and forth into redis' do
128
+ matcher = Matcher.new('name' => :blank)
129
+ expect(matcher.matches?('name' => 'cat')).to eq(false)
130
+ expect(matcher.matches?('name' => '')).to eq(true)
129
131
 
130
- QueueBus.redis { |redis| redis.set("temp1", QueueBus::Util.encode(matcher.to_redis) ) }
131
- redis= QueueBus.redis { |redis| redis.get("temp1") }
132
+ QueueBus.redis { |redis| redis.set('temp1', QueueBus::Util.encode(matcher.to_redis)) }
133
+ redis = QueueBus.redis { |redis| redis.get('temp1') }
132
134
  matcher = Matcher.new(QueueBus::Util.decode(redis))
133
- expect(matcher.matches?("name" => "cat")).to eq(false)
134
- expect(matcher.matches?("name" => "")).to eq(true)
135
+ expect(matcher.matches?('name' => 'cat')).to eq(false)
136
+ expect(matcher.matches?('name' => '')).to eq(true)
135
137
 
136
- QueueBus.redis { |redis| redis.set("temp2", QueueBus::Util.encode(matcher.to_redis) ) }
137
- redis= QueueBus.redis { |redis| redis.get("temp2") }
138
+ QueueBus.redis { |redis| redis.set('temp2', QueueBus::Util.encode(matcher.to_redis)) }
139
+ redis = QueueBus.redis { |redis| redis.get('temp2') }
138
140
  matcher = Matcher.new(QueueBus::Util.decode(redis))
139
- expect(matcher.matches?("name" => "cat")).to eq(false)
140
- expect(matcher.matches?("name" => "")).to eq(true)
141
+ expect(matcher.matches?('name' => 'cat')).to eq(false)
142
+ expect(matcher.matches?('name' => '')).to eq(true)
141
143
  end
142
144
  end
143
145
  end
@@ -1,98 +1,98 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe "Publishing an event" do
3
+ require 'spec_helper'
4
4
 
5
+ describe 'Publishing an event' do
5
6
  before(:each) do
6
7
  Timecop.freeze
7
- allow(QueueBus).to receive(:generate_uuid).and_return("idfhlkj")
8
+ allow(QueueBus).to receive(:generate_uuid).and_return('idfhlkj')
8
9
  end
9
10
  after(:each) do
10
11
  Timecop.return
11
12
  end
12
- let(:bus_attrs) { {"bus_class_proxy"=>"QueueBus::Driver",
13
- "bus_published_at" => Time.now.to_i,
14
- "bus_id"=>"#{Time.now.to_i}-idfhlkj",
15
- "bus_app_hostname" => `hostname 2>&1`.strip.sub(/.local/,'')} }
13
+ let(:bus_attrs) do
14
+ { 'bus_class_proxy' => 'QueueBus::Driver',
15
+ 'bus_published_at' => Time.now.to_i,
16
+ 'bus_id' => "#{Time.now.to_i}-idfhlkj",
17
+ 'bus_app_hostname' => Socket.gethostname }
18
+ end
16
19
 
17
- it "should add it to Redis" do
18
- hash = {:one => 1, "two" => "here", "id" => 12 }
19
- event_name = "event_name"
20
+ it 'should add it to Redis' do
21
+ hash = { :one => 1, 'two' => 'here', 'id' => 12 }
22
+ event_name = 'event_name'
20
23
 
21
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
24
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
22
25
  expect(val).to eq(nil)
23
26
 
24
27
  QueueBus.publish(event_name, hash)
25
28
 
26
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
29
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
27
30
  hash = JSON.parse(val)
28
- expect(hash["class"]).to eq("QueueBus::Worker")
29
- expect(hash["args"].size).to eq(1)
30
- expect(JSON.parse(hash["args"].first)).to eq({"bus_event_type" => event_name, "two"=>"here", "one"=>1, "id" => 12}.merge(bus_attrs))
31
-
31
+ expect(hash['class']).to eq('QueueBus::Worker')
32
+ expect(hash['args'].size).to eq(1)
33
+ expect(JSON.parse(hash['args'].first)).to eq({ 'bus_event_type' => event_name, 'two' => 'here', 'one' => 1, 'id' => 12 }.merge(bus_attrs))
32
34
  end
33
35
 
34
- it "should use the id if given" do
35
- hash = {:one => 1, "two" => "here", "bus_id" => "app-given" }
36
- event_name = "event_name"
36
+ it 'should use the id if given' do
37
+ hash = { :one => 1, 'two' => 'here', 'bus_id' => 'app-given' }
38
+ event_name = 'event_name'
37
39
 
38
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
40
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
39
41
  expect(val).to eq(nil)
40
42
 
41
43
  QueueBus.publish(event_name, hash)
42
44
 
43
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
45
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
44
46
  hash = JSON.parse(val)
45
- expect(hash["class"]).to eq("QueueBus::Worker")
46
- expect(hash["args"].size).to eq(1)
47
- expect(JSON.parse(hash["args"].first)).to eq({"bus_event_type" => event_name, "two"=>"here", "one"=>1}.merge(bus_attrs).merge("bus_id" => 'app-given'))
47
+ expect(hash['class']).to eq('QueueBus::Worker')
48
+ expect(hash['args'].size).to eq(1)
49
+ expect(JSON.parse(hash['args'].first)).to eq({ 'bus_event_type' => event_name, 'two' => 'here', 'one' => 1 }.merge(bus_attrs).merge('bus_id' => 'app-given'))
48
50
  end
49
51
 
50
- it "should add metadata via callback" do
52
+ it 'should add metadata via callback' do
51
53
  myval = 0
52
54
  QueueBus.before_publish = lambda { |att|
53
- att["mine"] = 4
55
+ att['mine'] = 4
54
56
  myval += 1
55
57
  }
56
58
 
57
- hash = {:one => 1, "two" => "here", "bus_id" => "app-given" }
58
- event_name = "event_name"
59
+ hash = { :one => 1, 'two' => 'here', 'bus_id' => 'app-given' }
60
+ event_name = 'event_name'
59
61
 
60
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
62
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
61
63
  expect(val).to eq(nil)
62
64
 
63
65
  QueueBus.publish(event_name, hash)
64
66
 
65
-
66
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
67
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
67
68
  hash = JSON.parse(val)
68
- att = JSON.parse(hash["args"].first)
69
- expect(att["mine"]).to eq(4)
69
+ att = JSON.parse(hash['args'].first)
70
+ expect(att['mine']).to eq(4)
70
71
  expect(myval).to eq(1)
71
72
  end
72
73
 
73
- it "should set the timezone and locale if available" do
74
+ it 'should set the timezone and locale if available' do
74
75
  expect(defined?(I18n)).to be_nil
75
76
  expect(Time.respond_to?(:zone)).to eq(false)
76
77
 
77
- stub_const("I18n", Class.new)
78
- allow(I18n).to receive(:locale).and_return("jp")
78
+ stub_const('I18n', Class.new)
79
+ allow(I18n).to receive(:locale).and_return('jp')
79
80
 
80
- allow(Time).to receive(:zone).and_return(double('zone', :name => "EST"))
81
+ allow(Time).to receive(:zone).and_return(double('zone', name: 'EST'))
81
82
 
82
- hash = {:one => 1, "two" => "here", "bus_id" => "app-given" }
83
- event_name = "event_name"
83
+ hash = { :one => 1, 'two' => 'here', 'bus_id' => 'app-given' }
84
+ event_name = 'event_name'
84
85
 
85
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
86
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
86
87
  expect(val).to eq(nil)
87
88
 
88
89
  QueueBus.publish(event_name, hash)
89
90
 
90
- val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
91
+ val = QueueBus.redis { |redis| redis.lpop('queue:bus_incoming') }
91
92
  hash = JSON.parse(val)
92
- expect(hash["class"]).to eq("QueueBus::Worker")
93
- att = JSON.parse(hash["args"].first)
94
- expect(att["bus_locale"]).to eq("jp")
95
- expect(att["bus_timezone"]).to eq("EST")
93
+ expect(hash['class']).to eq('QueueBus::Worker')
94
+ att = JSON.parse(hash['args'].first)
95
+ expect(att['bus_locale']).to eq('jp')
96
+ expect(att['bus_timezone']).to eq('EST')
96
97
  end
97
-
98
98
  end