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,39 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Publish do
|
4
|
-
it_behaves_like
|
4
|
+
it_behaves_like "an event"
|
5
5
|
|
6
|
-
|
7
|
-
Celluloid.boot
|
8
|
-
example.run
|
9
|
-
Celluloid.shutdown
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'given basic parameters' do
|
6
|
+
context "given basic parameters" do
|
13
7
|
before :each do
|
14
8
|
@pubnub = Pubnub::Client.new(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
10
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
11
|
+
auth_key: "ruby-test-auth",
|
12
|
+
uuid: "ruby-test-uuid",
|
19
13
|
)
|
20
14
|
end
|
21
|
-
it
|
22
|
-
VCR.use_cassette(
|
15
|
+
it "works" do
|
16
|
+
VCR.use_cassette("lib/events/publish", record: :once) do
|
23
17
|
envelope = @pubnub.publish(
|
24
|
-
|
25
|
-
|
18
|
+
channel: :demo,
|
19
|
+
message: "whatever",
|
26
20
|
).value
|
27
21
|
|
28
22
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
32
|
-
it
|
33
|
-
VCR.use_cassette(
|
26
|
+
it "forms valid ErrorEnvelope on error" do
|
27
|
+
VCR.use_cassette("lib/events/publish-error", record: :once) do
|
34
28
|
envelope = @pubnub.publish(
|
35
|
-
|
36
|
-
|
29
|
+
channel: :demo,
|
30
|
+
message: "whatever",
|
37
31
|
).value
|
38
32
|
|
39
33
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -42,39 +36,38 @@ describe Pubnub::Publish do
|
|
42
36
|
end
|
43
37
|
end
|
44
38
|
|
45
|
-
context
|
39
|
+
context "store, replicate" do
|
46
40
|
before(:each) do
|
47
41
|
@pubnub = Pubnub.new(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
42
|
+
:max_retries => 0,
|
43
|
+
:subscribe_key => :demo,
|
44
|
+
:publish_key => :demo,
|
45
|
+
:auth_key => :demoish_authkey,
|
46
|
+
:error_callback => @error_callback,
|
53
47
|
)
|
54
48
|
|
55
|
-
@pubnub.uuid =
|
49
|
+
@pubnub.uuid = "tester"
|
56
50
|
end
|
57
51
|
|
58
|
-
it
|
59
|
-
VCR.use_cassette(
|
52
|
+
it "works" do
|
53
|
+
VCR.use_cassette("integration/publish/publish-store-replicate", record: :once) do
|
60
54
|
future = @pubnub.publish(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
message: {text: "sometext"},
|
56
|
+
channel: "ruby_demo_channel",
|
57
|
+
callback: @callback,
|
58
|
+
store: false,
|
59
|
+
replicate: false,
|
66
60
|
)
|
67
61
|
|
68
62
|
future.value
|
69
63
|
end
|
70
64
|
end
|
71
65
|
|
72
|
-
it
|
73
|
-
VCR.use_cassette(
|
74
|
-
|
66
|
+
it "works with fire method" do
|
67
|
+
VCR.use_cassette("integration/publish/publish-store-replicate", record: :once) do
|
75
68
|
future = @pubnub.fire(
|
76
|
-
|
77
|
-
|
69
|
+
message: {text: "sometext"},
|
70
|
+
channel: "ruby_demo_channel",
|
78
71
|
)
|
79
72
|
|
80
73
|
future.value
|
@@ -1,32 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Revoke do
|
4
|
-
it_behaves_like
|
4
|
+
it_behaves_like "an event"
|
5
5
|
|
6
|
-
|
7
|
-
Celluloid.boot
|
8
|
-
example.run
|
9
|
-
Celluloid.shutdown
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'given basic parameters' do
|
6
|
+
context "given basic parameters" do
|
13
7
|
before :each do
|
14
8
|
Pubnub::Revoke.any_instance.stub(:current_time).and_return 1463307484
|
15
|
-
Pubnub::Revoke.any_instance.stub(:signature).and_return
|
9
|
+
Pubnub::Revoke.any_instance.stub(:signature).and_return "7FvZ9FQeu9q_uTx8ICyK8CiWDOeD1Qc6nrsNfqP0fyY="
|
16
10
|
|
17
11
|
@pubnub = Pubnub::Client.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
13
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
14
|
+
secret_key: "sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy",
|
15
|
+
auth_key: "ruby-test-auth",
|
16
|
+
uuid: "ruby-test-uuid",
|
23
17
|
)
|
24
18
|
end
|
25
19
|
|
26
|
-
it
|
27
|
-
VCR.use_cassette(
|
20
|
+
it "works" do
|
21
|
+
VCR.use_cassette("lib/events/revoke", record: :once) do
|
28
22
|
envelope = @pubnub.revoke(
|
29
|
-
|
23
|
+
channel: :demo,
|
30
24
|
).value
|
31
25
|
|
32
26
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
@@ -34,10 +28,10 @@ describe Pubnub::Revoke do
|
|
34
28
|
end
|
35
29
|
end
|
36
30
|
|
37
|
-
it
|
38
|
-
VCR.use_cassette(
|
31
|
+
it "forms valid ErrorEnvelope on error" do
|
32
|
+
VCR.use_cassette("lib/events/revoke-error", record: :once) do
|
39
33
|
envelope = @pubnub.revoke(
|
40
|
-
|
34
|
+
channel: :demo,
|
41
35
|
).value
|
42
36
|
|
43
37
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -46,4 +40,4 @@ describe Pubnub::Revoke do
|
|
46
40
|
end
|
47
41
|
end
|
48
42
|
end
|
49
|
-
end
|
43
|
+
end
|
@@ -1,29 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::State do
|
4
|
-
it_behaves_like
|
4
|
+
it_behaves_like "an event"
|
5
5
|
|
6
|
-
|
7
|
-
Celluloid.boot
|
8
|
-
example.run
|
9
|
-
Celluloid.shutdown
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'given basic parameters' do
|
6
|
+
context "given basic parameters" do
|
13
7
|
before :each do
|
14
8
|
@pubnub = Pubnub::Client.new(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
10
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
11
|
+
auth_key: "ruby-test-auth",
|
12
|
+
uuid: "ruby-test-uuid",
|
19
13
|
)
|
20
14
|
end
|
21
15
|
|
22
|
-
it
|
23
|
-
VCR.use_cassette(
|
16
|
+
it "works" do
|
17
|
+
VCR.use_cassette("lib/events/state", record: :once) do
|
24
18
|
envelope = @pubnub.state(
|
25
|
-
|
26
|
-
|
19
|
+
channel: :demo,
|
20
|
+
uuid: :whatever,
|
27
21
|
).value
|
28
22
|
|
29
23
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
@@ -31,11 +25,11 @@ describe Pubnub::State do
|
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
34
|
-
it
|
35
|
-
VCR.use_cassette(
|
28
|
+
it "forms valid ErrorEnvelope on error" do
|
29
|
+
VCR.use_cassette("lib/events/state-error", record: :once) do
|
36
30
|
envelope = @pubnub.state(
|
37
|
-
|
38
|
-
|
31
|
+
channel: :demo,
|
32
|
+
uuid: :whatever,
|
39
33
|
).value
|
40
34
|
|
41
35
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -43,4 +37,4 @@ describe Pubnub::State do
|
|
43
37
|
end
|
44
38
|
end
|
45
39
|
end
|
46
|
-
end
|
40
|
+
end
|
@@ -1,34 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Subscribe do
|
4
4
|
# it_behaves_like 'an event'
|
5
5
|
|
6
6
|
around :each do |example|
|
7
|
-
|
8
|
-
example.run
|
9
|
-
Celluloid.shutdown
|
7
|
+
example.run_with_retry retry: 10
|
10
8
|
end
|
11
9
|
|
12
|
-
|
10
|
+
|
11
|
+
context "given basic parameters" do
|
13
12
|
before :each do
|
14
13
|
@messages = []
|
15
14
|
@statuses = []
|
16
15
|
|
17
16
|
@callbacks = Pubnub::SubscribeCallback.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
message: -> (envelope) { @messages << envelope },
|
18
|
+
presence: -> (_envelope) { },
|
19
|
+
status: -> (envelope) { @statuses << envelope },
|
21
20
|
)
|
22
21
|
end
|
23
22
|
|
24
|
-
context
|
25
|
-
it
|
26
|
-
VCR.use_cassette(
|
23
|
+
context "async" do
|
24
|
+
it "works" do
|
25
|
+
VCR.use_cassette("lib/events/subscribe-async", record: :once) do
|
27
26
|
@pubnub = Pubnub::Client.new(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
28
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
29
|
+
auth_key: "ruby-test-auth",
|
30
|
+
uuid: "ruby-test-uuid",
|
32
31
|
)
|
33
32
|
|
34
33
|
@pubnub.add_listener(callback: @callbacks)
|
@@ -40,53 +39,51 @@ describe Pubnub::Subscribe do
|
|
40
39
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
41
40
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
|
-
it
|
45
|
+
it "works with cipher key" do
|
48
46
|
@pubnub = Pubnub::Client.new(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
subscribe_key: "demo",
|
48
|
+
publish_key: "demo",
|
49
|
+
uuid: "ruby-test-uuid",
|
50
|
+
cipher_key: "demo",
|
53
51
|
)
|
54
52
|
|
55
53
|
@pubnub.add_listener(callback: @callbacks)
|
56
54
|
|
57
|
-
VCR.use_cassette(
|
55
|
+
VCR.use_cassette("lib/events/subscribe-cipher-async", record: :once) do
|
58
56
|
@pubnub.subscribe(channel: :whatever)
|
59
57
|
|
60
58
|
eventually do
|
61
|
-
expect(@messages.first.result[:data][:message]).to eq(
|
59
|
+
expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
66
|
-
it
|
64
|
+
it "allows subscribing additional channels" do
|
67
65
|
@pubnub = Pubnub::Client.new(
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
subscribe_key: "demo",
|
67
|
+
publish_key: "demo",
|
68
|
+
uuid: "ruby-test-uuid",
|
71
69
|
)
|
72
70
|
|
73
|
-
VCR.use_cassette(
|
71
|
+
VCR.use_cassette("lib/events/subscribe-playing-async", record: :once) do
|
74
72
|
@pubnub.subscribe(channel: :demo)
|
75
73
|
#sleep(0.1)
|
76
74
|
@pubnub.subscribe(channel: :whatever)
|
77
75
|
#sleep(0.1)
|
78
76
|
@pubnub.leave(channel: [:whatever, :demo])
|
79
77
|
end
|
80
|
-
|
81
78
|
end
|
82
79
|
|
83
|
-
it
|
84
|
-
VCR.use_cassette(
|
80
|
+
it "fires status callback on error" do
|
81
|
+
VCR.use_cassette("lib/events/subscribe-async-error", record: :once) do
|
85
82
|
@pubnub = Pubnub::Client.new(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
84
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
85
|
+
auth_key: "ruby-test-auth",
|
86
|
+
uuid: "ruby-test-uuid",
|
90
87
|
)
|
91
88
|
|
92
89
|
@pubnub.add_listener(callback: @callbacks)
|
@@ -99,56 +96,53 @@ describe Pubnub::Subscribe do
|
|
99
96
|
expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
|
100
97
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
101
98
|
end
|
102
|
-
|
103
99
|
end
|
104
100
|
end
|
105
101
|
end
|
106
102
|
|
107
|
-
context
|
108
|
-
it
|
103
|
+
context "sync" do
|
104
|
+
it "works with cipher key" do
|
109
105
|
@pubnub = Pubnub::Client.new(
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
106
|
+
subscribe_key: "demo",
|
107
|
+
publish_key: "demo",
|
108
|
+
uuid: "ruby-test-uuid",
|
109
|
+
cipher_key: "demo",
|
114
110
|
)
|
115
111
|
|
116
|
-
VCR.use_cassette(
|
112
|
+
VCR.use_cassette("lib/events/subscribe-cipher-async", record: :once) do
|
117
113
|
@pubnub.subscribe(channel: :whatever, http_sync: true)
|
118
114
|
@messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
|
119
115
|
eventually do
|
120
|
-
expect(@messages.first.result[:data][:message]).to eq(
|
116
|
+
expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
|
121
117
|
end
|
122
118
|
end
|
123
119
|
end
|
124
120
|
|
125
|
-
it
|
126
|
-
VCR.use_cassette(
|
121
|
+
it "works" do
|
122
|
+
VCR.use_cassette("lib/events/subscribe-sync", record: :once) do
|
127
123
|
@pubnub = Pubnub::Client.new(
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
124
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
125
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
126
|
+
auth_key: "ruby-test-auth",
|
127
|
+
uuid: "ruby-test-uuid",
|
132
128
|
)
|
133
129
|
|
134
130
|
@pubnub.subscribe(channel: :demo, http_sync: true)
|
135
131
|
envelopes = @pubnub.subscribe(channel: :demo, http_sync: true)
|
136
132
|
|
137
|
-
|
138
133
|
envelope = envelopes.first
|
139
134
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
140
135
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
141
|
-
|
142
136
|
end
|
143
137
|
end
|
144
138
|
|
145
|
-
it
|
146
|
-
VCR.use_cassette(
|
139
|
+
it "fires status callback on error" do
|
140
|
+
VCR.use_cassette("lib/events/subscribe-sync-error", record: :once) do
|
147
141
|
@pubnub = Pubnub::Client.new(
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
142
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
143
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
144
|
+
auth_key: "ruby-test-auth",
|
145
|
+
uuid: "ruby-test-uuid",
|
152
146
|
)
|
153
147
|
|
154
148
|
@pubnub.subscribe(channel: :demo, http_sync: true)
|
@@ -157,40 +151,36 @@ describe Pubnub::Subscribe do
|
|
157
151
|
envelope = envelopes.first
|
158
152
|
expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
|
159
153
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
160
|
-
|
161
154
|
end
|
162
155
|
end
|
163
156
|
end
|
164
157
|
|
165
|
-
context
|
166
|
-
it
|
167
|
-
VCR.use_cassette(
|
158
|
+
context "aliases" do
|
159
|
+
it "pass channels to channel" do
|
160
|
+
VCR.use_cassette("lib/events/subscribe-sync", record: :once) do
|
168
161
|
@pubnub = Pubnub::Client.new(
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
162
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
163
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
164
|
+
auth_key: "ruby-test-auth",
|
165
|
+
uuid: "ruby-test-uuid",
|
173
166
|
)
|
174
167
|
|
175
168
|
@pubnub.subscribe(channels: :demo, http_sync: true)
|
176
169
|
envelopes = @pubnub.subscribe(channels: :demo, http_sync: true)
|
177
170
|
|
178
|
-
|
179
171
|
envelope = envelopes.first
|
180
172
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
181
173
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
182
|
-
|
183
174
|
end
|
184
175
|
end
|
185
176
|
|
186
|
-
it
|
187
|
-
VCR.use_cassette(
|
188
|
-
|
177
|
+
it "pass channel_groups to channel_group" do
|
178
|
+
VCR.use_cassette("lib/events/subscribe-channel-groups", record: :once) do
|
189
179
|
@pubnub = Pubnub::Client.new(
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
180
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
181
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
182
|
+
auth_key: "ruby-test-auth",
|
183
|
+
uuid: "ruby-test-uuid",
|
194
184
|
)
|
195
185
|
|
196
186
|
@pubnub.subscribe(channel_groups: :demo, http_sync: true)
|
@@ -203,18 +193,18 @@ describe Pubnub::Subscribe do
|
|
203
193
|
end
|
204
194
|
end
|
205
195
|
|
206
|
-
context
|
207
|
-
it
|
208
|
-
VCR.use_cassette(
|
196
|
+
context "flags" do
|
197
|
+
it "with with_presence" do
|
198
|
+
VCR.use_cassette("lib/events/subscribe-with-presence", record: :once) do
|
209
199
|
@pubnub = Pubnub::Client.new(
|
210
|
-
subscribe_key:
|
211
|
-
publish_key:
|
212
|
-
auth_key:
|
213
|
-
uuid:
|
200
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
201
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
202
|
+
auth_key: "ruby-test-auth",
|
203
|
+
uuid: "ruby-test-uuid",
|
214
204
|
)
|
215
205
|
|
216
|
-
@pubnub.subscribe(channels: [:demo, :demo1,
|
217
|
-
envelopes = @pubnub.subscribe(channels: [:demo, :demo1,
|
206
|
+
@pubnub.subscribe(channels: [:demo, :demo1, "demo.*"], with_presence: true, http_sync: true)
|
207
|
+
envelopes = @pubnub.subscribe(channels: [:demo, :demo1, "demo.*"], with_presence: true, http_sync: true)
|
218
208
|
|
219
209
|
envelope = envelopes.first
|
220
210
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
@@ -223,4 +213,4 @@ describe Pubnub::Subscribe do
|
|
223
213
|
end
|
224
214
|
end
|
225
215
|
end
|
226
|
-
end
|
216
|
+
end
|