ably 1.1.8 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check.yml +14 -5
  3. data/CHANGELOG.md +48 -0
  4. data/README.md +2 -2
  5. data/UPDATING.md +30 -0
  6. data/ably.gemspec +12 -24
  7. data/lib/ably/auth.rb +8 -8
  8. data/lib/ably/logger.rb +4 -4
  9. data/lib/ably/models/channel_details.rb +59 -0
  10. data/lib/ably/models/channel_metrics.rb +84 -0
  11. data/lib/ably/models/channel_occupancy.rb +43 -0
  12. data/lib/ably/models/channel_options.rb +97 -0
  13. data/lib/ably/models/channel_status.rb +53 -0
  14. data/lib/ably/models/device_details.rb +1 -1
  15. data/lib/ably/models/idiomatic_ruby_wrapper.rb +4 -0
  16. data/lib/ably/models/message.rb +4 -4
  17. data/lib/ably/models/protocol_message.rb +19 -7
  18. data/lib/ably/models/token_details.rb +7 -2
  19. data/lib/ably/models/token_request.rb +1 -1
  20. data/lib/ably/modules/ably.rb +1 -1
  21. data/lib/ably/modules/channels_collection.rb +22 -2
  22. data/lib/ably/modules/conversions.rb +34 -0
  23. data/lib/ably/realtime/auth.rb +2 -2
  24. data/lib/ably/realtime/channel/channel_manager.rb +16 -4
  25. data/lib/ably/realtime/channel/channel_state_machine.rb +5 -0
  26. data/lib/ably/realtime/channel.rb +54 -24
  27. data/lib/ably/realtime/channels.rb +1 -1
  28. data/lib/ably/rest/channel.rb +33 -34
  29. data/lib/ably/rest/client.rb +8 -5
  30. data/lib/ably/rest/middleware/encoder.rb +1 -1
  31. data/lib/ably/rest/middleware/exceptions.rb +1 -1
  32. data/lib/ably/rest/middleware/external_exceptions.rb +1 -1
  33. data/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +1 -1
  34. data/lib/ably/rest/middleware/logger.rb +1 -1
  35. data/lib/ably/rest/middleware/parse_json.rb +1 -1
  36. data/lib/ably/rest/middleware/parse_message_pack.rb +1 -1
  37. data/lib/ably/util/crypto.rb +1 -1
  38. data/lib/ably/version.rb +2 -2
  39. data/spec/acceptance/realtime/channel_spec.rb +247 -21
  40. data/spec/acceptance/realtime/channels_spec.rb +59 -7
  41. data/spec/acceptance/realtime/connection_spec.rb +21 -1
  42. data/spec/acceptance/realtime/message_spec.rb +77 -0
  43. data/spec/acceptance/rest/auth_spec.rb +18 -0
  44. data/spec/acceptance/rest/channel_spec.rb +19 -1
  45. data/spec/acceptance/rest/channels_spec.rb +22 -5
  46. data/spec/acceptance/rest/client_spec.rb +3 -3
  47. data/spec/acceptance/rest/message_spec.rb +61 -3
  48. data/spec/lib/unit/models/channel_options_spec.rb +52 -0
  49. data/spec/run_parallel_tests +2 -7
  50. data/spec/unit/logger_spec.rb +6 -14
  51. data/spec/unit/models/channel_details_spec.rb +30 -0
  52. data/spec/unit/models/channel_metrics_spec.rb +42 -0
  53. data/spec/unit/models/channel_occupancy_spec.rb +17 -0
  54. data/spec/unit/models/channel_status_spec.rb +36 -0
  55. data/spec/unit/models/message_spec.rb +14 -0
  56. data/spec/unit/models/protocol_message_spec.rb +53 -7
  57. data/spec/unit/models/token_details_spec.rb +14 -0
  58. data/spec/unit/realtime/channels_spec.rb +52 -14
  59. data/spec/unit/rest/channels_spec.rb +81 -14
  60. metadata +69 -11
@@ -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) { { 'bizarre' => 'value' } }
7
+ let(:options) do
8
+ { params: { 'bizarre' => 'value' } }
9
+ end
8
10
 
9
11
  subject { Ably::Rest::Channels.new(client) }
10
12
 
11
- context 'creating channels' do
12
- it '#get creates a channel' do
13
- expect(Ably::Rest::Channel).to receive(:new).with(client, channel_name, options)
14
- subject.get(channel_name, options)
15
- end
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
- it '#get will reuse the channel object' do
18
- channel = subject.get(channel_name, options)
19
- expect(channel).to be_a(Ably::Rest::Channel)
20
- expect(subject.get(channel_name, options).object_id).to eql(channel.object_id)
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
- it '[] creates a channel' do
24
- expect(Ably::Rest::Channel).to receive(:new).with(client, channel_name, options)
25
- subject.get(channel_name, options)
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)
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.8
4
+ version: 1.2.2
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: 2022-02-15 00:00:00.000000000 Z
12
+ date: 2022-06-08 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: '8.0'
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: '8.0'
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: '1.0'
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: '1.0'
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,28 @@ dependencies:
171
185
  requirements:
172
186
  - - "~>"
173
187
  - !ruby/object:Gem::Version
174
- version: 3.10.0
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.10.0
195
+ version: 3.11.0
196
+ - !ruby/object:Gem::Dependency
197
+ name: rspec_junit_formatter
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - "~>"
201
+ - !ruby/object:Gem::Version
202
+ version: 0.5.1
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: 0.5.1
182
210
  - !ruby/object:Gem::Dependency
183
211
  name: rspec-retry
184
212
  requirement: !ruby/object:Gem::Requirement
@@ -283,14 +311,14 @@ dependencies:
283
311
  requirements:
284
312
  - - "~>"
285
313
  - !ruby/object:Gem::Version
286
- version: '3.7'
314
+ version: '3.8'
287
315
  type: :development
288
316
  prerelease: false
289
317
  version_requirements: !ruby/object:Gem::Requirement
290
318
  requirements:
291
319
  - - "~>"
292
320
  - !ruby/object:Gem::Version
293
- version: '3.7'
321
+ version: '3.8'
294
322
  - !ruby/object:Gem::Dependency
295
323
  name: pry
296
324
  requirement: !ruby/object:Gem::Requirement
@@ -319,6 +347,20 @@ dependencies:
319
347
  - - "~>"
320
348
  - !ruby/object:Gem::Version
321
349
  version: 3.8.0
350
+ - !ruby/object:Gem::Dependency
351
+ name: webrick
352
+ requirement: !ruby/object:Gem::Requirement
353
+ requirements:
354
+ - - "~>"
355
+ - !ruby/object:Gem::Version
356
+ version: 1.7.0
357
+ type: :development
358
+ prerelease: false
359
+ version_requirements: !ruby/object:Gem::Requirement
360
+ requirements:
361
+ - - "~>"
362
+ - !ruby/object:Gem::Version
363
+ version: 1.7.0
322
364
  description: A Ruby client library for ably.io realtime messaging
323
365
  email:
324
366
  - lewis@lmars.net
@@ -340,6 +382,7 @@ files:
340
382
  - README.md
341
383
  - Rakefile
342
384
  - SPEC.md
385
+ - UPDATING.md
343
386
  - ably.gemspec
344
387
  - lib/ably.rb
345
388
  - lib/ably/agent.rb
@@ -347,7 +390,12 @@ files:
347
390
  - lib/ably/exceptions.rb
348
391
  - lib/ably/logger.rb
349
392
  - lib/ably/models/auth_details.rb
393
+ - lib/ably/models/channel_details.rb
394
+ - lib/ably/models/channel_metrics.rb
395
+ - lib/ably/models/channel_occupancy.rb
396
+ - lib/ably/models/channel_options.rb
350
397
  - lib/ably/models/channel_state_change.rb
398
+ - lib/ably/models/channel_status.rb
351
399
  - lib/ably/models/cipher_params.rb
352
400
  - lib/ably/models/connection_details.rb
353
401
  - lib/ably/models/connection_state_change.rb
@@ -463,6 +511,7 @@ files:
463
511
  - spec/acceptance/rest/push_spec.rb
464
512
  - spec/acceptance/rest/stats_spec.rb
465
513
  - spec/acceptance/rest/time_spec.rb
514
+ - spec/lib/unit/models/channel_options_spec.rb
466
515
  - spec/rspec_config.rb
467
516
  - spec/run_parallel_tests
468
517
  - spec/shared/client_initializer_behaviour.rb
@@ -485,7 +534,11 @@ files:
485
534
  - spec/unit/auth_spec.rb
486
535
  - spec/unit/logger_spec.rb
487
536
  - spec/unit/models/auth_details_spec.rb
537
+ - spec/unit/models/channel_details_spec.rb
538
+ - spec/unit/models/channel_metrics_spec.rb
539
+ - spec/unit/models/channel_occupancy_spec.rb
488
540
  - spec/unit/models/channel_state_change_spec.rb
541
+ - spec/unit/models/channel_status_spec.rb
489
542
  - spec/unit/models/cipher_params_spec.rb
490
543
  - spec/unit/models/connection_details_spec.rb
491
544
  - spec/unit/models/connection_state_change_spec.rb
@@ -548,7 +601,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
548
601
  - !ruby/object:Gem::Version
549
602
  version: '0'
550
603
  requirements: []
551
- rubygems_version: 3.0.3
604
+ rubygems_version: 3.3.14
552
605
  signing_key:
553
606
  specification_version: 4
554
607
  summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
@@ -579,6 +632,7 @@ test_files:
579
632
  - spec/acceptance/rest/push_spec.rb
580
633
  - spec/acceptance/rest/stats_spec.rb
581
634
  - spec/acceptance/rest/time_spec.rb
635
+ - spec/lib/unit/models/channel_options_spec.rb
582
636
  - spec/rspec_config.rb
583
637
  - spec/run_parallel_tests
584
638
  - spec/shared/client_initializer_behaviour.rb
@@ -601,7 +655,11 @@ test_files:
601
655
  - spec/unit/auth_spec.rb
602
656
  - spec/unit/logger_spec.rb
603
657
  - spec/unit/models/auth_details_spec.rb
658
+ - spec/unit/models/channel_details_spec.rb
659
+ - spec/unit/models/channel_metrics_spec.rb
660
+ - spec/unit/models/channel_occupancy_spec.rb
604
661
  - spec/unit/models/channel_state_change_spec.rb
662
+ - spec/unit/models/channel_status_spec.rb
605
663
  - spec/unit/models/cipher_params_spec.rb
606
664
  - spec/unit/models/connection_details_spec.rb
607
665
  - spec/unit/models/connection_state_change_spec.rb