ably 0.8.14 → 0.8.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -61
- data/README.md +6 -0
- data/ably.gemspec +1 -1
- data/lib/ably/models/http_paginated_response.rb +90 -0
- data/lib/ably/models/paginated_result.rb +5 -0
- data/lib/ably/modules/event_emitter.rb +30 -15
- data/lib/ably/modules/model_common.rb +25 -0
- data/lib/ably/realtime/channel/channel_manager.rb +3 -3
- data/lib/ably/realtime/client.rb +13 -0
- data/lib/ably/realtime/client/incoming_message_dispatcher.rb +2 -2
- data/lib/ably/realtime/presence/members_map.rb +3 -3
- data/lib/ably/rest/client.rb +60 -3
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/realtime/auth_spec.rb +29 -0
- data/spec/acceptance/realtime/channel_spec.rb +8 -6
- data/spec/acceptance/realtime/client_spec.rb +52 -0
- data/spec/acceptance/realtime/connection_spec.rb +44 -8
- data/spec/acceptance/realtime/presence_spec.rb +79 -38
- data/spec/acceptance/rest/channel_spec.rb +2 -4
- data/spec/acceptance/rest/client_spec.rb +69 -21
- data/spec/acceptance/rest/presence_spec.rb +10 -12
- data/spec/unit/models/http_paginated_result_spec.rb +380 -0
- data/spec/unit/modules/event_emitter_spec.rb +109 -51
- data/spec/unit/realtime/presence_spec.rb +3 -3
- metadata +10 -8
@@ -128,17 +128,34 @@ describe Ably::Modules::EventEmitter do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
context '#on' do
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
context 'with event specified' do
|
132
|
+
it 'calls the block every time an event is emitted only' do
|
133
|
+
block_called = 0
|
134
|
+
subject.on('event') { block_called += 1 }
|
135
|
+
3.times { subject.emit 'event', 'data' }
|
136
|
+
expect(block_called).to eql(3)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'catches exceptions in the provided block, logs the error and continues' do
|
140
|
+
expect(subject.logger).to receive(:error).with(/Intentional exception/)
|
141
|
+
subject.on(:event) { raise 'Intentional exception' }
|
142
|
+
subject.emit :event
|
143
|
+
end
|
136
144
|
end
|
137
145
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
146
|
+
context 'with no event specified' do
|
147
|
+
it 'calls the block every time an event is emitted only' do
|
148
|
+
block_called = 0
|
149
|
+
subject.on { block_called += 1 }
|
150
|
+
3.times { subject.emit 'event', 'data' }
|
151
|
+
expect(block_called).to eql(3)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'catches exceptions in the provided block, logs the error and continues' do
|
155
|
+
expect(subject.logger).to receive(:error).with(/Intentional exception/)
|
156
|
+
subject.on { raise 'Intentional exception' }
|
157
|
+
subject.emit :event
|
158
|
+
end
|
142
159
|
end
|
143
160
|
end
|
144
161
|
|
@@ -157,25 +174,50 @@ describe Ably::Modules::EventEmitter do
|
|
157
174
|
end
|
158
175
|
|
159
176
|
context '#once' do
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
177
|
+
context 'with event specified' do
|
178
|
+
it 'calls the block the first time an event is emitted only' do
|
179
|
+
block_called = 0
|
180
|
+
subject.once('event') { block_called += 1 }
|
181
|
+
3.times { subject.emit 'event', 'data' }
|
182
|
+
expect(block_called).to eql(1)
|
183
|
+
end
|
166
184
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
185
|
+
it 'does not remove other blocks after it is called' do
|
186
|
+
block_called = 0
|
187
|
+
subject.once('event') { block_called += 1 }
|
188
|
+
subject.on('event') { block_called += 1 }
|
189
|
+
3.times { subject.emit 'event', 'data' }
|
190
|
+
expect(block_called).to eql(4)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'catches exceptions in the provided block, logs the error and continues' do
|
194
|
+
expect(subject.logger).to receive(:error).with(/Intentional exception/)
|
195
|
+
subject.once(:event) { raise 'Intentional exception' }
|
196
|
+
subject.emit :event
|
197
|
+
end
|
173
198
|
end
|
174
199
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
200
|
+
context 'with no event specified' do
|
201
|
+
it 'calls the block the first time an event is emitted only' do
|
202
|
+
block_called = 0
|
203
|
+
subject.once { block_called += 1 }
|
204
|
+
3.times { subject.emit 'event', 'data' }
|
205
|
+
expect(block_called).to eql(1)
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'does not remove other blocks after it is called' do
|
209
|
+
block_called = 0
|
210
|
+
subject.once { block_called += 1 }
|
211
|
+
subject.on { block_called += 1 }
|
212
|
+
3.times { subject.emit 'event', 'data' }
|
213
|
+
expect(block_called).to eql(4)
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'catches exceptions in the provided block, logs the error and continues' do
|
217
|
+
expect(subject.logger).to receive(:error).with(/Intentional exception/)
|
218
|
+
subject.once { raise 'Intentional exception' }
|
219
|
+
subject.emit :event
|
220
|
+
end
|
179
221
|
end
|
180
222
|
end
|
181
223
|
|
@@ -196,41 +238,57 @@ describe Ably::Modules::EventEmitter do
|
|
196
238
|
context '#off' do
|
197
239
|
let(:callback) { Proc.new { |msg| obj.received_message msg } }
|
198
240
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
after do
|
204
|
-
subject.emit :message, msg
|
205
|
-
end
|
241
|
+
context 'with event specified in on handler' do
|
242
|
+
before do
|
243
|
+
subject.on(:message, &callback)
|
244
|
+
end
|
206
245
|
|
207
|
-
|
208
|
-
|
209
|
-
expect(obj).to_not receive(:received_message).with(msg)
|
210
|
-
subject.off(:message, &callback)
|
246
|
+
after do
|
247
|
+
subject.emit :message, msg
|
211
248
|
end
|
212
249
|
|
213
|
-
|
214
|
-
|
215
|
-
|
250
|
+
context 'with event names as arguments' do
|
251
|
+
it 'deletes matching callbacks' do
|
252
|
+
expect(obj).to_not receive(:received_message).with(msg)
|
253
|
+
subject.off(:message, &callback)
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'deletes all callbacks if not block given' do
|
257
|
+
expect(obj).to_not receive(:received_message).with(msg)
|
258
|
+
subject.off(:message)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'continues if the block does not exist' do
|
262
|
+
expect(obj).to receive(:received_message).with(msg)
|
263
|
+
subject.off(:message) { true }
|
264
|
+
end
|
216
265
|
end
|
217
266
|
|
218
|
-
|
219
|
-
|
220
|
-
|
267
|
+
context 'without any event names' do
|
268
|
+
it 'deletes all matching callbacks' do
|
269
|
+
expect(obj).to_not receive(:received_message).with(msg)
|
270
|
+
subject.off(&callback)
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'deletes all callbacks if not block given' do
|
274
|
+
expect(obj).to_not receive(:received_message).with(msg)
|
275
|
+
subject.off
|
276
|
+
end
|
221
277
|
end
|
222
278
|
end
|
223
279
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
280
|
+
it 'removes handler added with no event specified' do
|
281
|
+
subject.on(&callback)
|
282
|
+
expect(obj).to_not receive(:received_message).with(msg)
|
283
|
+
subject.off(&callback)
|
284
|
+
subject.emit :message, msg
|
285
|
+
end
|
229
286
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
287
|
+
it 'leaves handler when event specified' do
|
288
|
+
subject.on(&callback)
|
289
|
+
expect(obj).to receive(:received_message).with(msg)
|
290
|
+
subject.off(:foo, &callback)
|
291
|
+
subject.emit :message, msg
|
234
292
|
end
|
235
293
|
end
|
236
294
|
end
|
@@ -49,13 +49,13 @@ describe Ably::Realtime::Presence do
|
|
49
49
|
let(:message_history) { Hash.new { |hash, key| hash[key] = 0 } }
|
50
50
|
let(:enter_action) { Ably::Models::PresenceMessage::ACTION.Enter }
|
51
51
|
let(:enter_message) do
|
52
|
-
instance_double('Ably::Models::PresenceMessage', action: enter_action, connection_id: random_str, decode: true, member_key: random_str)
|
52
|
+
instance_double('Ably::Models::PresenceMessage', action: enter_action, connection_id: random_str, decode: true, member_key: random_str, to_safe_json: true)
|
53
53
|
end
|
54
54
|
let(:leave_message) do
|
55
|
-
instance_double('Ably::Models::PresenceMessage', action: Ably::Models::PresenceMessage::ACTION.Leave, connection_id: random_str, decode: true, member_key: random_str)
|
55
|
+
instance_double('Ably::Models::PresenceMessage', action: Ably::Models::PresenceMessage::ACTION.Leave, connection_id: random_str, decode: true, member_key: random_str, to_safe_json: true)
|
56
56
|
end
|
57
57
|
let(:update_message) do
|
58
|
-
instance_double('Ably::Models::PresenceMessage', action: Ably::Models::PresenceMessage::ACTION.Update, connection_id: random_str, decode: true, member_key: random_str)
|
58
|
+
instance_double('Ably::Models::PresenceMessage', action: Ably::Models::PresenceMessage::ACTION.Update, connection_id: random_str, decode: true, member_key: random_str, to_safe_json: true)
|
59
59
|
end
|
60
60
|
|
61
61
|
context '#subscribe' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ably
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lewis Marshall
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -211,16 +211,16 @@ dependencies:
|
|
211
211
|
name: webmock
|
212
212
|
requirement: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
|
-
- - "
|
214
|
+
- - "~>"
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
216
|
+
version: 2.3.0
|
217
217
|
type: :development
|
218
218
|
prerelease: false
|
219
219
|
version_requirements: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
|
-
- - "
|
221
|
+
- - "~>"
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
223
|
+
version: 2.3.0
|
224
224
|
- !ruby/object:Gem::Dependency
|
225
225
|
name: coveralls
|
226
226
|
requirement: !ruby/object:Gem::Requirement
|
@@ -291,6 +291,7 @@ files:
|
|
291
291
|
- lib/ably/models/connection_details.rb
|
292
292
|
- lib/ably/models/connection_state_change.rb
|
293
293
|
- lib/ably/models/error_info.rb
|
294
|
+
- lib/ably/models/http_paginated_response.rb
|
294
295
|
- lib/ably/models/idiomatic_ruby_wrapper.rb
|
295
296
|
- lib/ably/models/message.rb
|
296
297
|
- lib/ably/models/message_encoders/base.rb
|
@@ -402,6 +403,7 @@ files:
|
|
402
403
|
- spec/unit/models/connection_details_spec.rb
|
403
404
|
- spec/unit/models/connection_state_change_spec.rb
|
404
405
|
- spec/unit/models/error_info_spec.rb
|
406
|
+
- spec/unit/models/http_paginated_result_spec.rb
|
405
407
|
- spec/unit/models/idiomatic_ruby_wrapper_spec.rb
|
406
408
|
- spec/unit/models/message_encoders/base64_spec.rb
|
407
409
|
- spec/unit/models/message_encoders/cipher_spec.rb
|
@@ -454,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
454
456
|
version: '0'
|
455
457
|
requirements: []
|
456
458
|
rubyforge_project:
|
457
|
-
rubygems_version: 2.
|
459
|
+
rubygems_version: 2.6.8
|
458
460
|
signing_key:
|
459
461
|
specification_version: 4
|
460
462
|
summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
|
@@ -503,6 +505,7 @@ test_files:
|
|
503
505
|
- spec/unit/models/connection_details_spec.rb
|
504
506
|
- spec/unit/models/connection_state_change_spec.rb
|
505
507
|
- spec/unit/models/error_info_spec.rb
|
508
|
+
- spec/unit/models/http_paginated_result_spec.rb
|
506
509
|
- spec/unit/models/idiomatic_ruby_wrapper_spec.rb
|
507
510
|
- spec/unit/models/message_encoders/base64_spec.rb
|
508
511
|
- spec/unit/models/message_encoders/cipher_spec.rb
|
@@ -535,4 +538,3 @@ test_files:
|
|
535
538
|
- spec/unit/rest/rest_spec.rb
|
536
539
|
- spec/unit/util/crypto_spec.rb
|
537
540
|
- spec/unit/util/pub_sub_spec.rb
|
538
|
-
has_rdoc:
|