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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90bafc8494e8deab2c65a7271a01ec3b67d518d5
4
- data.tar.gz: 542511ae7f22c70929b18460c8aa64f2ba3a403f
3
+ metadata.gz: 05170c91d5faa8833b45609fc7fd9442c39cca84
4
+ data.tar.gz: 4e8cba116cd07d77c8dedfd337daf428e50a36a2
5
5
  SHA512:
6
- metadata.gz: d0cf3f9e3f11847d21bee3fcba83fc009663742f5166648db9f085d3e3e39dd1af14e701cf332f647592c7d9742ab7bc426994fcaf6a12d41837556609f13118
7
- data.tar.gz: e44c7b85e6034e2b79e3b5cfee27c5c4fde21f31323539756be19283a3031c5613ae5ad9242ed869189b3de8b796b53a0e020be7ffa7f14a14018f737869cee8
6
+ metadata.gz: 4ea210df11b807f6cdde82876af7e8fc412fe6dae79cf338402c234322d2cba2b4b2031eed4c1ef8049d38e6806f6d3af0751a6b58aa508be568fa0555130081
7
+ data.tar.gz: 091bce79d7500b27dcf6601a15f97c8cd3698f3dd0b7b66bec370a4677587c435da2e39dbd7a064553a3b8c38c0b5b6c08b60c84b25a0b5b77a5313b6bce5faf
@@ -1,4 +1,4 @@
1
1
  # Gem Version
2
2
  module Rigeon
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
@@ -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
- it 'does something useful' do
9
- expect(false).to eq(true)
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.1.2
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-18 00:00:00.000000000 Z
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.0
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