ably 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/.rspec_parallel +3 -0
  3. data/.github/workflows/check.yml +13 -2
  4. data/.github/workflows/docs.yml +36 -0
  5. data/CHANGELOG.md +18 -0
  6. data/INTRO.md +14 -0
  7. data/lib/ably/auth.rb +26 -23
  8. data/lib/ably/models/auth_details.rb +9 -6
  9. data/lib/ably/models/channel_details.rb +15 -5
  10. data/lib/ably/models/channel_metrics.rb +31 -8
  11. data/lib/ably/models/channel_occupancy.rb +10 -3
  12. data/lib/ably/models/channel_options.rb +26 -3
  13. data/lib/ably/models/channel_state_change.rb +45 -15
  14. data/lib/ably/models/channel_status.rb +14 -4
  15. data/lib/ably/models/cipher_params.rb +36 -13
  16. data/lib/ably/models/connection_details.rb +91 -10
  17. data/lib/ably/models/connection_state_change.rb +54 -15
  18. data/lib/ably/models/delta_extras.rb +6 -7
  19. data/lib/ably/models/device_details.rb +60 -21
  20. data/lib/ably/models/device_push_details.rb +27 -19
  21. data/lib/ably/models/error_info.rb +59 -17
  22. data/lib/ably/models/http_paginated_response.rb +27 -5
  23. data/lib/ably/models/idiomatic_ruby_wrapper.rb +3 -2
  24. data/lib/ably/models/message.rb +64 -24
  25. data/lib/ably/models/message_encoders/base.rb +6 -0
  26. data/lib/ably/models/paginated_result.rb +29 -14
  27. data/lib/ably/models/presence_message.rb +72 -22
  28. data/lib/ably/models/protocol_message.rb +0 -4
  29. data/lib/ably/models/push_channel_subscription.rb +40 -15
  30. data/lib/ably/models/stats.rb +76 -40
  31. data/lib/ably/models/stats_types.rb +16 -40
  32. data/lib/ably/models/token_details.rb +34 -12
  33. data/lib/ably/models/token_request.rb +63 -2
  34. data/lib/ably/modules/async_wrapper.rb +1 -0
  35. data/lib/ably/modules/enum.rb +2 -0
  36. data/lib/ably/modules/event_emitter.rb +14 -1
  37. data/lib/ably/modules/model_common.rb +5 -0
  38. data/lib/ably/modules/state_emitter.rb +2 -0
  39. data/lib/ably/modules/state_machine.rb +4 -0
  40. data/lib/ably/realtime/channel/channel_properties.rb +9 -2
  41. data/lib/ably/realtime/channel/publisher.rb +2 -0
  42. data/lib/ably/realtime/channel/push_channel.rb +17 -10
  43. data/lib/ably/realtime/channel.rb +79 -42
  44. data/lib/ably/realtime/channels.rb +4 -3
  45. data/lib/ably/realtime/client/incoming_message_dispatcher.rb +6 -14
  46. data/lib/ably/realtime/client.rb +53 -32
  47. data/lib/ably/realtime/connection/connection_manager.rb +4 -0
  48. data/lib/ably/realtime/connection/websocket_transport.rb +4 -2
  49. data/lib/ably/realtime/connection.rb +94 -55
  50. data/lib/ably/realtime/presence.rb +61 -36
  51. data/lib/ably/realtime/push/admin.rb +16 -2
  52. data/lib/ably/realtime/push.rb +15 -3
  53. data/lib/ably/rest/channel/push_channel.rb +0 -3
  54. data/lib/ably/rest/channel.rb +29 -21
  55. data/lib/ably/rest/channels.rb +6 -3
  56. data/lib/ably/rest/client.rb +41 -35
  57. data/lib/ably/rest/presence.rb +27 -12
  58. data/lib/ably/rest/push/admin.rb +4 -0
  59. data/lib/ably/rest/push/device_registrations.rb +13 -2
  60. data/lib/ably/rest/push.rb +2 -0
  61. data/lib/ably/util/crypto.rb +14 -10
  62. data/lib/ably/version.rb +1 -1
  63. data/spec/acceptance/realtime/connection_spec.rb +0 -15
  64. data/spec/acceptance/realtime/message_spec.rb +3 -3
  65. data/spec/unit/models/protocol_message_spec.rb +0 -26
  66. data/spec/unit/realtime/incoming_message_dispatcher_spec.rb +0 -38
  67. metadata +6 -3
@@ -10,12 +10,7 @@ require 'ably/rest/middleware/exceptions'
10
10
 
11
11
  module Ably
12
12
  module Rest
13
- # Client for the Ably REST API
14
- #
15
- # @!attribute [r] client_id
16
- # @return [String] A client ID, used for identifying this client for presence purposes
17
- # @!attribute [r] auth_options
18
- # @return [Hash] {Ably::Auth} options configured for this client
13
+ # A client that offers a simple stateless API to interact directly with Ably's REST API.
19
14
  #
20
15
  class Client
21
16
  include Ably::Modules::Conversions
@@ -59,11 +54,13 @@ module Ably
59
54
  # @return [String]
60
55
  attr_reader :agent
61
56
 
62
- # {Ably::Auth} authentication object configured for this connection
57
+ # An {Ably::Auth} object.
58
+ # @spec RSC5
63
59
  # @return [Ably::Auth]
64
60
  attr_reader :auth
65
61
 
66
- # The collection of {Ably::Rest::Channel}s that have been created
62
+ # A {Ably::Rest::Channels} object.
63
+ # @spec RSN1
67
64
  # @return [Aby::Rest::Channels]
68
65
  attr_reader :channels
69
66
 
@@ -127,9 +124,11 @@ module Ably
127
124
  # @return [Integer]
128
125
  attr_reader :max_frame_size
129
126
 
130
- # Creates a {Ably::Rest::Client Rest Client} and configures the {Ably::Auth} object for the connection.
127
+ # Constructs a {Ably::Rest::Client} object using an Ably API key or token string.
128
+ #
129
+ # @spec RSC1
131
130
  #
132
- # @param [Hash,String] options an options Hash used to configure the client and the authentication, or String with an API key or Token ID
131
+ # @param [Hash,String] options an options Hash or String used to configure the client and the authentication, or String with an API key or Token ID
133
132
  # @option options [Boolean] :tls (true) When false, TLS is disabled. Please note Basic Auth is disallowed without TLS as secrets cannot be transmitted over unsecured connections.
134
133
  # @option options [String] :key API key comprising the key name and key secret in a single string
135
134
  # @option options [String] :token Token string or {Models::TokenDetails} used to authenticate requests
@@ -167,10 +166,10 @@ module Ably
167
166
  # @return [Ably::Rest::Client]
168
167
  #
169
168
  # @example
170
- # # create a new client authenticating with basic auth
169
+ # # Create a new client authenticating with basic auth using a String object
171
170
  # client = Ably::Rest::Client.new('key.id:secret')
172
171
  #
173
- # # create a new client and configure a client ID used for presence
172
+ # # Construct a RestClient object using a Hash object.
174
173
  # client = Ably::Rest::Client.new(key: 'key.id:secret', client_id: 'john')
175
174
  #
176
175
  def initialize(options)
@@ -275,16 +274,18 @@ module Ably
275
274
  channels.get(name, channel_options)
276
275
  end
277
276
 
278
- # Retrieve the Stats for the application
277
+ # Queries the REST /stats API and retrieves your application's usage statistics. Returns a {Ably::Models::PaginatedResult} object, containing an array of {Ably::Models::Stats} objects. See the Stats docs.
278
+ #
279
+ # @spec RSC6a, RSC6b1, RSC6b2, RSC6b3, RSC6b4
279
280
  #
280
281
  # @param [Hash] options the options for the stats request
281
- # @option options [Integer,Time] :start Ensure earliest time or millisecond since epoch for any stats retrieved is +:start+
282
- # @option options [Integer,Time] :end Ensure latest time or millisecond since epoch for any stats retrieved is +:end+
283
- # @option options [Symbol] :direction +:forwards+ or +:backwards+, defaults to +:backwards+
284
- # @option options [Integer] :limit Maximum number of messages to retrieve up to 1,000, defaults to 100
285
- # @option options [Symbol] :unit `:minute`, `:hour`, `:day` or `:month`. Defaults to `:minute`
282
+ # @option options [Integer,Time] :start The time from which stats are retrieved, specified as milliseconds since the Unix epoch. RSC6b1
283
+ # @option options [Integer,Time] :end The time until stats are retrieved, specified as milliseconds since the Unix epoch. RSC6b1
284
+ # @option options [Symbol] :direction The order for which stats are returned in. Valid values are backwards which orders stats from most recent to oldest, or forwards which orders stats from oldest to most recent. The default is backwards. RSC6b2
285
+ # @option options [Integer] :limit An upper limit on the number of stats returned. The default is 100, and the maximum is 1000. RSC6b3
286
+ # @option options [Symbol] :unit minute, hour, day or month. Based on the unit selected, the given start or end times are rounded down to the start of the relevant interval depending on the unit granularity of the query. RSC6b4
286
287
  #
287
- # @return [Ably::Models::PaginatedResult<Ably::Models::Stats>] An Array of Stats
288
+ # @return [Ably::Models::PaginatedResult<Ably::Models::Stats>] A {Ably::Models::PaginatedResult} object containing an array of {Ably::Models::Stats} objects.
288
289
  #
289
290
  def stats(options = {})
290
291
  options = {
@@ -306,9 +307,13 @@ module Ably
306
307
  Ably::Models::PaginatedResult.new(response, url, self, paginated_options)
307
308
  end
308
309
 
309
- # Retrieve the Ably service time
310
+ # Retrieves the time from the Ably service as milliseconds since the Unix epoch. Clients that do not have access
311
+ # to a sufficiently well maintained time source and wish to issue Ably {Ably::Models::TokenRequest} with
312
+ # a more accurate timestamp should use the {Ably::Rest::Client#queryTime} property instead of this method.
310
313
  #
311
- # @return [Time] The time as reported by the Ably service
314
+ # @spec RSC16
315
+ #
316
+ # @return [Time] The time as milliseconds since the Unix epoch.
312
317
  def time
313
318
  response = get('/time', {}, send_auth_header: false)
314
319
 
@@ -357,20 +362,19 @@ module Ably
357
362
  raw_request(:delete, path, params, options)
358
363
  end
359
364
 
360
- # Perform an HTTP request to the Ably API
361
- # This is a convenience for customers who wish to use bleeding edge REST API functionality
362
- # that is either not documented or is not included in the API for our client libraries.
363
- # The REST client library provides a function to issue HTTP requests to the Ably endpoints
364
- # with all the built in functionality of the library such as authentication, paging,
365
- # fallback hosts, MsgPack and JSON support etc.
365
+ # Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API
366
+ # functionality that is either not documented or is not yet included in the public API, without having to directly
367
+ # handle features such as authentication, paging, fallback hosts, MsgPack and JSON support.
368
+ #
369
+ # @spec RSC19
366
370
  #
367
- # @param method [Symbol] The HTTP method symbol such as +:get+, +:post+, +:put+
368
- # @param path [String] The path of the URL such +/channel/foo/publish+
369
- # @param params [Hash, nil] Optional querystring params
370
- # @param body [Hash, nil] Optional body for the POST or PUT request, must be nil or a JSON-like object
371
- # @param headers [Hash, nil] Optional additional headers
371
+ # @param method [Symbol] The request method to use, such as :get, :post.
372
+ # @param path [String] The request path.
373
+ # @param params [Hash, nil] The parameters to include in the URL query of the request. The parameters depend on the endpoint being queried. See the REST API reference for the available parameters of each endpoint.
374
+ # @param body [Hash, nil] The JSON body of the request.
375
+ # @param headers [Hash, nil] Additional HTTP headers to include in the request.
372
376
  #
373
- # @return [Ably::Models::HttpPaginatedResponse<>]
377
+ # @return [Ably::Models::HttpPaginatedResponse<>] An {Ably::Models::HttpPaginatedResponse} object returned by the HTTP request, containing an empty or JSON-encodable object.
374
378
  def request(method, path, params = {}, body = nil, headers = {}, options = {})
375
379
  raise "Method #{method.to_s.upcase} not supported" unless %i(get put patch post delete).include?(method.to_sym)
376
380
 
@@ -408,7 +412,8 @@ module Ably
408
412
  Models::HttpPaginatedResponse.new(response, path, self)
409
413
  end
410
414
 
411
- # The local device detilas
415
+ # Retrieves an object that represents the current state of the device as a target for push notifications.
416
+ # @spec RSH8
412
417
  # @return [Ably::Models::LocalDevice]
413
418
  #
414
419
  # @note This is unsupported in the Ruby library
@@ -416,7 +421,8 @@ module Ably
416
421
  raise Ably::Exceptions::PushNotificationsNotSupported, 'This device does not support receiving or subscribing to push notifications. The local device object is not unavailable'
417
422
  end
418
423
 
419
- # Push notification object for publishing and managing push notifications
424
+ # A {Ably::Rest::Push} object.
425
+ # @spec RSH7
420
426
  # @return [Ably::Rest::Push]
421
427
  def push
422
428
  @push ||= Push.new(self)
@@ -1,34 +1,45 @@
1
1
  module Ably
2
2
  module Rest
3
+ # Enables the retrieval of the current and historic presence set for a channel.
4
+ #
3
5
  class Presence
4
6
  include Ably::Modules::Conversions
5
7
 
6
8
  # {Ably::Rest::Client} for this Presence object
9
+ #
7
10
  # @return {Ably::Rest::Client}
11
+ #
8
12
  # @private
9
13
  attr_reader :client
10
14
 
11
15
  # {Ably::Rest::Channel} this Presence object is associated with
12
- # @return {Ably::Rest::Channel}
16
+ #
17
+ # @return [Ably::Rest::Channel]
18
+ #
13
19
  attr_reader :channel
14
20
 
15
21
  # Initialize a new Presence object
16
22
  #
17
23
  # @param client [Ably::Rest::Client]
18
24
  # @param channel [Channel] The channel object
25
+ #
19
26
  def initialize(client, channel)
20
27
  @client = client
21
28
  @channel = channel
22
29
  end
23
30
 
24
- # Obtain the set of members currently present for a channel
31
+ # Retrieves the current members present on the channel and the metadata for each member, such as their
32
+ # {Ably::Models::PresenceMessage::ACTION} and ID. Returns a {Ably::Models::PaginatedResult} object,
33
+ # containing an array of {Ably::Models::PresenceMessage} objects.
34
+ #
35
+ # @spec RSPa, RSP3a, RSP3a2, RSP3a3
25
36
  #
26
37
  # @param [Hash] options the options for the set of members present
27
- # @option options [Integer] :limit Maximum number of members to retrieve up to 1,000, defaults to 100
28
- # @option options [String] :client_id optional client_id filter for the member
29
- # @option options [String] :connection_id optional connection_id filter for the member
38
+ # @option options [Integer] :limit An upper limit on the number of messages returned. The default is 100, and the maximum is 1000. (RSP3a)
39
+ # @option options [String] :client_id Filters the list of returned presence members by a specific client using its ID. (RSP3a2)
40
+ # @option options [String] :connection_id Filters the list of returned presence members by a specific connection using its ID. (RSP3a3)
30
41
  #
31
- # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] First {Ably::Models::PaginatedResult page} of {Ably::Models::PresenceMessage} objects accessible with {Ably::Models::PaginatedResult#items #items}.
42
+ # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] A {Ably::Models::PaginatedResult} object containing an array of {Ably::Models::PresenceMessage} objects.
32
43
  #
33
44
  def get(options = {})
34
45
  options = options = {
@@ -49,15 +60,19 @@ module Ably
49
60
  end
50
61
  end
51
62
 
52
- # Return the presence messages history for the channel
63
+ # Retrieves a {Ably::Models::PaginatedResult} object, containing an array of historical {Ably::Models::PresenceMessage}
64
+ # objects for the channel. If the channel is configured to persist messages, then presence messages can be retrieved
65
+ # from history for up to 72 hours in the past. If not, presence messages can only be retrieved from history for up to two minutes in the past.
66
+ #
67
+ # @spec RSP4a
53
68
  #
54
69
  # @param [Hash] options the options for the message history request
55
- # @option options [Integer,Time] :start Ensure earliest time or millisecond since epoch for any presence messages retrieved is +:start+
56
- # @option options [Integer,Time] :end Ensure latest time or millisecond since epoch for any presence messages retrieved is +:end+
57
- # @option options [Symbol] :direction +:forwards+ or +:backwards+, defaults to +:backwards+
58
- # @option options [Integer] :limit Maximum number of messages to retrieve up to 1,000, defaults to 100
70
+ # @option options [Integer,Time] :start The time from which messages are retrieved, specified as milliseconds since the Unix epoch. (RSP4b1)
71
+ # @option options [Integer,Time] :end The time until messages are retrieved, specified as milliseconds since the Unix epoch. (RSP4b1)
72
+ # @option options [Symbol] :direction The order for which messages are returned in. Valid values are backwards which orders messages from most recent to oldest, or forwards which orders messages from oldest to most recent. The default is backwards. (RSP4b2)
73
+ # @option options [Integer] :limit An upper limit on the number of messages returned. The default is 100, and the maximum is 1000. (RSP4b3)
59
74
  #
60
- # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] First {Ably::Models::PaginatedResult page} of {Ably::Models::PresenceMessage} objects accessible with {Ably::Models::PaginatedResult#items #items}.
75
+ # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] A {Ably::Models::PaginatedResult} object containing an array of {Ably::Models::PresenceMessage} objects.
61
76
  #
62
77
  def history(options = {})
63
78
  url = "#{base_path}/history"
@@ -39,13 +39,17 @@ module Ably::Rest
39
39
  end
40
40
 
41
41
  # Manage device registrations
42
+ #
42
43
  # @return [Ably::Rest::Push::DeviceRegistrations]
44
+ #
43
45
  def device_registrations
44
46
  @device_registrations ||= DeviceRegistrations.new(self)
45
47
  end
46
48
 
47
49
  # Manage channel subscriptions for devices or clients
50
+ #
48
51
  # @return [Ably::Rest::Push::ChannelSubscriptions]
52
+ #
49
53
  def channel_subscriptions
50
54
  @channel_subscriptions ||= ChannelSubscriptions.new(self)
51
55
  end
@@ -17,6 +17,8 @@ module Ably::Rest
17
17
 
18
18
  # Get registered device by device ID
19
19
  #
20
+ # @spec RSH1b1
21
+ #
20
22
  # @param [String, Ably::Models::DeviceDetails] device_id the device to retrieve
21
23
  #
22
24
  # @return [Ably::Models::DeviceDetails] Returns {Ably::Models::DeviceDetails} if a match is found else a {Ably::Exceptions::ResourceMissing} is raised
@@ -30,6 +32,8 @@ module Ably::Rest
30
32
 
31
33
  # List registered devices filtered by optional params
32
34
  #
35
+ # @spec RSH1b2
36
+ #
33
37
  # @param [Hash] params the filter options for the list registered device request
34
38
  # @option params [String] :client_id filter by devices registered to a client identifier. Cannot be used with +device_id+ param
35
39
  # @option params [String] :device_id filter by unique device ID. Cannot be used with +client_id+ param
@@ -54,7 +58,10 @@ module Ably::Rest
54
58
  Ably::Models::PaginatedResult.new(response, '', client, paginated_options)
55
59
  end
56
60
 
57
- # Save and register device
61
+ # Registers or updates a {Ably::Models::DeviceDetails} object with Ably.
62
+ # Returns the new, or updated {Ably::Models::DeviceDetails} object.
63
+ #
64
+ # @spec RSH1b3
58
65
  #
59
66
  # @param [Ably::Models::DeviceDetails, Hash] device the device details to save
60
67
  #
@@ -69,6 +76,8 @@ module Ably::Rest
69
76
 
70
77
  # Remove device
71
78
  #
79
+ # @spec RSH1b4
80
+ #
72
81
  # @param [String, Ably::Models::DeviceDetails] device_id the device to remove
73
82
  #
74
83
  # @return [void]
@@ -80,7 +89,9 @@ module Ably::Rest
80
89
  client.delete("/push/deviceRegistrations/#{device_id}", {})
81
90
  end
82
91
 
83
- # Remove device matching where params
92
+ # Removes all devices registered to receive push notifications from Ably matching the filter params provided.
93
+ #
94
+ # @spec RSH1b5
84
95
  #
85
96
  # @param [Hash] params the filter params for the remove request
86
97
  # @option params [String] :client_id remove devices registered to a client identifier. Cannot be used with +device_id+ param
@@ -14,7 +14,9 @@ module Ably
14
14
  end
15
15
 
16
16
  # Admin features for push notifications like managing devices and channel subscriptions
17
+ #
17
18
  # @return [Ably::Rest::Push::Admin]
19
+ #
18
20
  def admin
19
21
  @admin ||= Admin.new(self)
20
22
  end
@@ -2,6 +2,8 @@ require 'msgpack'
2
2
  require 'openssl'
3
3
 
4
4
  module Ably::Util
5
+ # Contains the properties required to configure the encryption of {Ably::Models::Message} payloads.
6
+ #
5
7
  class Crypto
6
8
  DEFAULTS = {
7
9
  algorithm: 'aes',
@@ -14,6 +16,7 @@ module Ably::Util
14
16
  # Configured {Ably::Models::CipherParams} for this Crypto object, see {#initialize} for a list of configureable options
15
17
  #
16
18
  # @return [Ably::Models::CipherParams]
19
+ #
17
20
  attr_reader :cipher_params
18
21
 
19
22
  # Creates a {Ably::Util::Crypto} object
@@ -34,13 +37,12 @@ module Ably::Util
34
37
  @cipher_params = Ably::Models::CipherParams(params)
35
38
  end
36
39
 
37
- # Obtain a default {Ably::Models::CipherParams}. This uses default algorithm, mode and
38
- # padding and key length. An IV is generated using the default
39
- # system SecureRandom; the key may be obtained from the returned {Ably::Models::CipherParams}
40
- # for out-of-band distribution to other clients.
41
-
40
+ # Returns a {Ably::Models::CipherParams} object, using the default values for any fields not supplied by the `Hash` object.
41
+ #
42
+ # @spec RSE1, RSE1b, RSE1b
43
+ #
42
44
  # @param [Hash] params a Hash used to configure the Crypto library's {Ably::Models::CipherParams}
43
- # @option params (see Ably::Models::CipherParams#initialize)
45
+ # @option params (see {Ably::Models::CipherParams#initialize})
44
46
  #
45
47
  # @return [Ably::Models::CipherParams] Configured cipher params with :key, :algorithm, :mode, :key_length attributes
46
48
  #
@@ -48,11 +50,13 @@ module Ably::Util
48
50
  Ably::Models::CipherParams(params)
49
51
  end
50
52
 
51
- # Generate a random encryption key from the supplied keylength (or the
52
- # default key_length of 256 if none supplied)
53
+ # Generates a random key to be used in the encryption of the channel. If the language cryptographic randomness
54
+ # primitives are blocking or async, a callback is used. The callback returns a generated binary key.
55
+ #
56
+ # @spec RSE2, RSE2a, RSE2b
53
57
  #
54
- # @param [Integer] key_length Optional (default 256) key length for the generated random key. 128 and 256 bit key lengths are supported
55
- # @return Binary String (byte array) with ASCII_8BIT encoding
58
+ # @param [Integer] key_length The length of the key, in bits, to be generated. If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.
59
+ # @return Binary The key as a binary, for example, a byte array.
56
60
  #
57
61
  def self.generate_random_key(key_length = DEFAULTS.fetch(:key_length))
58
62
  params = DEFAULTS.merge(key_length: key_length)
data/lib/ably/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Ably
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  PROTOCOL_VERSION = '1.2'
4
4
 
5
5
  # @api private
@@ -1620,21 +1620,6 @@ describe Ably::Realtime::Connection, :event_machine do
1620
1620
  end
1621
1621
  end
1622
1622
 
1623
- context 'with invalid formatted value sent to server' do
1624
- let(:client_options) { default_options.merge(recover: 'not-a-valid-connection-key:1:0', log_level: :none) }
1625
-
1626
- it 'sets the #error_reason and moves the connection to FAILED' do
1627
- connection.once(:failed) do |state_change|
1628
- expect(connection.state).to eq(:failed)
1629
- expect(state_change.reason.message).to match(/Invalid connectionKey/i)
1630
- expect(connection.error_reason.message).to match(/Invalid connectionKey/i)
1631
- expect(connection.error_reason.code).to eql(80018)
1632
- expect(connection.error_reason).to eql(state_change.reason)
1633
- stop_reactor
1634
- end
1635
- end
1636
- end
1637
-
1638
1623
  context 'with expired (missing) value sent to server' do
1639
1624
  let(:client_options) { default_options.merge(recover: 'wVIsgTHAB1UvXh7z-1991d8586:0:0', log_level: :fatal) }
1640
1625
 
@@ -523,7 +523,7 @@ describe 'Ably::Realtime::Channel Message', :event_machine do
523
523
 
524
524
  resources_root = File.expand_path('../../../../lib/submodules/ably-common/test-resources', __FILE__)
525
525
 
526
- def self.add_tests_for_data(data)
526
+ shared_examples 'add_tests_for_data' do |data|
527
527
  data['items'].each_with_index do |item, index|
528
528
  context "item #{index} with encrypted encoding #{item['encrypted']['encoding']}" do
529
529
  it_behaves_like 'an Ably encrypter and decrypter', item, data
@@ -533,12 +533,12 @@ describe 'Ably::Realtime::Channel Message', :event_machine do
533
533
 
534
534
  context 'with AES-128-CBC using crypto-data-128.json fixtures (#RTL7d)' do
535
535
  data = JSON.parse(File.read(File.join(resources_root, 'crypto-data-128.json')))
536
- add_tests_for_data data
536
+ include_examples 'add_tests_for_data', data
537
537
  end
538
538
 
539
539
  context 'with AES-256-CBC using crypto-data-256.json fixtures (#RTL7d)' do
540
540
  data = JSON.parse(File.read(File.join(resources_root, 'crypto-data-256.json')))
541
- add_tests_for_data data
541
+ include_examples 'add_tests_for_data', data
542
542
  end
543
543
 
544
544
  context 'with multiple sends from one client to another' do
@@ -400,32 +400,6 @@ describe Ably::Models::ProtocolMessage do
400
400
  end
401
401
  end
402
402
 
403
- context '#has_correct_message_size? (#TO3l8)' do
404
- context 'on presence' do
405
- it 'should return true when a message has correct size' do
406
- protocol_message = new_protocol_message(presence: [{ action: 1, data: 'x' * 100 }])
407
- expect(protocol_message.has_correct_message_size?).to eq(true)
408
- end
409
-
410
- it 'should return false when a message has not correct size' do
411
- protocol_message = new_protocol_message(presence: [{ action: 1, data: 'x' * 65537 }])
412
- expect(protocol_message.has_correct_message_size?).to eq(false)
413
- end
414
- end
415
-
416
- context 'on message' do
417
- it 'should return true when a message has correct size' do
418
- protocol_message = new_protocol_message(messages: [{ name: 'x' * 100 }])
419
- expect(protocol_message.has_correct_message_size?).to eq(true)
420
- end
421
-
422
- it 'should return false when a message has not correct size' do
423
- protocol_message = new_protocol_message(messages: [{ name: 'x' * 65537 }])
424
- expect(protocol_message.has_correct_message_size?).to eq(false)
425
- end
426
- end
427
- end
428
-
429
403
  context '#connection_details (#TR4o)' do
430
404
  let(:connection_details) { protocol_message.connection_details }
431
405
 
@@ -32,43 +32,5 @@ describe Ably::Realtime::Client::IncomingMessageDispatcher, :api_private do
32
32
  expect(subject).to receive_message_chain(:logger, :warn)
33
33
  msgbus.publish :protocol_message, Ably::Models::ProtocolMessage.new(:action => :attached, channel: 'unknown')
34
34
  end
35
-
36
- context 'TO3l8' do
37
- context 'on action presence' do
38
- let(:presence) { 101.times.map { { data: 'x' * 655 } } }
39
-
40
- let(:protocol_message) do
41
- Ably::Models::ProtocolMessage.new(action: :presence, channel: 'default', presence: presence, connection_serial: 123123123)
42
- end
43
-
44
- it 'should raise a protocol error when message size exceeded 65536 bytes' do
45
- allow(connection).to receive(:serial).and_return(12312312)
46
- allow(subject).to receive(:update_connection_recovery_info)
47
- allow(subject).to receive_message_chain(:logger, :debug)
48
- allow(subject).to receive_message_chain(:logger, :warn)
49
- expect(subject).to receive_message_chain(:logger, :fatal)
50
-
51
- msgbus.publish :protocol_message, protocol_message
52
- end
53
- end
54
-
55
- context 'on action message' do
56
- let(:messages) { 101.times.map { { data: 'x' * 655 } } }
57
-
58
- let(:protocol_message) do
59
- Ably::Models::ProtocolMessage.new(action: :message, channel: 'default', messages: messages, connection_serial: 123123123)
60
- end
61
-
62
- it 'should raise a protocol error when message size exceeded 65536 bytes' do
63
- allow(connection).to receive(:serial).and_return(12312312)
64
- allow(subject).to receive(:update_connection_recovery_info)
65
- allow(subject).to receive_message_chain(:logger, :debug)
66
- allow(subject).to receive_message_chain(:logger, :warn)
67
- expect(subject).to receive_message_chain(:logger, :fatal)
68
-
69
- msgbus.publish :protocol_message, protocol_message
70
- end
71
- end
72
- end
73
35
  end
74
36
  end
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.2.2
4
+ version: 1.2.3
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-06-08 00:00:00.000000000 Z
12
+ date: 2022-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -370,13 +370,16 @@ extensions: []
370
370
  extra_rdoc_files: []
371
371
  files:
372
372
  - ".editorconfig"
373
+ - ".github/workflows/.rspec_parallel"
373
374
  - ".github/workflows/check.yml"
375
+ - ".github/workflows/docs.yml"
374
376
  - ".gitignore"
375
377
  - ".gitmodules"
376
378
  - ".rspec"
377
379
  - CHANGELOG.md
378
380
  - COPYRIGHT
379
381
  - Gemfile
382
+ - INTRO.md
380
383
  - LICENSE
381
384
  - MAINTAINERS.md
382
385
  - README.md
@@ -601,7 +604,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
601
604
  - !ruby/object:Gem::Version
602
605
  version: '0'
603
606
  requirements: []
604
- rubygems_version: 3.3.14
607
+ rubygems_version: 3.2.32
605
608
  signing_key:
606
609
  specification_version: 4
607
610
  summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine