ably 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -4
- data/CHANGELOG.md +18 -1
- data/README.md +9 -1
- data/ably.gemspec +3 -3
- data/lib/ably/realtime/client.rb +4 -3
- data/lib/ably/realtime/connection.rb +24 -15
- data/lib/ably/realtime/connection/connection_manager.rb +0 -2
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/realtime/auth_spec.rb +11 -9
- data/spec/acceptance/realtime/channel_history_spec.rb +26 -20
- data/spec/acceptance/realtime/connection_failures_spec.rb +3 -3
- data/spec/acceptance/realtime/connection_spec.rb +116 -14
- data/spec/acceptance/realtime/message_spec.rb +15 -13
- data/spec/acceptance/realtime/presence_spec.rb +196 -162
- data/spec/acceptance/realtime/push_admin_spec.rb +6 -4
- data/spec/acceptance/rest/channel_spec.rb +37 -0
- data/spec/acceptance/rest/channels_spec.rb +6 -0
- data/spec/acceptance/rest/message_spec.rb +7 -25
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/realtime/connection_spec.rb +1 -1
- metadata +17 -17
@@ -63,20 +63,22 @@ describe Ably::Realtime::Push::Admin, :event_machine do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
context 'invalid recipient' do
|
66
|
+
let(:default_options) { { key: api_key, environment: environment, protocol: protocol, log_level: :fatal } }
|
67
|
+
|
66
68
|
it 'raises an error after receiving a 40x realtime response' do
|
67
|
-
skip 'validation on raw push is not enabled in realtime'
|
68
69
|
subject.publish({ invalid_recipient_details: 'foo.bar' }, basic_notification_payload).errback do |error|
|
69
|
-
expect(error.message).to match(/
|
70
|
+
expect(error.message).to match(/recipient must contain/)
|
70
71
|
stop_reactor
|
71
72
|
end
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
76
|
context 'invalid push data' do
|
77
|
+
let(:default_options) { { key: api_key, environment: environment, protocol: protocol, log_level: :fatal } }
|
78
|
+
|
76
79
|
it 'raises an error after receiving a 40x realtime response' do
|
77
|
-
skip 'validation on raw push is not enabled in realtime'
|
78
80
|
subject.publish(basic_recipient, { invalid_property_only: true }).errback do |error|
|
79
|
-
expect(error.message).to match(/
|
81
|
+
expect(error.message).to match(/Unexpected field/)
|
80
82
|
stop_reactor
|
81
83
|
end
|
82
84
|
end
|
@@ -275,6 +275,43 @@ describe Ably::Rest::Channel do
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
end
|
278
|
+
|
279
|
+
context 'with a frozen message event name' do
|
280
|
+
let(:event_name) { random_str.freeze }
|
281
|
+
|
282
|
+
it 'succeeds and publishes with an implicit client_id' do
|
283
|
+
channel.publish([name: event_name])
|
284
|
+
channel.publish(event_name)
|
285
|
+
|
286
|
+
if !(RUBY_VERSION.match(/^1\./) || RUBY_VERSION.match(/^2\.[012]/))
|
287
|
+
channel.publish(+'foo-bar') # new style freeze, see https://github.com/ably/ably-ruby/issues/132
|
288
|
+
else
|
289
|
+
channel.publish('foo-bar'.freeze) # new + style not supported until Ruby 2.3
|
290
|
+
end
|
291
|
+
|
292
|
+
channel.history do |messages|
|
293
|
+
expect(messages.length).to eql(3)
|
294
|
+
expect(messages.first.name).to eql(event_name)
|
295
|
+
expect(messages[1].name).to eql(event_name)
|
296
|
+
expect(messages.last.name).to eql('foo-bar')
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
context 'with a frozen payload' do
|
302
|
+
let(:payload) { { foo: random_str.freeze }.freeze }
|
303
|
+
|
304
|
+
it 'succeeds and publishes with an implicit client_id' do
|
305
|
+
channel.publish([data: payload])
|
306
|
+
channel.publish(nil, payload)
|
307
|
+
|
308
|
+
channel.history do |messages|
|
309
|
+
expect(messages.length).to eql(2)
|
310
|
+
expect(messages.first.data).to eql(payload)
|
311
|
+
expect(messages.last.data).to eql(payload)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
278
315
|
end
|
279
316
|
|
280
317
|
describe '#history' do
|
@@ -60,5 +60,11 @@ describe Ably::Rest::Channels do
|
|
60
60
|
let(:channel_with_options) { client.channels[channel_name, options] }
|
61
61
|
it_behaves_like 'a channel'
|
62
62
|
end
|
63
|
+
|
64
|
+
describe 'using a frozen channel name' do
|
65
|
+
let(:channel) { client.channels[channel_name.freeze] }
|
66
|
+
let(:channel_with_options) { client.channels[channel_name.freeze, options] }
|
67
|
+
it_behaves_like 'a channel'
|
68
|
+
end
|
63
69
|
end
|
64
70
|
end
|
@@ -120,8 +120,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
120
120
|
let(:message) { Ably::Models::Message.new(id: id, data: data) }
|
121
121
|
|
122
122
|
specify 'three REST publishes result in only one message being published' do
|
123
|
-
pending 'idempotency rolled out to global cluster'
|
124
|
-
|
125
123
|
3.times { channel.publish [message] }
|
126
124
|
expect(channel.history.items.length).to eql(1)
|
127
125
|
expect(channel.history.items[0].id).to eql(id)
|
@@ -130,8 +128,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
130
128
|
|
131
129
|
context 'with #publish arguments only' do
|
132
130
|
it 'three REST publishes result in only one message being published' do
|
133
|
-
pending 'idempotency rolled out to global cluster'
|
134
|
-
|
135
131
|
3.times { channel.publish 'event', data, id: id }
|
136
132
|
expect(channel.history.items.length).to eql(1)
|
137
133
|
end
|
@@ -143,8 +139,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
143
139
|
end
|
144
140
|
|
145
141
|
specify 'for multiple messages in one publish operation (#RSL1k3)' do
|
146
|
-
pending 'idempotency rolled out to global cluster'
|
147
|
-
|
148
142
|
message_arr = 3.times.map { Ably::Models::Message.new(id: id, data: data) }
|
149
143
|
expect { channel.publish message_arr }.to raise_error do |error|
|
150
144
|
expect(error.code).to eql(40031) # Invalid publish request (invalid client-specified id), see https://github.com/ably/ably-common/pull/30
|
@@ -152,12 +146,10 @@ describe Ably::Rest::Channel, 'messages' do
|
|
152
146
|
end
|
153
147
|
|
154
148
|
specify 'for multiple messages in one publish operation with IDs following the required format described in RSL1k1 (#RSL1k3)' do
|
155
|
-
pending 'idempotency rolled out to global cluster'
|
156
|
-
|
157
149
|
message_arr = 3.times.map { |index| Ably::Models::Message.new(id: "#{id}:#{index}", data: data) }
|
158
150
|
channel.publish message_arr
|
159
|
-
expect(channel.history.items[
|
160
|
-
expect(channel.history.items[
|
151
|
+
expect(channel.history.items[2].id).to eql("#{id}:0")
|
152
|
+
expect(channel.history.items[0].id).to eql("#{id}:2")
|
161
153
|
expect(channel.history.items.length).to eql(3)
|
162
154
|
end
|
163
155
|
end
|
@@ -174,7 +166,7 @@ describe Ably::Rest::Channel, 'messages' do
|
|
174
166
|
end
|
175
167
|
|
176
168
|
context 'when idempotent publishing is enabled in the client library ClientOptions (#TO3n)' do
|
177
|
-
let(:client_options) { default_client_options.merge(idempotent_rest_publishing: true, log_level: :error) }
|
169
|
+
let(:client_options) { default_client_options.merge(idempotent_rest_publishing: true, log_level: :error, fallback_hosts: ["#{environment}-realtime.ably.io"]) }
|
178
170
|
|
179
171
|
context 'when there is a network failure triggering an automatic retry (#RSL1k4)' do
|
180
172
|
def mock_for_two_publish_failures
|
@@ -195,8 +187,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
195
187
|
before { mock_for_two_publish_failures }
|
196
188
|
|
197
189
|
specify 'two REST publish retries result in only one message being published' do
|
198
|
-
pending 'idempotency rolled out to global cluster'
|
199
|
-
|
200
190
|
channel.publish [message]
|
201
191
|
expect(channel.history.items.length).to eql(1)
|
202
192
|
expect(@failed_http_posts).to eql(2)
|
@@ -207,8 +197,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
207
197
|
before { mock_for_two_publish_failures }
|
208
198
|
|
209
199
|
specify 'two REST publish retries result in only one message being published' do
|
210
|
-
pending 'idempotency rolled out to global cluster'
|
211
|
-
|
212
200
|
channel.publish 'event', data
|
213
201
|
expect(channel.history.items.length).to eql(1)
|
214
202
|
expect(@failed_http_posts).to eql(2)
|
@@ -221,8 +209,6 @@ describe Ably::Rest::Channel, 'messages' do
|
|
221
209
|
before { mock_for_two_publish_failures }
|
222
210
|
|
223
211
|
specify 'two REST publish retries result in only one message being published' do
|
224
|
-
pending 'idempotency rolled out to global cluster'
|
225
|
-
|
226
212
|
channel.publish 'event', data, id: id
|
227
213
|
expect(channel.history.items.length).to eql(1)
|
228
214
|
expect(channel.history.items[0].id).to eql(id)
|
@@ -231,11 +217,9 @@ describe Ably::Rest::Channel, 'messages' do
|
|
231
217
|
end
|
232
218
|
|
233
219
|
specify 'for multiple messages in one publish operation' do
|
234
|
-
pending 'idempotency rolled out to global cluster'
|
235
|
-
|
236
220
|
message_arr = 3.times.map { Ably::Models::Message.new(data: data) }
|
237
221
|
3.times { channel.publish message_arr }
|
238
|
-
expect(channel.history.items.length).to eql(message_arr.length)
|
222
|
+
expect(channel.history.items.length).to eql(message_arr.length * 3)
|
239
223
|
end
|
240
224
|
end
|
241
225
|
|
@@ -248,13 +232,11 @@ describe Ably::Rest::Channel, 'messages' do
|
|
248
232
|
|
249
233
|
context 'when publishing a batch of messages' do
|
250
234
|
specify 'the ID is populated with a single random ID and sequence of serials from this lib (#RSL1k1)' do
|
251
|
-
pending 'idempotency rolled out to global cluster'
|
252
|
-
|
253
235
|
message = { name: 'event' }
|
254
236
|
channel.publish [message, message, message]
|
255
|
-
expect(channel.history.items
|
256
|
-
expect(channel.history.items[0].id).to match(/^[A-Za-z0-9\+\/]+:
|
257
|
-
expect(channel.history.items[2].id).to match(/^[A-Za-z0-9\+\/]+:
|
237
|
+
expect(channel.history.items.length).to eql(3)
|
238
|
+
expect(channel.history.items[0].id).to match(/^[A-Za-z0-9\+\/]+:2$/)
|
239
|
+
expect(channel.history.items[2].id).to match(/^[A-Za-z0-9\+\/]+:0$/)
|
258
240
|
base_64_id = channel.history.items[0].id.split(':')[0]
|
259
241
|
expect(Base64.decode64(base_64_id).length).to eql(9)
|
260
242
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'shared/protocol_msgbus_behaviour'
|
3
3
|
|
4
4
|
describe Ably::Realtime::Connection do
|
5
|
-
let(:client) { instance_double('Ably::Realtime::Client', logger: double('logger').as_null_object) }
|
5
|
+
let(:client) { instance_double('Ably::Realtime::Client', logger: double('logger').as_null_object, recover: nil) }
|
6
6
|
|
7
7
|
subject do
|
8
8
|
Ably::Realtime::Connection.new(client, {}).tap do |connection|
|
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.1.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: 2019-
|
12
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -137,20 +137,6 @@ dependencies:
|
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 2.0.0
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: bundler
|
142
|
-
requirement: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- - "~>"
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: '1.3'
|
147
|
-
type: :development
|
148
|
-
prerelease: false
|
149
|
-
version_requirements: !ruby/object:Gem::Requirement
|
150
|
-
requirements:
|
151
|
-
- - "~>"
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: '1.3'
|
154
140
|
- !ruby/object:Gem::Dependency
|
155
141
|
name: rake
|
156
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +221,20 @@ dependencies:
|
|
235
221
|
- - "~>"
|
236
222
|
- !ruby/object:Gem::Version
|
237
223
|
version: '1.0'
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: bundler
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: 1.3.0
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: 1.3.0
|
238
238
|
- !ruby/object:Gem::Dependency
|
239
239
|
name: webmock
|
240
240
|
requirement: !ruby/object:Gem::Requirement
|
@@ -527,7 +527,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
527
527
|
- !ruby/object:Gem::Version
|
528
528
|
version: '0'
|
529
529
|
requirements: []
|
530
|
-
rubygems_version: 3.0.
|
530
|
+
rubygems_version: 3.0.3
|
531
531
|
signing_key:
|
532
532
|
specification_version: 4
|
533
533
|
summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
|