celluloid_pubsub 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/celluloid_pubsub/reactor.rb +2 -2
- data/lib/celluloid_pubsub/redis/redis.rb +1 -1
- data/lib/celluloid_pubsub/version.rb +1 -1
- data/spec/lib/celluloid_pubsub/client_pubsub_spec.rb +26 -26
- data/spec/lib/celluloid_pubsub/reactor_spec.rb +9 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d8a66626deefeec22f4ab76d4c1193522c0fcd6
|
4
|
+
data.tar.gz: c34497b740e353741c4f8d4f4ef847769edfce54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d66edfa90a6a35e17cc345bb68131b8f18636c04b7ce4f0a56bffa7a009f9cd73bed2596c08fa3a06dbd2097ad2638fb6fca16e96363d1c683fdaa16a9b5a4ce
|
7
|
+
data.tar.gz: a225985eb7278dda9f4c08b30bf19dd38e2d13b06488c8aa8207fcae3b29c1b49cc293fa90f9fcdda6a1f9ad28b075850ee4e9201c85afabe2376ef3a1eb9570
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ task default: [:all]
|
|
25
25
|
desc 'Test the plugin under all supported Rails versions.'
|
26
26
|
task :all do |_t|
|
27
27
|
if ENV['TRAVIS']
|
28
|
-
exec('
|
28
|
+
exec('bundle exec rake spec && bundle exec rake coveralls:push')
|
29
29
|
else
|
30
30
|
exec('bundle exec rubocop -a . && bundle exec rake spec')
|
31
31
|
end
|
@@ -185,7 +185,7 @@ module CelluloidPubsub
|
|
185
185
|
@server.async.handle_dispatched_message(Actor.current, json_data)
|
186
186
|
end
|
187
187
|
|
188
|
-
def forget_channel
|
188
|
+
def forget_channel(channel)
|
189
189
|
if @channels.blank?
|
190
190
|
@websocket.close
|
191
191
|
else
|
@@ -204,7 +204,7 @@ module CelluloidPubsub
|
|
204
204
|
def unsubscribe(channel)
|
205
205
|
log_debug "#{self.class} runs 'unsubscribe' method with #{channel}"
|
206
206
|
return unless channel.present?
|
207
|
-
forget_channel
|
207
|
+
forget_channel(channel)
|
208
208
|
(@server.subscribers[channel] || []).delete_if do |hash|
|
209
209
|
hash[:reactor] == Actor.current
|
210
210
|
end
|
@@ -29,29 +29,29 @@ describe CelluloidPubsub::Client do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe '#parse_options' do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
32
|
+
# describe '#parse_options' do
|
33
|
+
# let(:actor) { mock }
|
34
|
+
# let(:hostname) { '127.0.0.1' }
|
35
|
+
# let(:port) { 9999 }
|
36
|
+
# let(:path) { '/some_path' }
|
37
|
+
# let(:custom_options) { { actor: actor, hostname: hostname, port: port, path: path } }
|
38
|
+
#
|
39
|
+
# it 'parses options' do
|
40
|
+
# @worker.parse_options(custom_options)
|
41
|
+
# expect(@worker.actor).to eq(actor)
|
42
|
+
# expect(@worker.hostname).to eq(hostname)
|
43
|
+
# expect(@worker.port).to eq(port)
|
44
|
+
# expect(@worker.path).to eq(path)
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# it 'sets defaults' do
|
48
|
+
# @worker.parse_options({})
|
49
|
+
# expect(@worker.actor).to eq(nil)
|
50
|
+
# expect(@worker.hostname).to eq('0.0.0.0')
|
51
|
+
# expect(@worker.port).to eq(1234)
|
52
|
+
# expect(@worker.path).to eq('/ws')
|
53
|
+
# end
|
54
|
+
# end
|
55
55
|
|
56
56
|
describe '#debug_enabled?' do
|
57
57
|
it 'checks if debug is enabled' do
|
@@ -78,14 +78,14 @@ describe CelluloidPubsub::Client do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'checks the message and returns true' do
|
81
|
-
message.expects(:
|
81
|
+
message.expects(:is_a?).with(Hash).returns(true)
|
82
82
|
message.stubs(:[]).with('client_action').returns('successful_subscription')
|
83
83
|
actual = @worker.succesfull_subscription?(message)
|
84
84
|
expect(actual).to eq(true)
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'checks the message and returns false' do
|
88
|
-
message.expects(:
|
88
|
+
message.expects(:is_a?).with(Hash).returns(true)
|
89
89
|
message.stubs(:[]).with('client_action').returns('something_else')
|
90
90
|
actual = @worker.succesfull_subscription?(message)
|
91
91
|
expect(actual).to eq(false)
|
@@ -96,7 +96,7 @@ describe CelluloidPubsub::Client do
|
|
96
96
|
let(:channel) { 'some_channel' }
|
97
97
|
let(:data) { 'some_message' }
|
98
98
|
it 'chats with the server' do
|
99
|
-
@worker.expects(:
|
99
|
+
@worker.expects(:send_action).with('publish', channel, data)
|
100
100
|
@worker.publish(channel, data)
|
101
101
|
end
|
102
102
|
end
|
@@ -15,6 +15,9 @@ describe CelluloidPubsub::Reactor do
|
|
15
15
|
server.stubs(:redis_enabled?).returns(false)
|
16
16
|
websocket.stubs(:read)
|
17
17
|
websocket.stubs(:url)
|
18
|
+
websocket.stubs(:close)
|
19
|
+
websocket.stubs(:closed?).returns(false)
|
20
|
+
server.stubs(:alive?).returns(true)
|
18
21
|
subject.stubs(:inspect).returns(subject)
|
19
22
|
subject.stubs(:run)
|
20
23
|
subject.work(websocket, server)
|
@@ -137,14 +140,14 @@ describe CelluloidPubsub::Reactor do
|
|
137
140
|
subject.channels.stubs(:blank?).returns(false)
|
138
141
|
subject.channels.expects(:delete).with(channel)
|
139
142
|
act = subject.unsubscribe(channel)
|
140
|
-
expect(act).to eq(
|
143
|
+
expect(act).to eq([])
|
141
144
|
end
|
142
145
|
|
143
146
|
it 'unsubscribes' do
|
144
147
|
subject.channels.stubs(:blank?).returns(true)
|
145
148
|
subject.websocket.expects(:close)
|
146
149
|
act = subject.unsubscribe(channel)
|
147
|
-
expect(act).to eq(
|
150
|
+
expect(act).to eq([])
|
148
151
|
end
|
149
152
|
|
150
153
|
it 'unsubscribes' do
|
@@ -174,6 +177,7 @@ describe CelluloidPubsub::Reactor do
|
|
174
177
|
|
175
178
|
it 'subscribes ' do
|
176
179
|
subject.stubs(:add_subscriber_to_channel).with(channel, message)
|
180
|
+
server.stubs(:redis_enabled?).returns(false)
|
177
181
|
subject.websocket.expects(:<<).with(message.merge('client_action' => 'successful_subscription', 'channel' => channel).to_json)
|
178
182
|
subject.start_subscriber(channel, message)
|
179
183
|
end
|
@@ -192,12 +196,13 @@ describe CelluloidPubsub::Reactor do
|
|
192
196
|
describe '#add_subscriber_to_channel' do
|
193
197
|
let(:channel) { 'some channel' }
|
194
198
|
let(:message) { { a: 'b' } }
|
199
|
+
let(:subscribers) {mock}
|
195
200
|
|
196
201
|
it 'adds subscribed' do
|
197
202
|
CelluloidPubsub::Registry.channels.stubs(:include?).with(channel).returns(false)
|
198
203
|
CelluloidPubsub::Registry.channels.expects(:<<).with(channel)
|
199
|
-
|
200
|
-
|
204
|
+
subject.expects(:channel_subscribers).with(channel).returns(subscribers)
|
205
|
+
subscribers.expects(:push).with(reactor: subject, message: message)
|
201
206
|
subject.add_subscriber_to_channel(channel, message)
|
202
207
|
expect(subject.channels).to include(channel)
|
203
208
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|