pubnub 4.4.0 → 4.5.0
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 +18 -2
- data/.travis.yml +4 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +10 -1
- data/README.md +56 -17
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/add_channels_to_push/001.yml +45 -0
- data/fixtures/vcr_cassettes/examples/add_channels_to_push/002.yml +45 -0
- data/fixtures/vcr_cassettes/examples/add_channels_to_push/003.yml +45 -0
- data/fixtures/vcr_cassettes/examples/add_channels_to_push/004.yml +45 -0
- data/fixtures/vcr_cassettes/examples/grant/1946.yml +8 -9
- data/fixtures/vcr_cassettes/examples/grant/1947.yml +8 -9
- data/fixtures/vcr_cassettes/examples/grant/1948.yml +8 -9
- data/fixtures/vcr_cassettes/examples/list_push_provisions/001.yml +46 -0
- data/fixtures/vcr_cassettes/examples/list_push_provisions/002.yml +45 -0
- data/fixtures/vcr_cassettes/examples/list_push_provisions/003.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_channels_from_push/001.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_channels_from_push/002.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_channels_from_push/003.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_device_from_push/001.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_device_from_push/002.yml +45 -0
- data/fixtures/vcr_cassettes/examples/remove_device_from_push/003.yml +45 -0
- data/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml +1 -1
- data/fixtures/vcr_cassettes/lib/events/get_channel_members.yml +1 -1
- data/fixtures/vcr_cassettes/lib/events/{get_memberships.yml → get_memberships1.yml} +1 -1
- data/fixtures/vcr_cassettes/lib/events/get_memberships2.yml +37 -0
- data/fixtures/vcr_cassettes/lib/events/{get_uuid_metadata.yml → get_uuid_metadata1.yml} +0 -0
- data/fixtures/vcr_cassettes/lib/events/get_uuid_metadata2.yml +76 -0
- data/fixtures/vcr_cassettes/lib/events/remove_channel_members.yml +1 -1
- data/fixtures/vcr_cassettes/lib/events/{remove_memberships.yml → remove_memberships1.yml} +0 -0
- data/fixtures/vcr_cassettes/lib/events/remove_memberships2.yml +39 -0
- data/fixtures/vcr_cassettes/lib/events/{remove_uuid_metadata.yml → remove_uuid_metadata1.yml} +0 -0
- data/fixtures/vcr_cassettes/lib/events/remove_uuid_metadata2.yml +76 -0
- data/fixtures/vcr_cassettes/lib/events/{set_memberships.yml → set_memberships1.yml} +0 -0
- data/fixtures/vcr_cassettes/lib/events/set_memberships2.yml +39 -0
- data/fixtures/vcr_cassettes/lib/events/{set_uuid_metadata.yml → set_uuid_metadata1.yml} +0 -0
- data/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml +78 -0
- data/lib/pubnub/client.rb +4 -1
- data/lib/pubnub/event.rb +3 -1
- data/lib/pubnub/events/add_channels_to_push.rb +29 -13
- data/lib/pubnub/events/get_all_channels_metadata.rb +13 -1
- data/lib/pubnub/events/get_all_uuid_metadata.rb +13 -1
- data/lib/pubnub/events/get_channel_members.rb +21 -1
- data/lib/pubnub/events/get_channel_metadata.rb +6 -1
- data/lib/pubnub/events/get_memberships.rb +22 -2
- data/lib/pubnub/events/get_uuid_metadata.rb +7 -2
- data/lib/pubnub/events/grant.rb +1 -1
- data/lib/pubnub/events/list_push_provisions.rb +29 -12
- data/lib/pubnub/events/remove_channel_members.rb +22 -2
- data/lib/pubnub/events/remove_channels_from_push.rb +29 -13
- data/lib/pubnub/events/remove_device_from_push.rb +30 -14
- data/lib/pubnub/events/remove_memberships.rb +23 -3
- data/lib/pubnub/events/remove_uuid_metadata.rb +1 -1
- data/lib/pubnub/events/set_channel_members.rb +21 -1
- data/lib/pubnub/events/set_channel_metadata.rb +6 -1
- data/lib/pubnub/events/set_memberships.rb +22 -2
- data/lib/pubnub/events/set_uuid_metadata.rb +7 -2
- data/lib/pubnub/formatter.rb +28 -1
- data/lib/pubnub/validators/add_channels_to_push.rb +52 -0
- data/lib/pubnub/validators/grant.rb +1 -1
- data/lib/pubnub/validators/list_push_provisions.rb +43 -0
- data/lib/pubnub/validators/remove_channels_from_push.rb +52 -0
- data/lib/pubnub/validators/remove_device_from_push.rb +43 -0
- data/lib/pubnub/version.rb +1 -1
- data/spec/examples/add_channels_to_push_spec.rb +178 -0
- data/spec/examples/{grant_examples_spec.rb → grant_examples_1_spec.rb} +0 -9009
- data/spec/examples/grant_examples_2_spec.rb +9107 -0
- data/spec/examples/list_push_provisions_spec.rb +164 -0
- data/spec/examples/presence_examples_spec.rb +222 -186
- data/spec/examples/remove_channels_from_push_spec.rb +164 -0
- data/spec/examples/remove_device_from_push_spec.rb +164 -0
- data/spec/examples/revoke_examples_1_spec.rb +27013 -0
- data/spec/examples/revoke_examples_2_spec.rb +27012 -0
- data/spec/examples/revoke_examples_3_spec.rb +17967 -0
- data/spec/examples/status_request_message_count_exceeded_spec.rb +4 -1
- data/spec/examples/subscribe_examples_1_spec.rb +26972 -0
- data/spec/examples/subscribe_examples_2_spec.rb +19575 -0
- data/spec/lib/connection_callback_spec.rb +4 -3
- data/spec/lib/events/membership_spec.rb +38 -11
- data/spec/lib/events/presence_delta_spec.rb +9 -6
- data/spec/lib/events/presence_spec.rb +13 -7
- data/spec/lib/events/subscribe_spec.rb +56 -32
- data/spec/lib/events/uuid_metadata_spec.rb +36 -6
- data/spec/lib/super_admin_spec.rb +8 -4
- data/spec/spec_helper.rb +23 -7
- metadata +53 -15
- data/lib/pubnub/validators/push.rb +0 -43
- data/spec/examples/revoke_examples_spec.rb +0 -71950
- data/spec/examples/subscribe_examples_spec.rb +0 -45184
@@ -7,6 +7,7 @@ describe "Connect, disconnect and reconnect callbacks" do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
@connect_messages, @reconnect_messages, @disconnect_messages = [], [], []
|
10
|
+
@sleep_duration = ENV['JRUBY_TEST'] == 'true' ? 1.5 : 0.5
|
10
11
|
|
11
12
|
callback = Pubnub::SubscribeCallback.new(
|
12
13
|
message: -> (_envelope) { },
|
@@ -37,7 +38,7 @@ describe "Connect, disconnect and reconnect callbacks" do
|
|
37
38
|
it "fire connect callback when connection is made" do
|
38
39
|
VCR.use_cassette("client/connection_callbacks_0", :record => :once) do
|
39
40
|
@pubnub.subscribe(channel: :demo)
|
40
|
-
sleep
|
41
|
+
sleep @sleep_duration
|
41
42
|
expect(@connect_messages.size).to be > 0
|
42
43
|
end
|
43
44
|
end
|
@@ -47,7 +48,7 @@ describe "Connect, disconnect and reconnect callbacks" do
|
|
47
48
|
|
48
49
|
VCR.use_cassette("client/connection_callbacks_1", :record => :once) do
|
49
50
|
@pubnub.subscribe(channel: :demo)
|
50
|
-
sleep
|
51
|
+
sleep @sleep_duration
|
51
52
|
expect(@disconnect_messages.size).to be > 0
|
52
53
|
end
|
53
54
|
end
|
@@ -57,7 +58,7 @@ describe "Connect, disconnect and reconnect callbacks" do
|
|
57
58
|
|
58
59
|
VCR.use_cassette("client/connection_callbacks_2", :record => :once) do
|
59
60
|
@pubnub.subscribe(channel: :demo)
|
60
|
-
sleep
|
61
|
+
sleep @sleep_duration
|
61
62
|
expect(@reconnect_messages.size).to be > 0
|
62
63
|
end
|
63
64
|
end
|
@@ -10,7 +10,7 @@ describe Pubnub::SetMemberships do
|
|
10
10
|
publish_key: "pub-a-mock-key",
|
11
11
|
auth_key: "ruby-test-auth",
|
12
12
|
uuid: "ruby-test-uuid",
|
13
|
-
|
13
|
+
)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "get_channel_members_works" do
|
@@ -22,8 +22,8 @@ describe Pubnub::SetMemberships do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
VCR.use_cassette("lib/events/
|
25
|
+
it "get_memberships_works_1" do
|
26
|
+
VCR.use_cassette("lib/events/get_memberships1", record: :once) do
|
27
27
|
envelope = @pubnub.get_memberships(uuid: "mg3", include: { count: true, custom: true }).value
|
28
28
|
|
29
29
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
@@ -31,18 +31,45 @@ describe Pubnub::SetMemberships do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
35
|
-
VCR.use_cassette("lib/events/
|
36
|
-
envelope = @pubnub.
|
34
|
+
it "get_memberships_works_2" do
|
35
|
+
VCR.use_cassette("lib/events/get_memberships2", record: :once) do
|
36
|
+
envelope = @pubnub.get_memberships(include: { count: true, custom: true }).value
|
37
37
|
|
38
38
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
39
39
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
VCR.use_cassette("lib/events/
|
45
|
-
envelope = @pubnub.
|
43
|
+
it "set_memberships_works_1" do
|
44
|
+
VCR.use_cassette("lib/events/set_memberships1", record: :once) do
|
45
|
+
envelope = @pubnub.set_memberships(uuid: "mg3", channels: [{ channel: 'channel-1'}], include: { custom: true }).value
|
46
|
+
|
47
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
48
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "set_memberships_works_2" do
|
53
|
+
VCR.use_cassette("lib/events/set_memberships2", record: :once) do
|
54
|
+
envelope = @pubnub.set_memberships(channels: [{ channel: 'channel-1'}], include: { custom: true }).value
|
55
|
+
|
56
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
57
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "remove_memberships_works_1" do
|
62
|
+
VCR.use_cassette("lib/events/remove_memberships1", record: :once) do
|
63
|
+
envelope = @pubnub.remove_memberships(uuid: "mg3", channels: ['channel-1'], include: { custom: true }).value
|
64
|
+
|
65
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
66
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "remove_memberships_works_2" do
|
71
|
+
VCR.use_cassette("lib/events/remove_memberships2", record: :once) do
|
72
|
+
envelope = @pubnub.remove_memberships(channels: ['channel-1'], include: { custom: true }).value
|
46
73
|
|
47
74
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
48
75
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
@@ -51,7 +78,7 @@ describe Pubnub::SetMemberships do
|
|
51
78
|
|
52
79
|
it "set_channel_members_works" do
|
53
80
|
VCR.use_cassette("lib/events/set_channel_members", record: :once) do
|
54
|
-
envelope = @pubnub.set_channel_members(channel: "channel-1", uuids: [{
|
81
|
+
envelope = @pubnub.set_channel_members(channel: "channel-1", uuids: [{uuid: 'mg2'}], include: { custom: true }).value
|
55
82
|
|
56
83
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
57
84
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
@@ -60,7 +87,7 @@ describe Pubnub::SetMemberships do
|
|
60
87
|
|
61
88
|
it "remove_channel_members_works" do
|
62
89
|
VCR.use_cassette("lib/events/remove_channel_members", record: :once) do
|
63
|
-
envelope = @pubnub.remove_channel_members(channel: "channel-1", uuids: [
|
90
|
+
envelope = @pubnub.remove_channel_members(channel: "channel-1", uuids: ['mg2'], include: { custom: true }).value
|
64
91
|
|
65
92
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
66
93
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
@@ -8,12 +8,12 @@ describe Pubnub::Presence do
|
|
8
8
|
|
9
9
|
context "with interval events and delta" do
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@presences = []
|
12
12
|
@statuses = []
|
13
13
|
|
14
14
|
@callbacks = Pubnub::SubscribeCallback.new(
|
15
15
|
message: -> (_envelope) { },
|
16
|
-
presence: -> (envelope) { @
|
16
|
+
presence: -> (envelope) { @presences << envelope },
|
17
17
|
status: -> (envelope) { @statuses << envelope },
|
18
18
|
)
|
19
19
|
end
|
@@ -26,10 +26,13 @@ describe Pubnub::Presence do
|
|
26
26
|
pubnub.presence(channel: :demo)
|
27
27
|
|
28
28
|
eventually do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
if @presences.length >= 4
|
30
|
+
expect(@presences[0].result[:data]).to eq({:message => {"action" => "interval", "timestamp" => 1490958575, "occupancy" => 3}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14909585750910131", :region_code => 1}, :message_meta_data => nil, :presence_event => "interval", :presence => {:uuid => nil, :timestamp => 1490958575, :state => nil, :occupancy => 3}})
|
31
|
+
expect(@presences[1].result[:data]).to eq({:message => {"action" => "interval", "timestamp" => 1490958585, "occupancy" => 4, "join" => ["Client-d39lr"]}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14909585850925693", :region_code => 1}, :message_meta_data => nil, :presence_event => "interval", :presence => {:uuid => nil, :timestamp => 1490958585, :state => nil, :occupancy => 4}})
|
32
|
+
expect(@presences[2].result[:data]).to eq({:message => {"action" => "interval", "timestamp" => 1490958595, "occupancy" => 3, "leave" => ["another-client"]}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14909585950916556", :region_code => 1}, :message_meta_data => nil, :presence_event => "interval", :presence => {:uuid => nil, :timestamp => 1490958595, :state => nil, :occupancy => 3}})
|
33
|
+
expect(@presences[3].result[:data]).to eq({:message => {"action" => "interval", "timestamp" => 1490958605, "occupancy" => 2, "join" => ["another-client"], "leave" => ["Client-d39lr", "client0"]}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14909586050915528", :region_code => 1}, :message_meta_data => nil, :presence_event => "interval", :presence => {:uuid => nil, :timestamp => 1490958605, :state => nil, :occupancy => 2}})
|
34
|
+
true
|
35
|
+
end
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -4,7 +4,7 @@ describe Pubnub::Presence do
|
|
4
4
|
around :each do |example|
|
5
5
|
example.run_with_retry retry: 10
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it_behaves_like "an event"
|
9
9
|
|
10
10
|
context "given basic parameters" do
|
@@ -34,9 +34,12 @@ describe Pubnub::Presence do
|
|
34
34
|
@pubnub.presence(channel: :demo)
|
35
35
|
|
36
36
|
eventually do
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
if @messages.length > 0
|
38
|
+
envelope = @messages.first
|
39
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
40
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
41
|
+
true
|
42
|
+
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
@@ -56,9 +59,12 @@ describe Pubnub::Presence do
|
|
56
59
|
sleep 0.1
|
57
60
|
|
58
61
|
eventually do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
if @statuses.length > 0
|
63
|
+
envelope = @statuses.first
|
64
|
+
expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
|
65
|
+
# expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
66
|
+
true
|
67
|
+
end
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
@@ -53,9 +53,12 @@ describe Pubnub::Subscribe do
|
|
53
53
|
@pubnub.subscribe(channel: :demo)
|
54
54
|
|
55
55
|
eventually do
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
if @messages.length > 0
|
57
|
+
envelope = @messages.first
|
58
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
59
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
60
|
+
true
|
61
|
+
end
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
@@ -74,7 +77,10 @@ describe Pubnub::Subscribe do
|
|
74
77
|
@pubnub.subscribe(channel: :whatever)
|
75
78
|
|
76
79
|
eventually do
|
77
|
-
|
80
|
+
if @messages.length > 0
|
81
|
+
expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
|
82
|
+
true
|
83
|
+
end
|
78
84
|
end
|
79
85
|
end
|
80
86
|
end
|
@@ -110,9 +116,12 @@ describe Pubnub::Subscribe do
|
|
110
116
|
sleep 0.1
|
111
117
|
|
112
118
|
eventually do
|
113
|
-
|
114
|
-
|
115
|
-
|
119
|
+
if @statuses.length > 0
|
120
|
+
envelope = @statuses.first
|
121
|
+
expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
|
122
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
123
|
+
true
|
124
|
+
end
|
116
125
|
end
|
117
126
|
end
|
118
127
|
end
|
@@ -131,12 +140,15 @@ describe Pubnub::Subscribe do
|
|
131
140
|
@pubnub.subscribe(channel: :uuid_mg3)
|
132
141
|
|
133
142
|
eventually do
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
143
|
+
if @uuid_metadata_events.length > 0
|
144
|
+
envelope = @uuid_metadata_events.first
|
145
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
146
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
147
|
+
expect(envelope.result[:data][:message]['event']).to eq 'set'
|
148
|
+
expect(envelope.result[:data][:message]['type']).to eq 'uuid'
|
149
|
+
expect(envelope.result[:data][:message]['data']['id']).to eq 'uuid_mg3'
|
150
|
+
true
|
151
|
+
end
|
140
152
|
end
|
141
153
|
end
|
142
154
|
end
|
@@ -155,12 +167,15 @@ describe Pubnub::Subscribe do
|
|
155
167
|
@pubnub.subscribe(channel: :rb_channel_3)
|
156
168
|
|
157
169
|
eventually do
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
170
|
+
if @channel_metadata_events.length > 0
|
171
|
+
envelope = @channel_metadata_events.first
|
172
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
173
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
174
|
+
expect(envelope.result[:data][:message]['event']).to eq 'set'
|
175
|
+
expect(envelope.result[:data][:message]['type']).to eq 'channel'
|
176
|
+
# expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_channel_3'
|
177
|
+
true
|
178
|
+
end
|
164
179
|
end
|
165
180
|
end
|
166
181
|
end
|
@@ -179,12 +194,15 @@ describe Pubnub::Subscribe do
|
|
179
194
|
@pubnub.subscribe(channel: :rb_channel_3)
|
180
195
|
|
181
196
|
eventually do
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
197
|
+
if @membership_events.length > 0
|
198
|
+
envelope = @membership_events.first
|
199
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
200
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
201
|
+
expect(envelope.result[:data][:message]['event']).to eq 'set'
|
202
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
203
|
+
expect(envelope.result[:data][:message]['data']['uuid']['id']).to eq 'uuid_mg3'
|
204
|
+
true
|
205
|
+
end
|
188
206
|
end
|
189
207
|
end
|
190
208
|
end
|
@@ -203,12 +221,15 @@ describe Pubnub::Subscribe do
|
|
203
221
|
@pubnub.subscribe(channel: :uuid_mg5)
|
204
222
|
|
205
223
|
eventually do
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
224
|
+
if @membership_events.length > 0
|
225
|
+
envelope = @membership_events.first
|
226
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
227
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
228
|
+
expect(envelope.result[:data][:message]['event']).to eq 'set'
|
229
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
230
|
+
expect(envelope.result[:data][:message]['data']['channel']['id']).to eq 'rb_channel_5'
|
231
|
+
true
|
232
|
+
end
|
212
233
|
end
|
213
234
|
end
|
214
235
|
end
|
@@ -229,7 +250,10 @@ describe Pubnub::Subscribe do
|
|
229
250
|
@pubnub.subscribe(channel: :whatever, http_sync: true)
|
230
251
|
@messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
|
231
252
|
eventually do
|
232
|
-
|
253
|
+
if @messages.length > 0
|
254
|
+
expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
|
255
|
+
true
|
256
|
+
end
|
233
257
|
end
|
234
258
|
end
|
235
259
|
end
|
@@ -13,8 +13,8 @@ describe Pubnub::SetUuidMetadata do
|
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
VCR.use_cassette("lib/events/
|
16
|
+
it "set_uuid_metadata_works_1" do
|
17
|
+
VCR.use_cassette("lib/events/set_uuid_metadata1", record: :once) do
|
18
18
|
envelope = @pubnub.set_uuid_metadata(
|
19
19
|
uuid: "mg",
|
20
20
|
metadata: { name: "magnum", custom: { XXX: "YYYY" } },
|
@@ -26,8 +26,20 @@ describe Pubnub::SetUuidMetadata do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
VCR.use_cassette("lib/events/
|
29
|
+
it "set_uuid_metadata_works_2" do
|
30
|
+
VCR.use_cassette("lib/events/set_uuid_metadata2", record: :once) do
|
31
|
+
envelope = @pubnub.set_uuid_metadata(
|
32
|
+
metadata: { name: "magnum", custom: { XXX: "YYYY" } },
|
33
|
+
include: { custom: true }
|
34
|
+
).value
|
35
|
+
|
36
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
37
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "get_uuid_metadata_works_1" do
|
42
|
+
VCR.use_cassette("lib/events/get_uuid_metadata1", record: :once) do
|
31
43
|
envelope = @pubnub.get_uuid_metadata(uuid: "mg", include: { custom: true }).value
|
32
44
|
|
33
45
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
@@ -35,6 +47,15 @@ describe Pubnub::SetUuidMetadata do
|
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
50
|
+
it "get_uuid_metadata_works_2" do
|
51
|
+
VCR.use_cassette("lib/events/get_uuid_metadata2", record: :once) do
|
52
|
+
envelope = @pubnub.get_uuid_metadata(include: { custom: true }).value
|
53
|
+
|
54
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
55
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
38
59
|
it "get_all_uuid_metadata_works" do
|
39
60
|
VCR.use_cassette("lib/events/get_all_uuid_metadata", record: :once) do
|
40
61
|
envelope = @pubnub.get_all_uuid_metadata(limit: 5, include: { custom: true }).value
|
@@ -44,13 +65,22 @@ describe Pubnub::SetUuidMetadata do
|
|
44
65
|
end
|
45
66
|
end
|
46
67
|
|
47
|
-
it "
|
48
|
-
VCR.use_cassette("lib/events/
|
68
|
+
it "remove_uuid_metadata_works_1" do
|
69
|
+
VCR.use_cassette("lib/events/remove_uuid_metadata1", record: :once) do
|
49
70
|
envelope = @pubnub.remove_uuid_metadata(uuid: "mg").value
|
50
71
|
|
51
72
|
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
52
73
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
53
74
|
end
|
54
75
|
end
|
76
|
+
|
77
|
+
it "remove_uuid_metadata_works_2" do
|
78
|
+
VCR.use_cassette("lib/events/remove_uuid_metadata2", record: :once) do
|
79
|
+
envelope = @pubnub.remove_uuid_metadata.value
|
80
|
+
|
81
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
82
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
83
|
+
end
|
84
|
+
end
|
55
85
|
end
|
56
86
|
end
|
@@ -86,8 +86,10 @@ describe "Super admin mode" do
|
|
86
86
|
@pubnub.presence(channel: :demo)
|
87
87
|
|
88
88
|
eventually do
|
89
|
-
|
90
|
-
|
89
|
+
if @presences.length > 0
|
90
|
+
expect(@presences.first.status[:client_request].to_s.index("&signature=")).to be_truthy
|
91
|
+
true
|
92
|
+
end
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
@@ -128,8 +130,10 @@ describe "Super admin mode" do
|
|
128
130
|
@pubnub.subscribe(channel: :demo)
|
129
131
|
|
130
132
|
eventually do
|
131
|
-
|
132
|
-
|
133
|
+
if @messages.length > 0
|
134
|
+
expect(@messages.first.status[:client_request].to_s.index("&signature=")).to be_truthy
|
135
|
+
true
|
136
|
+
end
|
133
137
|
end
|
134
138
|
end
|
135
139
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,13 +9,20 @@ require "concurrent"
|
|
9
9
|
require "concurrent-edge"
|
10
10
|
require "rspec/retry"
|
11
11
|
require "simplecov"
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
if ENV['NO_COVERAGE'] != 'true'
|
14
|
+
puts "Gather Code Coverage"
|
15
|
+
|
16
|
+
SimpleCov.start do
|
17
|
+
add_filter "/spec/"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
puts "Skip Code Coverage"
|
14
21
|
end
|
15
22
|
|
16
23
|
require "pubnub"
|
17
24
|
Pubnub::Constants::DEFAULT_RECONNECT_INTERVAL = 0
|
18
|
-
if ENV["CI"] == "true"
|
25
|
+
if ENV["CI"] == "true" && ENV['NO_COVERAGE'] != 'true'
|
19
26
|
require "codacy-coverage"
|
20
27
|
Codacy::Reporter.start
|
21
28
|
end
|
@@ -34,13 +41,22 @@ module AsyncHelper
|
|
34
41
|
def loop_it(interval, time_limit)
|
35
42
|
loop do
|
36
43
|
begin
|
37
|
-
yield
|
44
|
+
check_called = yield
|
45
|
+
check_called = false if check_called.nil?
|
38
46
|
rescue => error
|
39
47
|
cought_error = error
|
40
48
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
|
50
|
+
# Check whether test code in block has been called or not.
|
51
|
+
if (check_called.nil? || !check_called) && Time.now >= time_limit
|
52
|
+
cought_error = 'Eventual condition not met' if cought_error.nil?
|
53
|
+
fail cought_error
|
54
|
+
break
|
55
|
+
elsif !check_called.nil? && check_called
|
56
|
+
break
|
57
|
+
end
|
58
|
+
|
59
|
+
sleep(interval)
|
44
60
|
end
|
45
61
|
end
|
46
62
|
end
|