pubnub 4.0.27 → 4.0.28
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.
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,129 +1,113 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Time 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.time(http_sync: true)
|
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(:time)
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
it '__http_sync__true___callback___block_' do
|
42
|
-
VCR.use_cassette('examples/time/3', record: :none) do
|
43
|
-
envelope = @pubnub.time(http_sync: true, &@callback)
|
44
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
45
|
-
expect(envelope.error?).to eq false
|
46
|
-
|
47
|
-
expect(envelope.status[:code]).to eq(200)
|
48
|
-
expect(envelope.status[:category]).to eq(:ack)
|
49
|
-
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"})
|
50
|
-
|
51
|
-
expect(envelope.result[:code]).to eq(200)
|
52
|
-
expect(envelope.result[:operation]).to eq(:time)
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
it '__http_sync__true___callback___lambda_' do
|
59
|
-
VCR.use_cassette('examples/time/4', record: :none) do
|
60
|
-
envelope = @pubnub.time(http_sync: true, callback: @callback)
|
61
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
62
|
-
expect(envelope.error?).to eq false
|
63
|
-
|
64
|
-
expect(envelope.status[:code]).to eq(200)
|
65
|
-
expect(envelope.status[:category]).to eq(:ack)
|
66
|
-
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"})
|
67
|
-
|
68
|
-
expect(envelope.result[:code]).to eq(200)
|
69
|
-
expect(envelope.result[:operation]).to eq(:time)
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
21
|
+
it "__http_sync__true___callback__nil_" do
|
22
|
+
VCR.use_cassette("examples/time/5", record: :none) do
|
23
|
+
envelope = @pubnub.time(http_sync: true)
|
24
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
25
|
+
expect(envelope.error?).to eq false
|
73
26
|
|
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"})
|
74
30
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
80
|
-
expect(envelope.error?).to eq false
|
31
|
+
expect(envelope.result[:code]).to eq(200)
|
32
|
+
expect(envelope.result[:operation]).to eq(:time)
|
33
|
+
end
|
34
|
+
end
|
81
35
|
|
82
|
-
|
83
|
-
|
84
|
-
|
36
|
+
it "__http_sync__true___callback___block_" do
|
37
|
+
VCR.use_cassette("examples/time/3", record: :none) do
|
38
|
+
envelope = @pubnub.time(http_sync: true, &@callback)
|
39
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
40
|
+
expect(envelope.error?).to eq false
|
85
41
|
|
86
|
-
expect(envelope.
|
87
|
-
expect(envelope.
|
42
|
+
expect(envelope.status[:code]).to eq(200)
|
43
|
+
expect(envelope.status[:category]).to eq(:ack)
|
44
|
+
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
45
|
|
89
|
-
|
90
|
-
|
46
|
+
expect(envelope.result[:code]).to eq(200)
|
47
|
+
expect(envelope.result[:operation]).to eq(:time)
|
48
|
+
end
|
49
|
+
end
|
91
50
|
|
51
|
+
it "__http_sync__true___callback___lambda_" do
|
52
|
+
VCR.use_cassette("examples/time/4", record: :none) do
|
53
|
+
envelope = @pubnub.time(http_sync: true, callback: @callback)
|
54
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
55
|
+
expect(envelope.error?).to eq false
|
92
56
|
|
93
|
-
|
94
|
-
|
95
|
-
envelope
|
96
|
-
envelope = envelope.value
|
97
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
98
|
-
expect(envelope.error?).to eq false
|
57
|
+
expect(envelope.status[:code]).to eq(200)
|
58
|
+
expect(envelope.status[:category]).to eq(:ack)
|
59
|
+
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"})
|
99
60
|
|
100
|
-
expect(envelope.
|
101
|
-
expect(envelope.
|
102
|
-
|
61
|
+
expect(envelope.result[:code]).to eq(200)
|
62
|
+
expect(envelope.result[:operation]).to eq(:time)
|
63
|
+
end
|
64
|
+
end
|
103
65
|
|
104
|
-
|
105
|
-
|
66
|
+
it "__http_sync__false___callback__nil_" do
|
67
|
+
VCR.use_cassette("examples/time/2", record: :none) do
|
68
|
+
envelope = @pubnub.time(http_sync: false)
|
69
|
+
envelope = envelope.value
|
70
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
71
|
+
expect(envelope.error?).to eq false
|
106
72
|
|
107
|
-
|
108
|
-
|
73
|
+
expect(envelope.status[:code]).to eq(200)
|
74
|
+
expect(envelope.status[:category]).to eq(:ack)
|
75
|
+
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"})
|
109
76
|
|
77
|
+
expect(envelope.result[:code]).to eq(200)
|
78
|
+
expect(envelope.result[:operation]).to eq(:time)
|
79
|
+
end
|
80
|
+
end
|
110
81
|
|
111
|
-
it
|
112
|
-
VCR.use_cassette(
|
113
|
-
envelope = @pubnub.time(http_sync: false, callback
|
114
|
-
envelope = envelope.value
|
115
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
116
|
-
expect(envelope.error?).to eq false
|
82
|
+
it "__http_sync__false___callback___block_" do
|
83
|
+
VCR.use_cassette("examples/time/0", record: :none) do
|
84
|
+
envelope = @pubnub.time(http_sync: false, &@callback)
|
85
|
+
envelope = envelope.value
|
86
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
87
|
+
expect(envelope.error?).to eq false
|
117
88
|
|
118
|
-
expect(envelope.status[:code]).to eq(200)
|
119
|
-
expect(envelope.status[:category]).to eq(:ack)
|
120
|
-
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"})
|
89
|
+
expect(envelope.status[:code]).to eq(200)
|
90
|
+
expect(envelope.status[:category]).to eq(:ack)
|
91
|
+
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"})
|
121
92
|
|
122
|
-
expect(envelope.result[:code]).to eq(200)
|
123
|
-
expect(envelope.result[:operation]).to eq(:time)
|
93
|
+
expect(envelope.result[:code]).to eq(200)
|
94
|
+
expect(envelope.result[:operation]).to eq(:time)
|
95
|
+
end
|
96
|
+
end
|
124
97
|
|
125
|
-
|
126
|
-
|
98
|
+
it "__http_sync__false___callback___lambda_" do
|
99
|
+
VCR.use_cassette("examples/time/1", record: :none) do
|
100
|
+
envelope = @pubnub.time(http_sync: false, callback: @callback)
|
101
|
+
envelope = envelope.value
|
102
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
103
|
+
expect(envelope.error?).to eq false
|
127
104
|
|
105
|
+
expect(envelope.status[:code]).to eq(200)
|
106
|
+
expect(envelope.status[:category]).to eq(:ack)
|
107
|
+
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"})
|
128
108
|
|
109
|
+
expect(envelope.result[:code]).to eq(200)
|
110
|
+
expect(envelope.result[:operation]).to eq(:time)
|
111
|
+
end
|
112
|
+
end
|
129
113
|
end
|
@@ -1,135 +1,119 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::WhereNow 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.where_now(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(:where_now)
|
36
|
-
expect(envelope.result[:data]).to eq({"channels"=>[]})
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
it '__uuid___ruby-test-uuid____http_sync__true___callback___block_' do
|
43
|
-
VCR.use_cassette('examples/where_now/3', record: :none) do
|
44
|
-
envelope = @pubnub.where_now(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(:where_now)
|
54
|
-
expect(envelope.result[:data]).to eq({"channels"=>[]})
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
it '__uuid___ruby-test-uuid____http_sync__true___callback___lambda_' do
|
61
|
-
VCR.use_cassette('examples/where_now/4', record: :none) do
|
62
|
-
envelope = @pubnub.where_now(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(:where_now)
|
72
|
-
expect(envelope.result[:data]).to eq({"channels"=>[]})
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
21
|
+
it "__uuid___ruby-test-uuid____http_sync__true___callback__nil_" do
|
22
|
+
VCR.use_cassette("examples/where_now/5", record: :none) do
|
23
|
+
envelope = @pubnub.where_now(uuid: "ruby-test-uuid", http_sync: true)
|
24
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
25
|
+
expect(envelope.error?).to eq false
|
76
26
|
|
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"})
|
77
30
|
|
78
|
-
|
79
|
-
|
80
|
-
envelope
|
81
|
-
|
82
|
-
|
83
|
-
expect(envelope.error?).to eq false
|
31
|
+
expect(envelope.result[:code]).to eq(200)
|
32
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
33
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
34
|
+
end
|
35
|
+
end
|
84
36
|
|
85
|
-
|
86
|
-
|
87
|
-
|
37
|
+
it "__uuid___ruby-test-uuid____http_sync__true___callback___block_" do
|
38
|
+
VCR.use_cassette("examples/where_now/3", record: :none) do
|
39
|
+
envelope = @pubnub.where_now(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
|
88
42
|
|
89
|
-
expect(envelope.
|
90
|
-
expect(envelope.
|
91
|
-
expect(envelope.
|
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"})
|
92
46
|
|
93
|
-
|
94
|
-
|
47
|
+
expect(envelope.result[:code]).to eq(200)
|
48
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
49
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
50
|
+
end
|
51
|
+
end
|
95
52
|
|
53
|
+
it "__uuid___ruby-test-uuid____http_sync__true___callback___lambda_" do
|
54
|
+
VCR.use_cassette("examples/where_now/4", record: :none) do
|
55
|
+
envelope = @pubnub.where_now(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
|
96
58
|
|
97
|
-
|
98
|
-
|
99
|
-
envelope
|
100
|
-
envelope = envelope.value
|
101
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
102
|
-
expect(envelope.error?).to eq false
|
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"})
|
103
62
|
|
104
|
-
expect(envelope.
|
105
|
-
expect(envelope.
|
106
|
-
expect(envelope.
|
63
|
+
expect(envelope.result[:code]).to eq(200)
|
64
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
65
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
66
|
+
end
|
67
|
+
end
|
107
68
|
|
108
|
-
|
109
|
-
|
110
|
-
|
69
|
+
it "__uuid___ruby-test-uuid____http_sync__false___callback__nil_" do
|
70
|
+
VCR.use_cassette("examples/where_now/2", record: :none) do
|
71
|
+
envelope = @pubnub.where_now(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
|
111
75
|
|
112
|
-
|
113
|
-
|
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"})
|
114
79
|
|
80
|
+
expect(envelope.result[:code]).to eq(200)
|
81
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
82
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
83
|
+
end
|
84
|
+
end
|
115
85
|
|
116
|
-
it
|
117
|
-
VCR.use_cassette(
|
118
|
-
envelope = @pubnub.where_now(uuid:
|
119
|
-
envelope = envelope.value
|
120
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
121
|
-
expect(envelope.error?).to eq false
|
86
|
+
it "__uuid___ruby-test-uuid____http_sync__false___callback___block_" do
|
87
|
+
VCR.use_cassette("examples/where_now/0", record: :none) do
|
88
|
+
envelope = @pubnub.where_now(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
|
122
92
|
|
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"})
|
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"})
|
126
96
|
|
127
|
-
expect(envelope.result[:code]).to eq(200)
|
128
|
-
expect(envelope.result[:operation]).to eq(:where_now)
|
129
|
-
expect(envelope.result[:data]).to eq({"channels"=>[]})
|
97
|
+
expect(envelope.result[:code]).to eq(200)
|
98
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
99
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
100
|
+
end
|
101
|
+
end
|
130
102
|
|
131
|
-
|
132
|
-
|
103
|
+
it "__uuid___ruby-test-uuid____http_sync__false___callback___lambda_" do
|
104
|
+
VCR.use_cassette("examples/where_now/1", record: :none) do
|
105
|
+
envelope = @pubnub.where_now(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
|
133
109
|
|
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"})
|
134
113
|
|
114
|
+
expect(envelope.result[:code]).to eq(200)
|
115
|
+
expect(envelope.result[:operation]).to eq(:where_now)
|
116
|
+
expect(envelope.result[:data]).to eq({"channels" => []})
|
117
|
+
end
|
118
|
+
end
|
135
119
|
end
|
data/spec/lib/client_spec.rb
CHANGED
@@ -1,33 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Client do
|
4
|
-
|
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
|
-
it
|
8
|
+
it "has valid version constant" do
|
12
9
|
expect(Pubnub::Client::VERSION).to match(/\d+\.\d+\..+/)
|
13
10
|
end
|
14
11
|
|
15
|
-
context
|
16
|
-
it
|
12
|
+
context "#initialize" do
|
13
|
+
it "returns new Pubnub::Client" do
|
17
14
|
pubnub = Pubnub.new(subscribe_key: :key)
|
18
15
|
expect(pubnub.is_a?(Pubnub::Client)).to eq true
|
19
16
|
end
|
20
17
|
|
21
|
-
it
|
18
|
+
it "requires arguments" do
|
22
19
|
expect { Pubnub.new }.to raise_error(Pubnub::InitializationError)
|
23
20
|
end
|
24
21
|
|
25
|
-
it
|
22
|
+
it "by default sets Pubnub.logger that logs to pubnub.log" do
|
26
23
|
_pubnub = Pubnub.new(subscribe_key: :key)
|
27
|
-
expect(Pubnub.logger.instance_eval(
|
24
|
+
expect(Pubnub.logger.instance_eval("@logdev").filename).to eq "pubnub.log"
|
28
25
|
end
|
29
26
|
|
30
|
-
it
|
27
|
+
it "sets Pubnub.logger to new one if given" do
|
31
28
|
_rd, wr = IO.pipe
|
32
29
|
|
33
30
|
logger = Logger.new(wr)
|
@@ -35,8 +32,8 @@ describe Pubnub::Client do
|
|
35
32
|
expect(Pubnub.logger).to eq(logger)
|
36
33
|
end
|
37
34
|
|
38
|
-
it
|
39
|
-
pubnub = Pubnub.new(subscribe_key:
|
35
|
+
it "creates required pools" do
|
36
|
+
pubnub = Pubnub.new(subscribe_key: "key")
|
40
37
|
|
41
38
|
# Connections
|
42
39
|
expect(pubnub.env[:single_event_conn_pool]).to eq({})
|
@@ -50,89 +47,79 @@ describe Pubnub::Client do
|
|
50
47
|
expect(pubnub.env[:subscription_pool]).to eq({})
|
51
48
|
end
|
52
49
|
|
53
|
-
context
|
54
|
-
|
55
|
-
|
56
|
-
pubnub = Pubnub.new('subscribe_key' => 'key')
|
50
|
+
context "parameters" do
|
51
|
+
it "changes string keys to sym keys" do
|
52
|
+
pubnub = Pubnub.new("subscribe_key" => "key")
|
57
53
|
pubnub.env.each_key do |key|
|
58
54
|
expect(key.class).to eq Symbol
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
|
-
it
|
63
|
-
pubnub = Pubnub.new(publish_key:
|
58
|
+
it "removes empty parameters" do
|
59
|
+
pubnub = Pubnub.new(publish_key: "", subscribe_key: "key")
|
64
60
|
expect(pubnub.env[:publish_key]).to eq(nil)
|
65
61
|
end
|
66
62
|
|
67
|
-
it
|
68
|
-
pubnub = Pubnub.new(publish_key:
|
69
|
-
expect(pubnub.env[:subscribe_key]).to eq(
|
63
|
+
it "does not remove non-empty parameters" do
|
64
|
+
pubnub = Pubnub.new(publish_key: "", subscribe_key: "key")
|
65
|
+
expect(pubnub.env[:subscribe_key]).to eq("key")
|
70
66
|
end
|
71
67
|
|
72
|
-
context
|
73
|
-
context
|
74
|
-
it
|
75
|
-
expect { Pubnub.new(origin: 123, subscribe_key:
|
76
|
-
.to raise_error(Pubnub::InitializationError)
|
68
|
+
context "validates" do
|
69
|
+
context "parameter :origin" do
|
70
|
+
it "must be valid" do
|
71
|
+
expect { Pubnub.new(origin: 123, subscribe_key: "key") }.to raise_error(Pubnub::InitializationError)
|
77
72
|
|
78
|
-
expect { Pubnub.new(origin: {
|
79
|
-
.to raise_error(Pubnub::InitializationError)
|
73
|
+
expect { Pubnub.new(origin: {a: :b}, subscribe_key: "key") }.to raise_error(Pubnub::InitializationError)
|
80
74
|
|
81
|
-
expect { Pubnub.new(origin: nil, subscribe_key:
|
82
|
-
.not_to raise_error
|
75
|
+
expect { Pubnub.new(origin: nil, subscribe_key: "key") }.not_to raise_error
|
83
76
|
|
84
|
-
expect { Pubnub.new(origin:
|
85
|
-
.not_to raise_error
|
77
|
+
expect { Pubnub.new(origin: "", subscribe_key: "key") }.not_to raise_error
|
86
78
|
|
87
|
-
expect { Pubnub.new(origin:
|
88
|
-
.not_to raise_error
|
79
|
+
expect { Pubnub.new(origin: "http://a.com", subscribe_key: "key") }.not_to raise_error
|
89
80
|
end
|
90
81
|
end
|
91
82
|
|
92
|
-
context
|
93
|
-
it
|
94
|
-
expect { Pubnub.new(http_sync: true) }
|
95
|
-
.to raise_error(Pubnub::InitializationError)
|
83
|
+
context "parameter :subscribe_key" do
|
84
|
+
it "is required" do
|
85
|
+
expect { Pubnub.new(http_sync: true) }.to raise_error(Pubnub::InitializationError)
|
96
86
|
end
|
97
87
|
|
98
|
-
it
|
99
|
-
expect { Pubnub.new(subscribe_key: 123) }
|
100
|
-
.to raise_error(Pubnub::InitializationError)
|
88
|
+
it "must be valid" do
|
89
|
+
expect { Pubnub.new(subscribe_key: 123) }.to raise_error(Pubnub::InitializationError)
|
101
90
|
|
102
|
-
expect { Pubnub.new(subscribe_key: []) }
|
103
|
-
.to raise_error(Pubnub::InitializationError)
|
91
|
+
expect { Pubnub.new(subscribe_key: []) }.to raise_error(Pubnub::InitializationError)
|
104
92
|
|
105
|
-
expect { Pubnub.new(subscribe_key: {}) }
|
106
|
-
.to raise_error(Pubnub::InitializationError)
|
93
|
+
expect { Pubnub.new(subscribe_key: {}) }.to raise_error(Pubnub::InitializationError)
|
107
94
|
|
108
|
-
expect { Pubnub.new(subscribe_key:
|
95
|
+
expect { Pubnub.new(subscribe_key: "key") }.not_to raise_error
|
109
96
|
expect { Pubnub.new(subscribe_key: :key) }.not_to raise_error
|
110
97
|
end
|
111
98
|
end
|
112
99
|
|
113
|
-
context
|
114
|
-
it
|
100
|
+
context "parameter :publish_key" do
|
101
|
+
it "must be valid" do
|
115
102
|
expect do
|
116
|
-
Pubnub.new(subscribe_key:
|
103
|
+
Pubnub.new(subscribe_key: "valid", publish_key: ["invalid"])
|
117
104
|
end.to raise_error(Pubnub::InitializationError)
|
118
105
|
|
119
106
|
expect do
|
120
107
|
Pubnub.new(
|
121
|
-
|
122
|
-
|
108
|
+
subscribe_key: "valid",
|
109
|
+
publish_key: {invalid: "yeah"},
|
123
110
|
)
|
124
111
|
end.to raise_error(Pubnub::InitializationError)
|
125
112
|
|
126
113
|
expect do
|
127
|
-
Pubnub.new(subscribe_key:
|
114
|
+
Pubnub.new(subscribe_key: "valid", publish_key: ["invalid"])
|
128
115
|
end.to raise_error(Pubnub::InitializationError)
|
129
116
|
|
130
117
|
expect do
|
131
|
-
Pubnub.new(subscribe_key:
|
118
|
+
Pubnub.new(subscribe_key: "valid", publish_key: "key")
|
132
119
|
end.not_to raise_error
|
133
120
|
|
134
121
|
expect do
|
135
|
-
Pubnub.new(subscribe_key:
|
122
|
+
Pubnub.new(subscribe_key: "valid", publish_key: :key)
|
136
123
|
end.not_to raise_error
|
137
124
|
end
|
138
125
|
end
|
@@ -140,39 +127,39 @@ describe Pubnub::Client do
|
|
140
127
|
end
|
141
128
|
end
|
142
129
|
|
143
|
-
context
|
144
|
-
let(:pubnub_client) { Pubnub.new(subscribe_key:
|
130
|
+
context "timetoken manipulation" do
|
131
|
+
let(:pubnub_client) { Pubnub.new(subscribe_key: "demo") }
|
145
132
|
|
146
|
-
context
|
147
|
-
it
|
148
|
-
pubnub_client.env[:timetoken] =
|
149
|
-
expect(pubnub_client.timetoken).to eq
|
133
|
+
context "#timetoken" do
|
134
|
+
it "returns timetoken hold in env" do
|
135
|
+
pubnub_client.env[:timetoken] = "0987654321"
|
136
|
+
expect(pubnub_client.timetoken).to eq "0987654321"
|
150
137
|
end
|
151
138
|
end
|
152
139
|
|
153
|
-
context
|
154
|
-
it
|
155
|
-
pubnub_client.timetoken =
|
156
|
-
expect(pubnub_client.env[:timetoken]).to eq
|
140
|
+
context "#timetoken=" do
|
141
|
+
it "sets given timetoken in env" do
|
142
|
+
pubnub_client.timetoken = "1234567890"
|
143
|
+
expect(pubnub_client.env[:timetoken]).to eq "1234567890"
|
157
144
|
end
|
158
145
|
end
|
159
146
|
end
|
160
147
|
|
161
|
-
context
|
162
|
-
let(:pubnub_client) { Pubnub.new(subscribe_key:
|
148
|
+
context "callback listeners" do
|
149
|
+
let(:pubnub_client) { Pubnub.new(subscribe_key: "demo") }
|
163
150
|
|
164
|
-
it
|
151
|
+
it "can be added" do
|
165
152
|
callbacks = Pubnub::SubscribeCallback.new(
|
166
|
-
|
167
|
-
|
168
|
-
|
153
|
+
message: -> (_envelope) { },
|
154
|
+
presence: -> (_envelope) { },
|
155
|
+
status: -> (_envelope) { },
|
169
156
|
)
|
170
157
|
|
171
158
|
expect(pubnub_client.subscribed?).to eq false
|
172
159
|
|
173
160
|
pubnub_client.add_listener(
|
174
|
-
|
175
|
-
|
161
|
+
callback: callbacks,
|
162
|
+
name: :callbacks,
|
176
163
|
)
|
177
164
|
|
178
165
|
expect(pubnub_client.subscriber.listeners[:callbacks]).not_to be_nil
|
@@ -180,16 +167,16 @@ describe Pubnub::Client do
|
|
180
167
|
expect(pubnub_client.subscribed?).to eq false # we have callbacks but we're not subscribed yet
|
181
168
|
end
|
182
169
|
|
183
|
-
it
|
170
|
+
it "can be removed" do
|
184
171
|
callbacks = Pubnub::SubscribeCallback.new(
|
185
|
-
|
186
|
-
|
187
|
-
|
172
|
+
message: -> (_envelope) { },
|
173
|
+
presence: -> (_envelope) { },
|
174
|
+
status: -> (_envelope) { },
|
188
175
|
)
|
189
176
|
|
190
177
|
pubnub_client.add_listener(
|
191
|
-
|
192
|
-
|
178
|
+
callback: callbacks,
|
179
|
+
name: :callbacks,
|
193
180
|
)
|
194
181
|
|
195
182
|
expect(pubnub_client.subscriber.listeners[:callbacks]).not_to be_nil
|
@@ -199,7 +186,7 @@ describe Pubnub::Client do
|
|
199
186
|
expect(pubnub_client.subscriber.listeners[:callbacks]).to be_nil
|
200
187
|
|
201
188
|
pubnub_client.add_listener(
|
202
|
-
|
189
|
+
callback: callbacks,
|
203
190
|
)
|
204
191
|
|
205
192
|
expect(pubnub_client.subscriber.listeners).not_to be_empty
|
@@ -210,83 +197,78 @@ describe Pubnub::Client do
|
|
210
197
|
end
|
211
198
|
end
|
212
199
|
|
213
|
-
context
|
214
|
-
let(:pubnub_client) { Pubnub.new(subscribe_key:
|
200
|
+
context "helper methods" do
|
201
|
+
let(:pubnub_client) { Pubnub.new(subscribe_key: "demo") }
|
215
202
|
|
216
|
-
it
|
217
|
-
expect(pubnub_client.change_uuid(
|
203
|
+
it "can change uuid while not subscribed" do
|
204
|
+
expect(pubnub_client.change_uuid("whatever")).to eq "whatever"
|
218
205
|
end
|
219
206
|
|
220
|
-
it
|
207
|
+
it "cannot change uuid when subscribed" do
|
221
208
|
pubnub_client.subscribe(channel: :demo)
|
222
209
|
|
223
|
-
expect { pubnub_client.change_uuid(
|
210
|
+
expect { pubnub_client.change_uuid("whatever") }.to raise_error(RuntimeError)
|
224
211
|
end
|
225
212
|
|
226
|
-
it
|
213
|
+
it "can show what channels are subscribed" do
|
227
214
|
expect(pubnub_client.subscribed?).to eq(false)
|
228
|
-
pubnub_client.subscribe(channel: [
|
215
|
+
pubnub_client.subscribe(channel: ["demo", "demo.*"], presence: "demo", group: "demo")
|
229
216
|
expect(pubnub_client.subscribed?).to eq(true)
|
230
217
|
|
231
|
-
expect(pubnub_client.subscribed_to).to eq(channel: [
|
232
|
-
expect(pubnub_client.subscribed_to(true)).to eq(channel: [
|
218
|
+
expect(pubnub_client.subscribed_to).to eq(channel: ["demo", "demo-pnpres", "demo.*"], group: ["demo"])
|
219
|
+
expect(pubnub_client.subscribed_to(true)).to eq(channel: ["demo", "demo-pnpres"], wildcard_channel: ["demo.*"], group: ["demo"])
|
233
220
|
end
|
234
221
|
end
|
235
222
|
|
236
|
-
context
|
237
|
-
it
|
223
|
+
context "connections" do
|
224
|
+
it "are keep_alive by default" do
|
238
225
|
pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo)
|
239
226
|
|
240
|
-
VCR.use_cassette(
|
227
|
+
VCR.use_cassette("lib/client/keep_alive_default", record: :once) do
|
241
228
|
pubnub.subscribe(channel: :demo)
|
242
|
-
|
243
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
229
|
+
|
230
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:subscribe_event].tcp_keepalive).to eq true }
|
244
231
|
pubnub.leave(channel: :demo)
|
245
|
-
|
246
232
|
end
|
247
233
|
end
|
248
234
|
|
249
|
-
it
|
235
|
+
it "respect :disable_keep_alive" do
|
250
236
|
pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, disable_keepalive: true)
|
251
237
|
|
252
|
-
VCR.use_cassette(
|
238
|
+
VCR.use_cassette("lib/client/keep_alive_disabled", record: :once) do
|
253
239
|
pubnub.subscribe(channel: :demo)
|
254
|
-
|
255
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
240
|
+
|
241
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:subscribe_event].tcp_keepalive).to eq false }
|
256
242
|
pubnub.leave(channel: :demo)
|
257
|
-
|
258
243
|
end
|
259
244
|
end
|
260
245
|
|
261
|
-
it
|
246
|
+
it "respect :disable_subscribe_keep_alive init parameter" do
|
262
247
|
pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, disable_subscribe_keepalive: true)
|
263
248
|
|
264
|
-
VCR.use_cassette(
|
249
|
+
VCR.use_cassette("lib/client/keep_alive_disable_subscribe_keep_alive", record: :once) do
|
265
250
|
pubnub.subscribe(channel: :demo)
|
266
|
-
|
267
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
251
|
+
|
252
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:subscribe_event].tcp_keepalive).to eq false }
|
268
253
|
pubnub.leave(channel: :demo)
|
269
|
-
|
254
|
+
|
270
255
|
pubnub.publish(channel: :demo, message: :whatever)
|
271
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
272
|
-
|
256
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:single_event].tcp_keepalive).to eq true }
|
273
257
|
end
|
274
258
|
end
|
275
259
|
|
276
|
-
it
|
260
|
+
it "respect :disable_non_subscribe_keep_alive init parameter" do
|
277
261
|
pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, disable_non_subscribe_keepalive: true)
|
278
262
|
|
279
|
-
VCR.use_cassette(
|
263
|
+
VCR.use_cassette("lib/client/keep_alive_disable_non_subscribe_keep_alive", record: :once) do
|
280
264
|
pubnub.subscribe(channel: :demo)
|
281
|
-
|
282
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
265
|
+
|
266
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:subscribe_event].tcp_keepalive).to eq true }
|
283
267
|
pubnub.leave(channel: :demo)
|
284
|
-
|
268
|
+
|
285
269
|
pubnub.publish(channel: :demo, message: :whatever)
|
286
|
-
eventually { expect(pubnub.env[:req_dispatchers_pool][:async][
|
287
|
-
|
270
|
+
eventually { expect(pubnub.env[:req_dispatchers_pool][:async]["ps.pndsn.com"][:single_event].tcp_keepalive).to eq false }
|
288
271
|
end
|
289
272
|
end
|
290
273
|
end
|
291
|
-
|
292
274
|
end
|