ably-rest 0.8.14 → 0.8.15
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/submodules/ably-ruby/CHANGELOG.md +48 -61
- data/lib/submodules/ably-ruby/README.md +6 -0
- data/lib/submodules/ably-ruby/ably.gemspec +1 -1
- data/lib/submodules/ably-ruby/lib/ably/models/http_paginated_response.rb +90 -0
- data/lib/submodules/ably-ruby/lib/ably/models/paginated_result.rb +5 -0
- data/lib/submodules/ably-ruby/lib/ably/modules/event_emitter.rb +30 -15
- data/lib/submodules/ably-ruby/lib/ably/modules/model_common.rb +25 -0
- data/lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_manager.rb +3 -3
- data/lib/submodules/ably-ruby/lib/ably/realtime/client.rb +13 -0
- data/lib/submodules/ably-ruby/lib/ably/realtime/client/incoming_message_dispatcher.rb +2 -2
- data/lib/submodules/ably-ruby/lib/ably/realtime/presence/members_map.rb +3 -3
- data/lib/submodules/ably-ruby/lib/ably/rest/client.rb +60 -3
- data/lib/submodules/ably-ruby/lib/ably/version.rb +1 -1
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/auth_spec.rb +29 -0
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/channel_spec.rb +8 -6
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/client_spec.rb +52 -0
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/connection_spec.rb +44 -8
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/presence_spec.rb +79 -38
- data/lib/submodules/ably-ruby/spec/acceptance/rest/channel_spec.rb +2 -4
- data/lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb +69 -21
- data/lib/submodules/ably-ruby/spec/acceptance/rest/presence_spec.rb +10 -12
- data/lib/submodules/ably-ruby/spec/unit/models/http_paginated_result_spec.rb +380 -0
- data/lib/submodules/ably-ruby/spec/unit/modules/event_emitter_spec.rb +109 -51
- data/lib/submodules/ably-ruby/spec/unit/realtime/presence_spec.rb +3 -3
- metadata +5 -4
@@ -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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ably-rest
|
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
|
- Matthew O'Riordan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/submodules/ably-ruby/lib/ably/models/connection_details.rb
|
234
234
|
- lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb
|
235
235
|
- lib/submodules/ably-ruby/lib/ably/models/error_info.rb
|
236
|
+
- lib/submodules/ably-ruby/lib/ably/models/http_paginated_response.rb
|
236
237
|
- lib/submodules/ably-ruby/lib/ably/models/idiomatic_ruby_wrapper.rb
|
237
238
|
- lib/submodules/ably-ruby/lib/ably/models/message.rb
|
238
239
|
- lib/submodules/ably-ruby/lib/ably/models/message_encoders/base.rb
|
@@ -344,6 +345,7 @@ files:
|
|
344
345
|
- lib/submodules/ably-ruby/spec/unit/models/connection_details_spec.rb
|
345
346
|
- lib/submodules/ably-ruby/spec/unit/models/connection_state_change_spec.rb
|
346
347
|
- lib/submodules/ably-ruby/spec/unit/models/error_info_spec.rb
|
348
|
+
- lib/submodules/ably-ruby/spec/unit/models/http_paginated_result_spec.rb
|
347
349
|
- lib/submodules/ably-ruby/spec/unit/models/idiomatic_ruby_wrapper_spec.rb
|
348
350
|
- lib/submodules/ably-ruby/spec/unit/models/message_encoders/base64_spec.rb
|
349
351
|
- lib/submodules/ably-ruby/spec/unit/models/message_encoders/cipher_spec.rb
|
@@ -403,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
403
405
|
version: '0'
|
404
406
|
requirements: []
|
405
407
|
rubyforge_project:
|
406
|
-
rubygems_version: 2.4.
|
408
|
+
rubygems_version: 2.4.8
|
407
409
|
signing_key:
|
408
410
|
specification_version: 4
|
409
411
|
summary: A Ruby REST only client library for ably.io realtime messaging
|
@@ -415,4 +417,3 @@ test_files:
|
|
415
417
|
- spec/unit/modules_spec.rb
|
416
418
|
- spec/unit/rest_spec.rb
|
417
419
|
- spec/unit/util_spec.rb
|
418
|
-
has_rdoc:
|