rigeon 0.1.2 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/rigeon/version.rb +1 -1
- data/spec/rigeon/publisher_spec.rb +15 -0
- data/spec/rigeon/subscriber_spec.rb +39 -0
- data/spec/rigeon_spec.rb +4 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05170c91d5faa8833b45609fc7fd9442c39cca84
|
4
|
+
data.tar.gz: 4e8cba116cd07d77c8dedfd337daf428e50a36a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ea210df11b807f6cdde82876af7e8fc412fe6dae79cf338402c234322d2cba2b4b2031eed4c1ef8049d38e6806f6d3af0751a6b58aa508be568fa0555130081
|
7
|
+
data.tar.gz: 091bce79d7500b27dcf6601a15f97c8cd3698f3dd0b7b66bec370a4677587c435da2e39dbd7a064553a3b8c38c0b5b6c08b60c84b25a0b5b77a5313b6bce5faf
|
data/lib/rigeon/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rigeon::Publisher do
|
4
|
+
class DummyPublisher
|
5
|
+
include Rigeon::Publisher
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#publish' do
|
9
|
+
it 'publishs message to channel' do
|
10
|
+
expect_any_instance_of(Redis).to receive(:publish)
|
11
|
+
.with('channel', 'message'.to_json)
|
12
|
+
DummyPublisher.new.publish('channel', 'message')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rigeon::Publisher do
|
4
|
+
class DummyPublisher
|
5
|
+
include Rigeon::Publisher
|
6
|
+
end
|
7
|
+
|
8
|
+
class DummySubscriber
|
9
|
+
include Rigeon::Subscriber
|
10
|
+
def callback(message)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#subscribe' do
|
15
|
+
it 'subscribes to specific channels' do
|
16
|
+
expect_any_instance_of(Redis).to receive(:subscribe).with('channel')
|
17
|
+
expect_any_instance_of(Redis).not_to receive(:subscribe).with('_')
|
18
|
+
|
19
|
+
DummySubscriber.new.subscribe('channel', :callback)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'calls `callback` on message received' do
|
23
|
+
event = double()
|
24
|
+
payload = { 'k' => 'v' }
|
25
|
+
|
26
|
+
allow(event).to receive(:message).and_yield 'channel', payload.to_json
|
27
|
+
allow_any_instance_of(Redis).to\
|
28
|
+
receive(:subscribe).with('channel').and_yield event
|
29
|
+
|
30
|
+
expect_any_instance_of(DummySubscriber).to\
|
31
|
+
receive(:callback).with(payload)
|
32
|
+
|
33
|
+
DummySubscriber.new.subscribe 'channel', :callback
|
34
|
+
|
35
|
+
allow_any_instance_of(Redis).to receive(:publish)
|
36
|
+
DummyPublisher.new.publish 'channel', payload
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/rigeon_spec.rb
CHANGED
@@ -5,7 +5,9 @@ describe Rigeon do
|
|
5
5
|
expect(Rigeon::VERSION).not_to be nil
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
describe '.client' do
|
9
|
+
it 'creates more than one Redis client' do
|
10
|
+
expect(Rigeon.client).not_to eq Rigeon.client
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rigeon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Abdel-Razzak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -147,6 +147,8 @@ files:
|
|
147
147
|
- lib/rigeon/publisher.rb
|
148
148
|
- lib/rigeon/subscriber.rb
|
149
149
|
- lib/rigeon/version.rb
|
150
|
+
- spec/rigeon/publisher_spec.rb
|
151
|
+
- spec/rigeon/subscriber_spec.rb
|
150
152
|
- spec/rigeon_spec.rb
|
151
153
|
- spec/spec_helper.rb
|
152
154
|
homepage: https://github.com/artmees/rigeon
|
@@ -169,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
171
|
version: '0'
|
170
172
|
requirements: []
|
171
173
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.5.
|
174
|
+
rubygems_version: 2.4.5.1
|
173
175
|
signing_key:
|
174
176
|
specification_version: 4
|
175
177
|
summary: wrapper for implementing PUB/SUB pattern across distributed system
|