ably 1.1.7 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/check.yml +1 -1
- data/CHANGELOG.md +99 -0
- data/COPYRIGHT +1 -1
- data/README.md +2 -2
- data/SPEC.md +0 -7
- data/UPDATING.md +30 -0
- data/ably.gemspec +11 -24
- data/lib/ably/auth.rb +8 -8
- data/lib/ably/logger.rb +4 -4
- data/lib/ably/models/channel_options.rb +97 -0
- data/lib/ably/models/connection_details.rb +8 -2
- data/lib/ably/models/delta_extras.rb +29 -0
- data/lib/ably/models/device_details.rb +1 -1
- data/lib/ably/models/error_info.rb +6 -2
- data/lib/ably/models/idiomatic_ruby_wrapper.rb +4 -0
- data/lib/ably/models/message.rb +14 -3
- data/lib/ably/models/protocol_message.rb +23 -14
- data/lib/ably/models/token_details.rb +7 -2
- data/lib/ably/models/token_request.rb +1 -1
- data/lib/ably/modules/ably.rb +1 -1
- data/lib/ably/modules/channels_collection.rb +22 -2
- data/lib/ably/modules/conversions.rb +34 -0
- data/lib/ably/realtime/auth.rb +2 -2
- data/lib/ably/realtime/channel/channel_manager.rb +16 -4
- data/lib/ably/realtime/channel/channel_state_machine.rb +10 -1
- data/lib/ably/realtime/channel/publisher.rb +3 -2
- data/lib/ably/realtime/channel.rb +54 -22
- data/lib/ably/realtime/channels.rb +1 -1
- data/lib/ably/realtime/connection/connection_manager.rb +13 -4
- data/lib/ably/realtime/connection/connection_state_machine.rb +4 -0
- data/lib/ably/realtime/connection.rb +0 -3
- data/lib/ably/rest/channel.rb +28 -35
- data/lib/ably/rest/client.rb +23 -8
- data/lib/ably/rest/middleware/encoder.rb +1 -1
- data/lib/ably/rest/middleware/exceptions.rb +1 -1
- data/lib/ably/rest/middleware/external_exceptions.rb +1 -1
- data/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +1 -1
- data/lib/ably/rest/middleware/logger.rb +1 -1
- data/lib/ably/rest/middleware/parse_json.rb +1 -1
- data/lib/ably/rest/middleware/parse_message_pack.rb +1 -1
- data/lib/ably/util/crypto.rb +1 -1
- data/lib/ably/version.rb +2 -2
- data/spec/acceptance/realtime/channel_spec.rb +458 -27
- data/spec/acceptance/realtime/channels_spec.rb +59 -7
- data/spec/acceptance/realtime/connection_failures_spec.rb +56 -1
- data/spec/acceptance/realtime/connection_spec.rb +270 -1
- data/spec/acceptance/realtime/message_spec.rb +77 -0
- data/spec/acceptance/realtime/presence_spec.rb +18 -1
- data/spec/acceptance/rest/auth_spec.rb +18 -0
- data/spec/acceptance/rest/channel_spec.rb +73 -11
- data/spec/acceptance/rest/channels_spec.rb +23 -6
- data/spec/acceptance/rest/client_spec.rb +3 -3
- data/spec/acceptance/rest/message_spec.rb +61 -3
- data/spec/lib/unit/models/channel_options_spec.rb +52 -0
- data/spec/run_parallel_tests +2 -7
- data/spec/support/test_app.rb +1 -1
- data/spec/unit/logger_spec.rb +6 -14
- data/spec/unit/models/delta_extras_spec.rb +14 -0
- data/spec/unit/models/error_info_spec.rb +17 -1
- data/spec/unit/models/message_spec.rb +38 -0
- data/spec/unit/models/protocol_message_spec.rb +77 -27
- data/spec/unit/models/token_details_spec.rb +14 -0
- data/spec/unit/realtime/channel_spec.rb +2 -1
- data/spec/unit/realtime/channels_spec.rb +53 -15
- data/spec/unit/rest/channel_spec.rb +40 -7
- data/spec/unit/rest/channels_spec.rb +81 -14
- data/spec/unit/rest/client_spec.rb +27 -0
- metadata +46 -11
@@ -7,17 +7,14 @@ describe Ably::Rest::Channel do
|
|
7
7
|
'Ably::Rest::Client',
|
8
8
|
encoders: [],
|
9
9
|
post: instance_double('Faraday::Response', status: 201),
|
10
|
-
idempotent_rest_publishing: false,
|
10
|
+
idempotent_rest_publishing: false, max_message_size: max_message_size
|
11
11
|
)
|
12
12
|
end
|
13
13
|
let(:channel_name) { 'unique' }
|
14
|
+
let(:max_message_size) { nil }
|
14
15
|
|
15
16
|
subject { Ably::Rest::Channel.new(client, channel_name) }
|
16
17
|
|
17
|
-
it 'should return Ably::Rest::Channel::MAX_MESSAGE_SIZE equal 65536 (TO3l8)' do
|
18
|
-
expect(Ably::Rest::Channel::MAX_MESSAGE_SIZE).to eq(65536)
|
19
|
-
end
|
20
|
-
|
21
18
|
describe '#initializer' do
|
22
19
|
let(:channel_name) { random_str.encode(encoding) }
|
23
20
|
|
@@ -132,8 +129,44 @@ describe Ably::Rest::Channel do
|
|
132
129
|
end
|
133
130
|
|
134
131
|
context 'max message size exceeded' do
|
135
|
-
|
136
|
-
|
132
|
+
context 'when max_message_size is nil' do
|
133
|
+
context 'and a message size is 65537 bytes' do
|
134
|
+
it 'should raise Ably::Exceptions::MaxMessageSizeExceeded' do
|
135
|
+
expect { subject.publish('x' * 65537, 'data') }.to raise_error Ably::Exceptions::MaxMessageSizeExceeded
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when max_message_size is 65536 bytes' do
|
141
|
+
let(:max_message_size) { 65536 }
|
142
|
+
|
143
|
+
context 'and a message size is 65537 bytes' do
|
144
|
+
it 'should raise Ably::Exceptions::MaxMessageSizeExceeded' do
|
145
|
+
expect { subject.publish('x' * 65537, 'data') }.to raise_error Ably::Exceptions::MaxMessageSizeExceeded
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'and a message size is 10 bytes' do
|
150
|
+
it 'should send a message' do
|
151
|
+
expect(subject.publish('x' * 10, 'data')).to eq(true)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'when max_message_size is 10 bytes' do
|
157
|
+
let(:max_message_size) { 10 }
|
158
|
+
|
159
|
+
context 'and a message size is 11 bytes' do
|
160
|
+
it 'should raise Ably::Exceptions::MaxMessageSizeExceeded' do
|
161
|
+
expect { subject.publish('x' * 11, 'data') }.to raise_error Ably::Exceptions::MaxMessageSizeExceeded
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'and a message size is 2 bytes' do
|
166
|
+
it 'should send a message' do
|
167
|
+
expect(subject.publish('x' * 2, 'data')).to eq(true)
|
168
|
+
end
|
169
|
+
end
|
137
170
|
end
|
138
171
|
end
|
139
172
|
end
|
@@ -2,30 +2,97 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Ably::Rest::Channels do
|
5
|
-
let(:client) { instance_double('Ably::Rest::Client') }
|
5
|
+
let(:client) { instance_double('Ably::Rest::Client', logger: double('logger').as_null_object) }
|
6
6
|
let(:channel_name) { 'unique'.encode(Encoding::UTF_8) }
|
7
|
-
let(:options)
|
7
|
+
let(:options) do
|
8
|
+
{ params: { 'bizarre' => 'value' } }
|
9
|
+
end
|
8
10
|
|
9
11
|
subject { Ably::Rest::Channels.new(client) }
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
describe '#get' do
|
14
|
+
context "when channel doesn't exist" do
|
15
|
+
shared_examples 'creates a channel' do
|
16
|
+
it 'creates a channel (RSN3a)' do
|
17
|
+
expect(Ably::Rest::Channel).to receive(:new).with(client, channel_name, options)
|
18
|
+
subject.get(channel_name, options)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
describe 'hash' do
|
23
|
+
let(:channel_options) { options }
|
24
|
+
it { expect(channel_options).to be_a(Hash) }
|
25
|
+
|
26
|
+
include_examples 'creates a channel'
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'ChannelOptions object' do
|
30
|
+
let(:channel_options) { Ably::Models::ChannelOptions.new(options) }
|
31
|
+
it { expect(channel_options).to be_a(Ably::Models::ChannelOptions) }
|
32
|
+
|
33
|
+
include_examples 'creates a channel'
|
34
|
+
end
|
21
35
|
end
|
22
36
|
|
23
|
-
|
24
|
-
|
25
|
-
|
37
|
+
context 'when an existing channel exists' do
|
38
|
+
shared_examples 'reuse a channel object if it exists' do
|
39
|
+
it 'will reuse a channel object if it exists (RSN3a)' do
|
40
|
+
channel = subject.get(channel_name, channel_options)
|
41
|
+
expect(channel).to be_a(Ably::Rest::Channel)
|
42
|
+
expect(subject.get(channel_name, channel_options).object_id).to eql(channel.object_id)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'hash' do
|
47
|
+
let(:channel_options) { options }
|
48
|
+
it { expect(channel_options).to be_a(Hash) }
|
49
|
+
|
50
|
+
include_examples 'reuse a channel object if it exists'
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'ChannelOptions object' do
|
54
|
+
let(:channel_options) { Ably::Models::ChannelOptions.new(options) }
|
55
|
+
it { expect(channel_options).to be_a(Ably::Models::ChannelOptions) }
|
56
|
+
|
57
|
+
include_examples 'reuse a channel object if it exists'
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with new channel_options modes' do
|
61
|
+
shared_examples 'update channel with provided options :modes' do
|
62
|
+
it 'will update channel with provided options modes (RSN3c)' do
|
63
|
+
channel = subject.get(channel_name, channel_options)
|
64
|
+
expect(channel.options.modes).to eq(modes)
|
65
|
+
|
66
|
+
subject.get(channel_name, channel_options)
|
67
|
+
expect(channel.options.modes).to eq(modes)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
let(:modes) { %i[subscribe] }
|
72
|
+
let(:new_options) { { modes: modes } }
|
73
|
+
|
74
|
+
describe 'hash' do
|
75
|
+
let(:channel_options) { new_options }
|
76
|
+
it { expect(channel_options).to be_a(Hash) }
|
77
|
+
|
78
|
+
include_examples 'update channel with provided options :modes'
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'ChannelOptions object' do
|
82
|
+
let(:channel_options) { Ably::Models::ChannelOptions.new(new_options) }
|
83
|
+
it { expect(channel_options).to be_a(Ably::Models::ChannelOptions) }
|
84
|
+
|
85
|
+
include_examples 'update channel with provided options :modes'
|
86
|
+
end
|
87
|
+
end
|
26
88
|
end
|
27
89
|
end
|
28
90
|
|
91
|
+
it '[] creates a channel' do
|
92
|
+
expect(Ably::Rest::Channel).to receive(:new).with(client, channel_name, options)
|
93
|
+
subject.get(channel_name, options)
|
94
|
+
end
|
95
|
+
|
29
96
|
context '#fetch' do
|
30
97
|
it 'retrieves a channel if it exists' do
|
31
98
|
channel = subject.get(channel_name, options)
|
@@ -87,6 +87,33 @@ describe Ably::Rest::Client do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
context 'max_message_size' do
|
92
|
+
context 'is not present' do
|
93
|
+
let(:client_options) { { key: 'appid.keyuid:keysecret' } }
|
94
|
+
|
95
|
+
it 'should return default 65536 (#TO3l8)' do
|
96
|
+
expect(subject.max_message_size).to eq(Ably::Rest::Client::MAX_MESSAGE_SIZE)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'is nil' do
|
101
|
+
let(:client_options) { { key: 'appid.keyuid:keysecret', max_message_size: nil } }
|
102
|
+
|
103
|
+
it 'should return default 65536 (#TO3l8)' do
|
104
|
+
expect(Ably::Rest::Client::MAX_MESSAGE_SIZE).to eq(65536)
|
105
|
+
expect(subject.max_message_size).to eq(Ably::Rest::Client::MAX_MESSAGE_SIZE)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'is customized 131072 bytes' do
|
110
|
+
let(:client_options) { { key: 'appid.keyuid:keysecret', max_message_size: 131072 } }
|
111
|
+
|
112
|
+
it 'should return 131072' do
|
113
|
+
expect(subject.max_message_size).to eq(131072)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
90
117
|
end
|
91
118
|
|
92
119
|
context 'request_id generation' 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: 1.1
|
4
|
+
version: 1.2.1
|
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: 2022-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -45,28 +45,42 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '9.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '9.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: faraday
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '2.2'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '2.2'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: faraday-typhoeus
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.2.0
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.2.0
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: typhoeus
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,14 +185,14 @@ dependencies:
|
|
171
185
|
requirements:
|
172
186
|
- - "~>"
|
173
187
|
- !ruby/object:Gem::Version
|
174
|
-
version: 3.
|
188
|
+
version: 3.11.0
|
175
189
|
type: :development
|
176
190
|
prerelease: false
|
177
191
|
version_requirements: !ruby/object:Gem::Requirement
|
178
192
|
requirements:
|
179
193
|
- - "~>"
|
180
194
|
- !ruby/object:Gem::Version
|
181
|
-
version: 3.
|
195
|
+
version: 3.11.0
|
182
196
|
- !ruby/object:Gem::Dependency
|
183
197
|
name: rspec-retry
|
184
198
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,14 +297,14 @@ dependencies:
|
|
283
297
|
requirements:
|
284
298
|
- - "~>"
|
285
299
|
- !ruby/object:Gem::Version
|
286
|
-
version: '3.
|
300
|
+
version: '3.8'
|
287
301
|
type: :development
|
288
302
|
prerelease: false
|
289
303
|
version_requirements: !ruby/object:Gem::Requirement
|
290
304
|
requirements:
|
291
305
|
- - "~>"
|
292
306
|
- !ruby/object:Gem::Version
|
293
|
-
version: '3.
|
307
|
+
version: '3.8'
|
294
308
|
- !ruby/object:Gem::Dependency
|
295
309
|
name: pry
|
296
310
|
requirement: !ruby/object:Gem::Requirement
|
@@ -319,6 +333,20 @@ dependencies:
|
|
319
333
|
- - "~>"
|
320
334
|
- !ruby/object:Gem::Version
|
321
335
|
version: 3.8.0
|
336
|
+
- !ruby/object:Gem::Dependency
|
337
|
+
name: webrick
|
338
|
+
requirement: !ruby/object:Gem::Requirement
|
339
|
+
requirements:
|
340
|
+
- - "~>"
|
341
|
+
- !ruby/object:Gem::Version
|
342
|
+
version: 1.7.0
|
343
|
+
type: :development
|
344
|
+
prerelease: false
|
345
|
+
version_requirements: !ruby/object:Gem::Requirement
|
346
|
+
requirements:
|
347
|
+
- - "~>"
|
348
|
+
- !ruby/object:Gem::Version
|
349
|
+
version: 1.7.0
|
322
350
|
description: A Ruby client library for ably.io realtime messaging
|
323
351
|
email:
|
324
352
|
- lewis@lmars.net
|
@@ -340,6 +368,7 @@ files:
|
|
340
368
|
- README.md
|
341
369
|
- Rakefile
|
342
370
|
- SPEC.md
|
371
|
+
- UPDATING.md
|
343
372
|
- ably.gemspec
|
344
373
|
- lib/ably.rb
|
345
374
|
- lib/ably/agent.rb
|
@@ -347,10 +376,12 @@ files:
|
|
347
376
|
- lib/ably/exceptions.rb
|
348
377
|
- lib/ably/logger.rb
|
349
378
|
- lib/ably/models/auth_details.rb
|
379
|
+
- lib/ably/models/channel_options.rb
|
350
380
|
- lib/ably/models/channel_state_change.rb
|
351
381
|
- lib/ably/models/cipher_params.rb
|
352
382
|
- lib/ably/models/connection_details.rb
|
353
383
|
- lib/ably/models/connection_state_change.rb
|
384
|
+
- lib/ably/models/delta_extras.rb
|
354
385
|
- lib/ably/models/device_details.rb
|
355
386
|
- lib/ably/models/device_push_details.rb
|
356
387
|
- lib/ably/models/error_info.rb
|
@@ -462,6 +493,7 @@ files:
|
|
462
493
|
- spec/acceptance/rest/push_spec.rb
|
463
494
|
- spec/acceptance/rest/stats_spec.rb
|
464
495
|
- spec/acceptance/rest/time_spec.rb
|
496
|
+
- spec/lib/unit/models/channel_options_spec.rb
|
465
497
|
- spec/rspec_config.rb
|
466
498
|
- spec/run_parallel_tests
|
467
499
|
- spec/shared/client_initializer_behaviour.rb
|
@@ -488,6 +520,7 @@ files:
|
|
488
520
|
- spec/unit/models/cipher_params_spec.rb
|
489
521
|
- spec/unit/models/connection_details_spec.rb
|
490
522
|
- spec/unit/models/connection_state_change_spec.rb
|
523
|
+
- spec/unit/models/delta_extras_spec.rb
|
491
524
|
- spec/unit/models/device_details_spec.rb
|
492
525
|
- spec/unit/models/device_push_details_spec.rb
|
493
526
|
- spec/unit/models/error_info_spec.rb
|
@@ -546,7 +579,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
546
579
|
- !ruby/object:Gem::Version
|
547
580
|
version: '0'
|
548
581
|
requirements: []
|
549
|
-
rubygems_version: 3.
|
582
|
+
rubygems_version: 3.3.14
|
550
583
|
signing_key:
|
551
584
|
specification_version: 4
|
552
585
|
summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
|
@@ -577,6 +610,7 @@ test_files:
|
|
577
610
|
- spec/acceptance/rest/push_spec.rb
|
578
611
|
- spec/acceptance/rest/stats_spec.rb
|
579
612
|
- spec/acceptance/rest/time_spec.rb
|
613
|
+
- spec/lib/unit/models/channel_options_spec.rb
|
580
614
|
- spec/rspec_config.rb
|
581
615
|
- spec/run_parallel_tests
|
582
616
|
- spec/shared/client_initializer_behaviour.rb
|
@@ -603,6 +637,7 @@ test_files:
|
|
603
637
|
- spec/unit/models/cipher_params_spec.rb
|
604
638
|
- spec/unit/models/connection_details_spec.rb
|
605
639
|
- spec/unit/models/connection_state_change_spec.rb
|
640
|
+
- spec/unit/models/delta_extras_spec.rb
|
606
641
|
- spec/unit/models/device_details_spec.rb
|
607
642
|
- spec/unit/models/device_push_details_spec.rb
|
608
643
|
- spec/unit/models/error_info_spec.rb
|