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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a4a15beb803aecb5a661e0d835229a61683f1b5
4
- data.tar.gz: 5581259a03bf295aba3115c189dee1bb9309820f
3
+ metadata.gz: 0d8a66626deefeec22f4ab76d4c1193522c0fcd6
4
+ data.tar.gz: c34497b740e353741c4f8d4f4ef847769edfce54
5
5
  SHA512:
6
- metadata.gz: a4f197756c1df59a29f911bae49eabc9776cdf00d19853b37828af4cd7f59378d9427e8770bf7badf95ef1791a445956410963914fdb801c1aff629ce01cd03c
7
- data.tar.gz: 4d0c016688b4ad1f203149aa5be2da0994b49060014dba519fb8a7ed6abbe6944c0b6b54fbcf36f28864e1684f8ec89282be1881b0db68ca9e28194f1dc9b90b
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(' bundle exec rubocop . && bundle exec rake spec && bundle exec rake coveralls:push')
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
@@ -22,7 +22,7 @@ module CelluloidPubsub
22
22
 
23
23
  def run_the_eventmachine(&block)
24
24
  EM.run do
25
- @connection = EM::Hiredis.connect
25
+ @connection ||= EM::Hiredis.connect
26
26
  @connected = true
27
27
  block.call @connection
28
28
  end
@@ -17,7 +17,7 @@ module CelluloidPubsub
17
17
  # minor release version
18
18
  MINOR = 3
19
19
  # tiny release version
20
- TINY = 2
20
+ TINY = 3
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
@@ -29,29 +29,29 @@ describe CelluloidPubsub::Client do
29
29
  end
30
30
  end
31
31
 
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
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(:present?).returns(true)
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(:present?).returns(true)
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(:chat).with('client_action' => 'publish', 'channel' => channel, 'data' => data)
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(nil)
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(nil)
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
- server.subscribers[channel] = []
200
- server.subscribers[channel].expects(:<<).with(reactor: subject, message: message)
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.2
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-29 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid