pubnub 4.0.27 → 4.0.28
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +8 -1
- data/.rubocop.yml +9 -3
- data/.travis.yml +6 -19
- data/CHANGELOG.md +86 -82
- data/Gemfile +7 -5
- data/Gemfile.lock +155 -157
- data/README.md +34 -34
- data/VERSION +1 -1
- data/gemfiles/celluloid_017.gemfile +4 -4
- data/gemfiles/celluloid_018.gemfile +4 -4
- data/gemfiles/celluloid_master.gemfile +4 -4
- data/gemfiles/concurrent-ruby-1.0.5.gem +0 -0
- data/gemfiles/concurrent-ruby-edge-0.3.1.gem +0 -0
- data/lib/pubnub.rb +3 -3
- data/lib/pubnub/client.rb +19 -16
- data/lib/pubnub/client/events.rb +5 -5
- data/lib/pubnub/client/getters_setters.rb +11 -12
- data/lib/pubnub/client/paged_history.rb +11 -9
- data/lib/pubnub/configuration.rb +1 -2
- data/lib/pubnub/constants.rb +47 -47
- data/lib/pubnub/crypto.rb +2 -2
- data/lib/pubnub/envelope.rb +7 -5
- data/lib/pubnub/error.rb +22 -15
- data/lib/pubnub/event.rb +24 -25
- data/lib/pubnub/event/formatter.rb +8 -5
- data/lib/pubnub/event/signature.rb +3 -3
- data/lib/pubnub/events/audit.rb +1 -1
- data/lib/pubnub/events/channel_registration.rb +10 -15
- data/lib/pubnub/events/delete_messages.rb +9 -9
- data/lib/pubnub/events/grant.rb +3 -3
- data/lib/pubnub/events/heartbeat.rb +4 -8
- data/lib/pubnub/events/here_now.rb +4 -8
- data/lib/pubnub/events/history.rb +10 -10
- data/lib/pubnub/events/leave.rb +2 -2
- data/lib/pubnub/events/presence.rb +1 -1
- data/lib/pubnub/events/publish.rb +3 -5
- data/lib/pubnub/events/revoke.rb +3 -3
- data/lib/pubnub/events/set_state.rb +3 -3
- data/lib/pubnub/events/state.rb +4 -6
- data/lib/pubnub/events/subscribe.rb +1 -1
- data/lib/pubnub/events/time.rb +2 -2
- data/lib/pubnub/events/where_now.rb +6 -6
- data/lib/pubnub/format.rb +73 -0
- data/lib/pubnub/formatter.rb +23 -21
- data/lib/pubnub/heart.rb +4 -4
- data/lib/pubnub/origin_manager.rb +3 -5
- data/lib/pubnub/pam.rb +5 -5
- data/lib/pubnub/schemas/envelope_schema.rb +1 -1
- data/lib/pubnub/subscribe_callback.rb +3 -3
- data/lib/pubnub/subscribe_event.rb +6 -10
- data/lib/pubnub/subscribe_event/formatter.rb +82 -80
- data/lib/pubnub/subscribe_event/heartbeat.rb +1 -1
- data/lib/pubnub/subscriber.rb +31 -32
- data/lib/pubnub/telemetry.rb +26 -27
- data/lib/pubnub/validators/audit.rb +3 -2
- data/lib/pubnub/validators/channel_registration.rb +6 -4
- data/lib/pubnub/validators/client.rb +1 -0
- data/lib/pubnub/validators/common_validator.rb +37 -31
- data/lib/pubnub/validators/delete.rb +5 -4
- data/lib/pubnub/validators/grant.rb +3 -2
- data/lib/pubnub/validators/history.rb +3 -2
- data/lib/pubnub/validators/leave.rb +3 -2
- data/lib/pubnub/validators/presence.rb +3 -2
- data/lib/pubnub/validators/publish.rb +15 -10
- data/lib/pubnub/validators/set_state.rb +0 -2
- data/lib/pubnub/validators/state.rb +3 -2
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +19 -18
- data/spec/examples/audit_examples_spec.rb +1268 -1418
- data/spec/examples/channel_registration_examples_spec.rb +655 -757
- data/spec/examples/delete_messages_examples_spec.rb +19 -21
- data/spec/examples/grant_examples_spec.rb +34028 -37920
- data/spec/examples/heartbeat_examples_spec.rb +583 -731
- data/spec/examples/here_now_examples_spec.rb +493 -569
- data/spec/examples/history_examples_spec.rb +979 -1127
- data/spec/examples/leave_examples_spec.rb +439 -551
- data/spec/examples/presence_examples_spec.rb +686 -830
- data/spec/examples/publish_examples_spec.rb +27223 -31547
- data/spec/examples/publish_with_ttl_spec.rb +11 -14
- data/spec/examples/revoke_examples_spec.rb +68048 -75828
- data/spec/examples/set_state_examples_spec.rb +295 -371
- data/spec/examples/state_examples_spec.rb +169 -197
- data/spec/examples/status_request_message_count_exceeded_spec.rb +16 -19
- data/spec/examples/subscribe_examples_spec.rb +43843 -52035
- data/spec/examples/time_examples_spec.rb +82 -98
- data/spec/examples/where_now_examples_spec.rb +88 -104
- data/spec/lib/client_spec.rb +99 -117
- data/spec/lib/connection_callback_spec.rb +27 -33
- data/spec/lib/custom_retries_examples_spec.rb +8 -11
- data/spec/lib/event_spec.rb +35 -42
- data/spec/lib/events/audit_spec.rb +19 -25
- data/spec/lib/events/channel_registration_spec.rb +17 -23
- data/spec/lib/events/delete_messages_spec.rb +14 -20
- data/spec/lib/events/grant_spec.rb +15 -21
- data/spec/lib/events/heartbeat_spec.rb +21 -27
- data/spec/lib/events/here_now_spec.rb +14 -20
- data/spec/lib/events/history_spec.rb +14 -20
- data/spec/lib/events/leave_spec.rb +14 -20
- data/spec/lib/events/presence_delta_spec.rb +15 -16
- data/spec/lib/events/presence_spec.rb +36 -45
- data/spec/lib/events/publish_spec.rb +33 -40
- data/spec/lib/events/revoke_spec.rb +16 -22
- data/spec/lib/events/state_spec.rb +16 -22
- data/spec/lib/events/subscribe_spec.rb +75 -85
- data/spec/lib/events/time_spec.rb +12 -18
- data/spec/lib/events/timeout_handling_spec.rb +8 -14
- data/spec/lib/events/where_now_spec.rb +14 -20
- data/spec/lib/keep_alive_spec.rb +4 -8
- data/spec/lib/multiple_ciphers_spec.rb +56 -60
- data/spec/lib/pubnub_spec.rb +10 -13
- data/spec/lib/signatures_spec.rb +118 -120
- data/spec/lib/ssl_error_spec.rb +14 -18
- data/spec/lib/super_admin_spec.rb +58 -66
- data/spec/lib/uuid_spec.rb +3 -4
- data/spec/spec_expectations.rb +3 -3
- data/spec/spec_helper.rb +29 -46
- metadata +52 -22
- data/lib/pubnub/message.rb +0 -43
@@ -1,246 +1,218 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::State do
|
4
4
|
around :each do |example|
|
5
|
-
Celluloid.boot
|
6
|
-
|
7
5
|
@fired = false
|
8
6
|
|
9
|
-
@callback = ->(_envelope) do
|
7
|
+
@callback = -> (_envelope) do
|
10
8
|
@fired = true
|
11
9
|
end
|
12
10
|
|
13
11
|
@pubnub = Pubnub.new(
|
14
|
-
publish_key:
|
15
|
-
subscribe_key:
|
16
|
-
uuid:
|
17
|
-
auth_key:
|
12
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
13
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
14
|
+
uuid: "ruby-test-uuid-client-one",
|
15
|
+
auth_key: "ruby-test-auth-client-one",
|
18
16
|
)
|
19
17
|
|
20
|
-
example.
|
21
|
-
Celluloid.shutdown
|
18
|
+
example.run_with_retry retry: 10
|
22
19
|
end
|
23
20
|
|
24
|
-
it
|
25
|
-
VCR.use_cassette(
|
26
|
-
envelope = @pubnub.state(channel: :demo, uuid:
|
27
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
28
|
-
expect(envelope.error?).to eq false
|
29
|
-
|
30
|
-
expect(envelope.status[:code]).to eq(200)
|
31
|
-
expect(envelope.status[:category]).to eq(:ack)
|
32
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
33
|
-
|
34
|
-
expect(envelope.result[:code]).to eq(200)
|
35
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
36
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
it '__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___block_' do
|
43
|
-
VCR.use_cassette('examples/state/9', record: :none) do
|
44
|
-
envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: true, &@callback)
|
45
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
46
|
-
expect(envelope.error?).to eq false
|
47
|
-
|
48
|
-
expect(envelope.status[:code]).to eq(200)
|
49
|
-
expect(envelope.status[:category]).to eq(:ack)
|
50
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
51
|
-
|
52
|
-
expect(envelope.result[:code]).to eq(200)
|
53
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
54
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
21
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback__nil_" do
|
22
|
+
VCR.use_cassette("examples/state/11", record: :none) do
|
23
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true)
|
24
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
25
|
+
expect(envelope.error?).to eq false
|
55
26
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
it '__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___lambda_' do
|
61
|
-
VCR.use_cassette('examples/state/10', record: :none) do
|
62
|
-
envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: true, callback: @callback)
|
63
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
64
|
-
expect(envelope.error?).to eq false
|
65
|
-
|
66
|
-
expect(envelope.status[:code]).to eq(200)
|
67
|
-
expect(envelope.status[:category]).to eq(:ack)
|
68
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
69
|
-
|
70
|
-
expect(envelope.result[:code]).to eq(200)
|
71
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
72
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
27
|
+
expect(envelope.status[:code]).to eq(200)
|
28
|
+
expect(envelope.status[:category]).to eq(:ack)
|
29
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
76
30
|
|
31
|
+
expect(envelope.result[:code]).to eq(200)
|
32
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
33
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
34
|
+
end
|
35
|
+
end
|
77
36
|
|
78
|
-
it
|
79
|
-
VCR.use_cassette(
|
80
|
-
envelope = @pubnub.state(channel: :demo, uuid:
|
81
|
-
envelope
|
82
|
-
expect(envelope.
|
83
|
-
expect(envelope.error?).to eq false
|
84
|
-
|
85
|
-
expect(envelope.status[:code]).to eq(200)
|
86
|
-
expect(envelope.status[:category]).to eq(:ack)
|
87
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
88
|
-
|
89
|
-
expect(envelope.result[:code]).to eq(200)
|
90
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
91
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
it '__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___block_' do
|
98
|
-
VCR.use_cassette('examples/state/6', record: :none) do
|
99
|
-
envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: false, &@callback)
|
100
|
-
envelope = envelope.value
|
101
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
102
|
-
expect(envelope.error?).to eq false
|
103
|
-
|
104
|
-
expect(envelope.status[:code]).to eq(200)
|
105
|
-
expect(envelope.status[:category]).to eq(:ack)
|
106
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
107
|
-
|
108
|
-
expect(envelope.result[:code]).to eq(200)
|
109
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
110
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
it '__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___lambda_' do
|
117
|
-
VCR.use_cassette('examples/state/7', record: :none) do
|
118
|
-
envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: false, callback: @callback)
|
119
|
-
envelope = envelope.value
|
120
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
121
|
-
expect(envelope.error?).to eq false
|
122
|
-
|
123
|
-
expect(envelope.status[:code]).to eq(200)
|
124
|
-
expect(envelope.status[:category]).to eq(:ack)
|
125
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
126
|
-
|
127
|
-
expect(envelope.result[:code]).to eq(200)
|
128
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
129
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
37
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___block_" do
|
38
|
+
VCR.use_cassette("examples/state/9", record: :none) do
|
39
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true, &@callback)
|
40
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
41
|
+
expect(envelope.error?).to eq false
|
133
42
|
|
43
|
+
expect(envelope.status[:code]).to eq(200)
|
44
|
+
expect(envelope.status[:category]).to eq(:ack)
|
45
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
134
46
|
|
135
|
-
|
136
|
-
|
137
|
-
envelope
|
138
|
-
|
139
|
-
|
47
|
+
expect(envelope.result[:code]).to eq(200)
|
48
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
49
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
50
|
+
end
|
51
|
+
end
|
140
52
|
|
141
|
-
|
142
|
-
|
143
|
-
|
53
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___lambda_" do
|
54
|
+
VCR.use_cassette("examples/state/10", record: :none) do
|
55
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true, callback: @callback)
|
56
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
57
|
+
expect(envelope.error?).to eq false
|
144
58
|
|
145
|
-
expect(envelope.
|
146
|
-
expect(envelope.
|
147
|
-
expect(envelope.
|
59
|
+
expect(envelope.status[:code]).to eq(200)
|
60
|
+
expect(envelope.status[:category]).to eq(:ack)
|
61
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
148
62
|
|
149
|
-
|
150
|
-
|
63
|
+
expect(envelope.result[:code]).to eq(200)
|
64
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
65
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
66
|
+
end
|
67
|
+
end
|
151
68
|
|
69
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback__nil_" do
|
70
|
+
VCR.use_cassette("examples/state/8", record: :none) do
|
71
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false)
|
72
|
+
envelope = envelope.value
|
73
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
74
|
+
expect(envelope.error?).to eq false
|
152
75
|
|
153
|
-
|
154
|
-
|
155
|
-
envelope
|
156
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
157
|
-
expect(envelope.error?).to eq false
|
76
|
+
expect(envelope.status[:code]).to eq(200)
|
77
|
+
expect(envelope.status[:category]).to eq(:ack)
|
78
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
158
79
|
|
159
|
-
expect(envelope.
|
160
|
-
expect(envelope.
|
161
|
-
expect(envelope.
|
80
|
+
expect(envelope.result[:code]).to eq(200)
|
81
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
82
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
83
|
+
end
|
84
|
+
end
|
162
85
|
|
163
|
-
|
164
|
-
|
165
|
-
|
86
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___block_" do
|
87
|
+
VCR.use_cassette("examples/state/6", record: :none) do
|
88
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false, &@callback)
|
89
|
+
envelope = envelope.value
|
90
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
91
|
+
expect(envelope.error?).to eq false
|
166
92
|
|
167
|
-
|
168
|
-
|
93
|
+
expect(envelope.status[:code]).to eq(200)
|
94
|
+
expect(envelope.status[:category]).to eq(:ack)
|
95
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
169
96
|
|
97
|
+
expect(envelope.result[:code]).to eq(200)
|
98
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
99
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
100
|
+
end
|
101
|
+
end
|
170
102
|
|
171
|
-
it
|
172
|
-
VCR.use_cassette(
|
173
|
-
envelope = @pubnub.state(channel:
|
174
|
-
|
175
|
-
expect(envelope.
|
103
|
+
it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___lambda_" do
|
104
|
+
VCR.use_cassette("examples/state/7", record: :none) do
|
105
|
+
envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false, callback: @callback)
|
106
|
+
envelope = envelope.value
|
107
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
108
|
+
expect(envelope.error?).to eq false
|
176
109
|
|
177
|
-
expect(envelope.status[:code]).to eq(200)
|
178
|
-
expect(envelope.status[:category]).to eq(:ack)
|
179
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
110
|
+
expect(envelope.status[:code]).to eq(200)
|
111
|
+
expect(envelope.status[:category]).to eq(:ack)
|
112
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
180
113
|
|
181
|
-
expect(envelope.result[:code]).to eq(200)
|
182
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
183
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
114
|
+
expect(envelope.result[:code]).to eq(200)
|
115
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
116
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
117
|
+
end
|
118
|
+
end
|
184
119
|
|
185
|
-
|
186
|
-
|
120
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback__nil_" do
|
121
|
+
VCR.use_cassette("examples/state/5", record: :none) do
|
122
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true)
|
123
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
124
|
+
expect(envelope.error?).to eq false
|
187
125
|
|
126
|
+
expect(envelope.status[:code]).to eq(200)
|
127
|
+
expect(envelope.status[:category]).to eq(:ack)
|
128
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
188
129
|
|
189
|
-
|
190
|
-
|
191
|
-
envelope
|
192
|
-
|
193
|
-
|
194
|
-
expect(envelope.error?).to eq false
|
130
|
+
expect(envelope.result[:code]).to eq(200)
|
131
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
132
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
133
|
+
end
|
134
|
+
end
|
195
135
|
|
196
|
-
|
197
|
-
|
198
|
-
|
136
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___block_" do
|
137
|
+
VCR.use_cassette("examples/state/3", record: :none) do
|
138
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true, &@callback)
|
139
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
140
|
+
expect(envelope.error?).to eq false
|
199
141
|
|
200
|
-
expect(envelope.
|
201
|
-
expect(envelope.
|
202
|
-
expect(envelope.
|
142
|
+
expect(envelope.status[:code]).to eq(200)
|
143
|
+
expect(envelope.status[:category]).to eq(:ack)
|
144
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
203
145
|
|
204
|
-
|
205
|
-
|
146
|
+
expect(envelope.result[:code]).to eq(200)
|
147
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
148
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
149
|
+
end
|
150
|
+
end
|
206
151
|
|
152
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___lambda_" do
|
153
|
+
VCR.use_cassette("examples/state/4", record: :none) do
|
154
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true, callback: @callback)
|
155
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
156
|
+
expect(envelope.error?).to eq false
|
207
157
|
|
208
|
-
|
209
|
-
|
210
|
-
envelope
|
211
|
-
envelope = envelope.value
|
212
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
213
|
-
expect(envelope.error?).to eq false
|
158
|
+
expect(envelope.status[:code]).to eq(200)
|
159
|
+
expect(envelope.status[:category]).to eq(:ack)
|
160
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
214
161
|
|
215
|
-
expect(envelope.
|
216
|
-
expect(envelope.
|
217
|
-
expect(envelope.
|
162
|
+
expect(envelope.result[:code]).to eq(200)
|
163
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
164
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
165
|
+
end
|
166
|
+
end
|
218
167
|
|
219
|
-
|
220
|
-
|
221
|
-
|
168
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback__nil_" do
|
169
|
+
VCR.use_cassette("examples/state/2", record: :none) do
|
170
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false)
|
171
|
+
envelope = envelope.value
|
172
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
173
|
+
expect(envelope.error?).to eq false
|
222
174
|
|
223
|
-
|
224
|
-
|
175
|
+
expect(envelope.status[:code]).to eq(200)
|
176
|
+
expect(envelope.status[:category]).to eq(:ack)
|
177
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
225
178
|
|
179
|
+
expect(envelope.result[:code]).to eq(200)
|
180
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
181
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
182
|
+
end
|
183
|
+
end
|
226
184
|
|
227
|
-
it
|
228
|
-
VCR.use_cassette(
|
229
|
-
envelope = @pubnub.state(channel:
|
230
|
-
envelope = envelope.value
|
231
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
232
|
-
expect(envelope.error?).to eq false
|
185
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___block_" do
|
186
|
+
VCR.use_cassette("examples/state/0", record: :none) do
|
187
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false, &@callback)
|
188
|
+
envelope = envelope.value
|
189
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
190
|
+
expect(envelope.error?).to eq false
|
233
191
|
|
234
|
-
expect(envelope.status[:code]).to eq(200)
|
235
|
-
expect(envelope.status[:category]).to eq(:ack)
|
236
|
-
expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
192
|
+
expect(envelope.status[:code]).to eq(200)
|
193
|
+
expect(envelope.status[:category]).to eq(:ack)
|
194
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
237
195
|
|
238
|
-
expect(envelope.result[:code]).to eq(200)
|
239
|
-
expect(envelope.result[:operation]).to eq(:get_state)
|
240
|
-
expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
|
196
|
+
expect(envelope.result[:code]).to eq(200)
|
197
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
198
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
199
|
+
end
|
200
|
+
end
|
241
201
|
|
242
|
-
|
243
|
-
|
202
|
+
it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___lambda_" do
|
203
|
+
VCR.use_cassette("examples/state/1", record: :none) do
|
204
|
+
envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false, callback: @callback)
|
205
|
+
envelope = envelope.value
|
206
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
207
|
+
expect(envelope.error?).to eq false
|
244
208
|
|
209
|
+
expect(envelope.status[:code]).to eq(200)
|
210
|
+
expect(envelope.status[:category]).to eq(:ack)
|
211
|
+
expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
245
212
|
|
213
|
+
expect(envelope.result[:code]).to eq(200)
|
214
|
+
expect(envelope.result[:operation]).to eq(:get_state)
|
215
|
+
expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
|
216
|
+
end
|
217
|
+
end
|
246
218
|
end
|
@@ -1,41 +1,38 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe 'Status request message count exceeded' do
|
1
|
+
require "spec_helper"
|
4
2
|
|
3
|
+
describe "Status request message count exceeded" do
|
5
4
|
around :each do |example|
|
6
|
-
|
7
|
-
example.run
|
8
|
-
Celluloid.shutdown
|
5
|
+
example.run_with_retry retry: 10
|
9
6
|
end
|
10
7
|
|
11
8
|
before(:each) do
|
12
|
-
@messages
|
13
|
-
@statuses
|
9
|
+
@messages = []
|
10
|
+
@statuses = []
|
14
11
|
@presences = []
|
15
12
|
|
16
13
|
@callbacks = Pubnub::SubscribeCallback.new(
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
message: -> (envelope) { @messages << envelope },
|
15
|
+
presence: -> (envelope) { @presences << envelope },
|
16
|
+
status: -> (envelope) { @statuses << envelope },
|
20
17
|
)
|
21
18
|
|
22
19
|
@pubnub = Pubnub.new(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
subscribe_key: "demo",
|
21
|
+
publish_key: "demo",
|
22
|
+
uuid: "ruby-test",
|
23
|
+
request_message_count_threshold: 100,
|
27
24
|
)
|
28
25
|
|
29
26
|
@pubnub.add_listener(callback: @callbacks)
|
30
27
|
end
|
31
28
|
|
32
|
-
it
|
33
|
-
|
34
|
-
|
29
|
+
it "works" do
|
30
|
+
VCR.use_cassette("examples/status_request_message_count_exceeded", record: :once) do
|
31
|
+
@pubnub.subscribe(channel: :demo)
|
35
32
|
|
36
33
|
eventually do
|
37
34
|
expect(@statuses[1].status[:category]).to eq(Pubnub::Constants::STATUS_REQUEST_MESSAGE_COUNT_EXCEEDED)
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
41
|
-
end
|
38
|
+
end
|