ably 0.8.7 → 0.8.8
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/CHANGELOG.md +61 -3
- data/ably.gemspec +1 -1
- data/lib/ably/auth.rb +12 -3
- data/lib/ably/logger.rb +3 -1
- data/lib/ably/models/connection_details.rb +2 -1
- data/lib/ably/models/idiomatic_ruby_wrapper.rb +1 -1
- data/lib/ably/models/message.rb +4 -2
- data/lib/ably/models/message_encoders/cipher.rb +2 -2
- data/lib/ably/models/paginated_result.rb +27 -1
- data/lib/ably/models/presence_message.rb +3 -1
- data/lib/ably/models/{stat.rb → stats.rb} +5 -3
- data/lib/ably/modules/async_wrapper.rb +1 -1
- data/lib/ably/modules/channels_collection.rb +11 -1
- data/lib/ably/modules/enum.rb +18 -2
- data/lib/ably/modules/event_emitter.rb +3 -3
- data/lib/ably/modules/safe_deferrable.rb +1 -1
- data/lib/ably/modules/safe_yield.rb +2 -2
- data/lib/ably/modules/state_emitter.rb +8 -8
- data/lib/ably/modules/statesman_monkey_patch.rb +2 -2
- data/lib/ably/modules/uses_state_machine.rb +4 -2
- data/lib/ably/realtime.rb +1 -0
- data/lib/ably/realtime/auth.rb +6 -2
- data/lib/ably/realtime/channel.rb +6 -4
- data/lib/ably/realtime/channel/channel_manager.rb +7 -1
- data/lib/ably/realtime/client.rb +7 -12
- data/lib/ably/realtime/client/incoming_message_dispatcher.rb +9 -2
- data/lib/ably/realtime/client/outgoing_message_dispatcher.rb +7 -1
- data/lib/ably/realtime/connection.rb +19 -8
- data/lib/ably/realtime/connection/connection_manager.rb +16 -9
- data/lib/ably/realtime/connection/websocket_transport.rb +12 -3
- data/lib/ably/realtime/presence.rb +6 -6
- data/lib/ably/realtime/presence/members_map.rb +21 -7
- data/lib/ably/rest/channel.rb +8 -8
- data/lib/ably/rest/client.rb +1 -1
- data/lib/ably/rest/middleware/exceptions.rb +3 -1
- data/lib/ably/rest/presence.rb +4 -4
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/realtime/channel_history_spec.rb +4 -4
- data/spec/acceptance/realtime/connection_failures_spec.rb +2 -4
- data/spec/acceptance/realtime/connection_spec.rb +46 -8
- data/spec/acceptance/realtime/presence_spec.rb +49 -34
- data/spec/acceptance/rest/auth_spec.rb +1 -1
- data/spec/acceptance/rest/base_spec.rb +1 -1
- data/spec/shared/safe_deferrable_behaviour.rb +4 -4
- data/spec/unit/models/message_encoders/cipher_spec.rb +1 -1
- data/spec/unit/models/token_details_spec.rb +20 -18
- data/spec/unit/modules/event_emitter_spec.rb +2 -2
- data/spec/unit/modules/state_emitter_spec.rb +6 -6
- data/spec/unit/realtime/channel_spec.rb +4 -4
- data/spec/unit/realtime/connection_spec.rb +1 -1
- data/spec/unit/realtime/presence_spec.rb +5 -5
- metadata +5 -5
@@ -689,12 +689,12 @@ describe Ably::Auth do
|
|
689
689
|
stub_const 'Ably::Models::TokenDetails::TOKEN_EXPIRY_BUFFER', 0
|
690
690
|
old_token_defaults = Ably::Auth::TOKEN_DEFAULTS
|
691
691
|
stub_const 'Ably::Auth::TOKEN_DEFAULTS', old_token_defaults.merge(renew_token_buffer: 0)
|
692
|
+
@block_called = 0
|
692
693
|
end
|
693
694
|
|
694
695
|
let(:token_client) { Ably::Rest::Client.new(default_options.merge(key: api_key, token_params: { ttl: 3 })) }
|
695
696
|
let(:client_options) {
|
696
697
|
default_options.merge(token: token_client.auth.request_token.token, auth_callback: Proc.new do
|
697
|
-
@block_called ||= 0
|
698
698
|
@block_called += 1
|
699
699
|
token_client.auth.create_token_request
|
700
700
|
end)
|
@@ -130,7 +130,7 @@ describe Ably::Rest do
|
|
130
130
|
if [1, 3].include?(@publish_attempts)
|
131
131
|
{ status: 201, :body => '[]', :headers => { 'Content-Type' => 'application/json' } }
|
132
132
|
else
|
133
|
-
raise Ably::Exceptions::TokenExpired.new('Authentication failure', 401,
|
133
|
+
raise Ably::Exceptions::TokenExpired.new('Authentication failure', 401, 40142)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
@@ -16,7 +16,7 @@ shared_examples 'a safe Deferrable' do
|
|
16
16
|
subject.errback do |*args|
|
17
17
|
expect(args).to eql(arguments)
|
18
18
|
end
|
19
|
-
subject.fail
|
19
|
+
subject.fail(*arguments)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'catches exceptions in the callback and logs the error to the logger' do
|
@@ -34,7 +34,7 @@ shared_examples 'a safe Deferrable' do
|
|
34
34
|
subject.errback { errback_calls << true }
|
35
35
|
subject.callback { success_calls << true }
|
36
36
|
end
|
37
|
-
subject.fail
|
37
|
+
subject.fail(*arguments)
|
38
38
|
expect(errback_calls.count).to eql(3)
|
39
39
|
expect(success_calls.count).to eql(0)
|
40
40
|
end
|
@@ -45,7 +45,7 @@ shared_examples 'a safe Deferrable' do
|
|
45
45
|
subject.callback do |*args|
|
46
46
|
expect(args).to eql(arguments)
|
47
47
|
end
|
48
|
-
subject.succeed
|
48
|
+
subject.succeed(*arguments)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'catches exceptions in the callback and logs the error to the logger' do
|
@@ -63,7 +63,7 @@ shared_examples 'a safe Deferrable' do
|
|
63
63
|
subject.errback { errback_calls << true }
|
64
64
|
subject.callback { success_calls << true }
|
65
65
|
end
|
66
|
-
subject.succeed
|
66
|
+
subject.succeed(*arguments)
|
67
67
|
expect(success_calls.count).to eql(3)
|
68
68
|
expect(errback_calls.count).to eql(0)
|
69
69
|
end
|
@@ -85,7 +85,7 @@ describe Ably::Models::MessageEncoders::Cipher do
|
|
85
85
|
let(:decode_method) { subject.decode message, { encrypted: true, cipher_params: cipher_params } }
|
86
86
|
|
87
87
|
it 'raise an exception' do
|
88
|
-
expect { decode_method }.to raise_error Ably::Exceptions::CipherError, /Cipher algorithm [\w
|
88
|
+
expect { decode_method }.to raise_error Ably::Exceptions::CipherError, /Cipher algorithm [\w-]+ does not match message cipher algorithm of AES-128-CBC/
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -23,31 +23,33 @@ describe Ably::Models::TokenDetails do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
context do
|
27
27
|
let(:time) { Time.now }
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
{ :issued => :issued, :expires => :expires }.each do |method_name, attribute|
|
29
|
+
context "##{method_name} with :#{method_name} option as milliseconds in constructor" do
|
30
|
+
subject { Ably::Models::TokenDetails.new({ attribute.to_sym => time.to_i * 1000 }) }
|
31
|
+
|
32
|
+
it "retrieves attribute :#{attribute} as Time" do
|
33
|
+
expect(subject.public_send(method_name)).to be_a(Time)
|
34
|
+
expect(subject.public_send(method_name).to_i).to eql(time.to_i)
|
35
|
+
end
|
34
36
|
end
|
35
|
-
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
context "##{method_name} with :#{method_name} option as a Time in constructor" do
|
39
|
+
subject { Ably::Models::TokenDetails.new({ attribute.to_sym => time }) }
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
it "retrieves attribute :#{attribute} as Time" do
|
42
|
+
expect(subject.public_send(method_name)).to be_a(Time)
|
43
|
+
expect(subject.public_send(method_name).to_i).to eql(time.to_i)
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
context "##{method_name} when converted to JSON" do
|
48
|
+
subject { Ably::Models::TokenDetails.new({ attribute.to_sym => time }) }
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
it 'is in milliseconds' do
|
51
|
+
expect(JSON.parse(JSON.dump(subject))[convert_to_mixed_case(attribute)]).to eql((time.to_f * 1000).round)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -75,8 +75,8 @@ describe Ably::Modules::EventEmitter do
|
|
75
75
|
2.times do
|
76
76
|
subject.on(:message) do |msg|
|
77
77
|
obj.received_message msg
|
78
|
-
subject.on(:message) do |
|
79
|
-
obj.received_message_from_new_callbacks
|
78
|
+
subject.on(:message) do |message|
|
79
|
+
obj.received_message_from_new_callbacks message
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -30,11 +30,11 @@ describe Ably::Modules::StateEmitter do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
specify '#state= sets current state' do
|
33
|
-
expect { subject.state = :connecting }.to change { subject.state }.to(:connecting)
|
33
|
+
expect { subject.state = :connecting }.to change { subject.state.to_sym }.to(:connecting)
|
34
34
|
end
|
35
35
|
|
36
36
|
specify '#change_state sets current state' do
|
37
|
-
expect { subject.change_state :connecting }.to change { subject.state }.to(:connecting)
|
37
|
+
expect { subject.change_state :connecting }.to change { subject.state.to_sym }.to(:connecting)
|
38
38
|
end
|
39
39
|
|
40
40
|
context '#change_state with arguments' do
|
@@ -46,7 +46,7 @@ describe Ably::Modules::StateEmitter do
|
|
46
46
|
expect(callback_args).to eql(args)
|
47
47
|
callback_status[:called] = true
|
48
48
|
end
|
49
|
-
expect { subject.change_state :connecting, *args }.to change { subject.state }.to(:connecting)
|
49
|
+
expect { subject.change_state :connecting, *args }.to change { subject.state.to_sym }.to(:connecting)
|
50
50
|
expect(callback_status).to eql(called: true)
|
51
51
|
end
|
52
52
|
end
|
@@ -320,13 +320,13 @@ describe Ably::Modules::StateEmitter do
|
|
320
320
|
end
|
321
321
|
|
322
322
|
it 'is not called if the state does not change' do
|
323
|
-
subject.once_state_changed
|
323
|
+
subject.once_state_changed(&block)
|
324
324
|
subject.change_state initial_state
|
325
325
|
expect(block_calls.count).to eql(0)
|
326
326
|
end
|
327
327
|
|
328
328
|
it 'calls the block for any state change once' do
|
329
|
-
subject.once_state_changed
|
329
|
+
subject.once_state_changed(&block)
|
330
330
|
3.times do
|
331
331
|
subject.change_state :connected
|
332
332
|
subject.change_state :connecting
|
@@ -335,7 +335,7 @@ describe Ably::Modules::StateEmitter do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it 'emits arguments to the block' do
|
338
|
-
subject.once_state_changed
|
338
|
+
subject.once_state_changed(&block)
|
339
339
|
subject.change_state :connected, 1, 2
|
340
340
|
expect(block_calls.count).to eql(1)
|
341
341
|
expect(block_calls.first).to contain_exactly(1, 2)
|
@@ -212,25 +212,25 @@ describe Ably::Realtime::Channel do
|
|
212
212
|
end
|
213
213
|
|
214
214
|
specify 'with no event name specified unsubscribes that block from all events' do
|
215
|
-
subject.unsubscribe
|
215
|
+
subject.unsubscribe(&callback)
|
216
216
|
subject.__incoming_msgbus__.publish(:message, click_message)
|
217
217
|
expect(message_history[:received]).to eql(0)
|
218
218
|
end
|
219
219
|
|
220
220
|
specify 'with a single event name argument unsubscribes the provided block with the matching event name' do
|
221
|
-
subject.unsubscribe
|
221
|
+
subject.unsubscribe(click_event, &callback)
|
222
222
|
subject.__incoming_msgbus__.publish(:message, click_message)
|
223
223
|
expect(message_history[:received]).to eql(0)
|
224
224
|
end
|
225
225
|
|
226
226
|
specify 'with multiple event name arguments unsubscribes each of those matching event names with the provided block' do
|
227
|
-
subject.unsubscribe
|
227
|
+
subject.unsubscribe(focus_event, click_event, &callback)
|
228
228
|
subject.__incoming_msgbus__.publish(:message, click_message)
|
229
229
|
expect(message_history[:received]).to eql(0)
|
230
230
|
end
|
231
231
|
|
232
232
|
specify 'with a non-matching event name argument has no effect' do
|
233
|
-
subject.unsubscribe
|
233
|
+
subject.unsubscribe('move', &callback)
|
234
234
|
subject.__incoming_msgbus__.publish(:message, click_message)
|
235
235
|
expect(message_history[:received]).to eql(1)
|
236
236
|
end
|
@@ -54,7 +54,7 @@ describe Ably::Realtime::Connection do
|
|
54
54
|
it 'registers a callback' do
|
55
55
|
subject.on_resume { callbacks << true }
|
56
56
|
additional_proc = proc { raise 'This should not be called' }
|
57
|
-
subject.off_resume
|
57
|
+
subject.off_resume(&additional_proc)
|
58
58
|
subject.resumed
|
59
59
|
expect(callbacks.count).to eql(1)
|
60
60
|
end
|
@@ -104,31 +104,31 @@ describe Ably::Realtime::Presence do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
specify 'with no action specified unsubscribes that block from all events' do
|
107
|
-
subject.unsubscribe
|
107
|
+
subject.unsubscribe(&callback)
|
108
108
|
subject.__incoming_msgbus__.publish(:presence, enter_message)
|
109
109
|
expect(message_history[:received]).to eql(0)
|
110
110
|
end
|
111
111
|
|
112
112
|
specify 'with a single action argument unsubscribes the provided block with the matching action' do
|
113
|
-
subject.unsubscribe
|
113
|
+
subject.unsubscribe(enter_action, &callback)
|
114
114
|
subject.__incoming_msgbus__.publish(:presence, enter_message)
|
115
115
|
expect(message_history[:received]).to eql(0)
|
116
116
|
end
|
117
117
|
|
118
118
|
specify 'with multiple action arguments unsubscribes each of those matching actions with the provided block' do
|
119
|
-
subject.unsubscribe
|
119
|
+
subject.unsubscribe(:update, :leave, enter_action, &callback)
|
120
120
|
subject.__incoming_msgbus__.publish(:presence, enter_message)
|
121
121
|
expect(message_history[:received]).to eql(0)
|
122
122
|
end
|
123
123
|
|
124
124
|
specify 'with a non-matching action argument has no effect' do
|
125
|
-
subject.unsubscribe
|
125
|
+
subject.unsubscribe(:leave, &callback)
|
126
126
|
subject.__incoming_msgbus__.publish(:presence, enter_message)
|
127
127
|
expect(message_history[:received]).to eql(1)
|
128
128
|
end
|
129
129
|
|
130
130
|
specify 'with no block argument unsubscribes all blocks for the action argument' do
|
131
|
-
subject.unsubscribe
|
131
|
+
subject.unsubscribe(enter_action)
|
132
132
|
subject.__incoming_msgbus__.publish(:presence, enter_message)
|
133
133
|
expect(message_history[:received]).to eql(0)
|
134
134
|
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: 0.8.
|
4
|
+
version: 0.8.8
|
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: 2016-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0.
|
90
|
+
version: '0.6'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0.
|
97
|
+
version: '0.6'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: msgpack
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -301,7 +301,7 @@ files:
|
|
301
301
|
- lib/ably/models/paginated_result.rb
|
302
302
|
- lib/ably/models/presence_message.rb
|
303
303
|
- lib/ably/models/protocol_message.rb
|
304
|
-
- lib/ably/models/
|
304
|
+
- lib/ably/models/stats.rb
|
305
305
|
- lib/ably/models/stats_types.rb
|
306
306
|
- lib/ably/models/token_details.rb
|
307
307
|
- lib/ably/models/token_request.rb
|