pubnub 4.2.5 → 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.

Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.pubnub.yml +168 -117
  4. data/.travis.yml +13 -9
  5. data/CHANGELOG.md +31 -8
  6. data/Gemfile.lock +67 -64
  7. data/README.md +56 -17
  8. data/VERSION +1 -1
  9. data/fixtures/vcr_cassettes/examples/add_channels_to_push/001.yml +45 -0
  10. data/fixtures/vcr_cassettes/examples/add_channels_to_push/002.yml +45 -0
  11. data/fixtures/vcr_cassettes/examples/add_channels_to_push/003.yml +45 -0
  12. data/fixtures/vcr_cassettes/examples/add_channels_to_push/004.yml +45 -0
  13. data/fixtures/vcr_cassettes/examples/grant/1913.yml +1 -1
  14. data/fixtures/vcr_cassettes/examples/grant/1944.yml +8 -9
  15. data/fixtures/vcr_cassettes/examples/grant/1945.yml +359 -9
  16. data/fixtures/vcr_cassettes/examples/grant/1946.yml +8 -9
  17. data/fixtures/vcr_cassettes/examples/grant/1947.yml +8 -9
  18. data/fixtures/vcr_cassettes/examples/grant/1948.yml +8 -9
  19. data/fixtures/vcr_cassettes/examples/history/100.yml +46 -0
  20. data/fixtures/vcr_cassettes/examples/history/include_meta__encrypted.yml +46 -0
  21. data/fixtures/vcr_cassettes/examples/history/include_token__encrypted.yml +45 -0
  22. data/fixtures/vcr_cassettes/examples/history/no_includes__encrypted.yml +45 -0
  23. data/fixtures/vcr_cassettes/examples/list_push_provisions/001.yml +46 -0
  24. data/fixtures/vcr_cassettes/examples/list_push_provisions/002.yml +45 -0
  25. data/fixtures/vcr_cassettes/examples/list_push_provisions/003.yml +45 -0
  26. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/001.yml +45 -0
  27. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/002.yml +45 -0
  28. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/003.yml +45 -0
  29. data/fixtures/vcr_cassettes/examples/remove_device_from_push/001.yml +45 -0
  30. data/fixtures/vcr_cassettes/examples/remove_device_from_push/002.yml +45 -0
  31. data/fixtures/vcr_cassettes/examples/remove_device_from_push/003.yml +45 -0
  32. data/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml +39 -0
  33. data/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml +76 -0
  34. data/fixtures/vcr_cassettes/lib/events/get_channel_members.yml +37 -0
  35. data/fixtures/vcr_cassettes/lib/events/get_channel_metadata.yml +37 -0
  36. data/fixtures/vcr_cassettes/lib/events/get_memberships1.yml +37 -0
  37. data/fixtures/vcr_cassettes/lib/events/get_memberships2.yml +37 -0
  38. data/fixtures/vcr_cassettes/lib/events/get_uuid_metadata1.yml +76 -0
  39. data/fixtures/vcr_cassettes/lib/events/get_uuid_metadata2.yml +76 -0
  40. data/fixtures/vcr_cassettes/lib/events/grant-error.yml +2 -2
  41. data/fixtures/vcr_cassettes/lib/events/grant.yml +10 -11
  42. data/fixtures/vcr_cassettes/lib/events/remove_channel_members.yml +78 -0
  43. data/fixtures/vcr_cassettes/lib/events/{delete_space.yml → remove_channel_metadata.yml} +5 -6
  44. data/fixtures/vcr_cassettes/lib/events/{manage_memberships_remove.yml → remove_memberships1.yml} +8 -9
  45. data/fixtures/vcr_cassettes/lib/events/{manage_members_add.yml → remove_memberships2.yml} +8 -9
  46. data/fixtures/vcr_cassettes/lib/events/remove_uuid_metadata1.yml +76 -0
  47. data/fixtures/vcr_cassettes/lib/events/remove_uuid_metadata2.yml +76 -0
  48. data/fixtures/vcr_cassettes/lib/events/set_channel_members.yml +39 -0
  49. data/fixtures/vcr_cassettes/lib/events/set_channel_metadata.yml +39 -0
  50. data/fixtures/vcr_cassettes/lib/events/{manage_memberships_add.yml → set_memberships1.yml} +8 -9
  51. data/fixtures/vcr_cassettes/lib/events/set_memberships2.yml +39 -0
  52. data/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml +78 -0
  53. data/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml +78 -0
  54. data/fixtures/vcr_cassettes/lib/events/{subscribe-space-delete-async.yml → subscribe-channel-metadata-remove-sync.yml} +12 -14
  55. data/fixtures/vcr_cassettes/lib/events/subscribe-channel-metadata-set-async.yml +75 -0
  56. data/fixtures/vcr_cassettes/lib/events/{subscribe-member-remove-async.yml → subscribe-member-remove-sync.yml} +12 -14
  57. data/fixtures/vcr_cassettes/lib/events/subscribe-member-set-async.yml +75 -0
  58. data/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml +12 -14
  59. data/fixtures/vcr_cassettes/lib/events/{subscribe-user-update-async.yml → subscribe-membership-set-async.yml} +12 -14
  60. data/fixtures/vcr_cassettes/lib/events/{subscribe-user-delete-async.yml → subscribe-uuid-metadata-remove-sync.yml} +12 -14
  61. data/fixtures/vcr_cassettes/lib/events/subscribe-uuid-metadata-set-async.yml +75 -0
  62. data/lib/pubnub/client.rb +18 -15
  63. data/lib/pubnub/client/events.rb +4 -2
  64. data/lib/pubnub/client/paged_history.rb +1 -1
  65. data/lib/pubnub/constants.rb +19 -18
  66. data/lib/pubnub/event.rb +32 -16
  67. data/lib/pubnub/event/formatter.rb +4 -0
  68. data/lib/pubnub/event/signature.rb +22 -7
  69. data/lib/pubnub/events/add_channels_to_push.rb +29 -13
  70. data/lib/pubnub/events/get_all_channels_metadata.rb +104 -0
  71. data/lib/pubnub/events/get_all_uuid_metadata.rb +104 -0
  72. data/lib/pubnub/events/get_channel_members.rb +120 -0
  73. data/lib/pubnub/events/{update_space.rb → get_channel_metadata.rb} +27 -27
  74. data/lib/pubnub/events/get_memberships.rb +120 -0
  75. data/lib/pubnub/events/{create_space.rb → get_uuid_metadata.rb} +27 -25
  76. data/lib/pubnub/events/grant.rb +10 -1
  77. data/lib/pubnub/events/history.rb +17 -2
  78. data/lib/pubnub/events/list_push_provisions.rb +29 -12
  79. data/lib/pubnub/events/remove_channel_members.rb +137 -0
  80. data/lib/pubnub/events/{delete_space.rb → remove_channel_metadata.rb} +12 -12
  81. data/lib/pubnub/events/remove_channels_from_push.rb +29 -13
  82. data/lib/pubnub/events/remove_device_from_push.rb +30 -14
  83. data/lib/pubnub/events/remove_memberships.rb +137 -0
  84. data/lib/pubnub/events/{delete_user.rb → remove_uuid_metadata.rb} +12 -12
  85. data/lib/pubnub/events/set_channel_members.rb +140 -0
  86. data/lib/pubnub/events/{manage_members.rb → set_channel_metadata.rb} +32 -38
  87. data/lib/pubnub/events/set_memberships.rb +140 -0
  88. data/lib/pubnub/events/{create_user.rb → set_uuid_metadata.rb} +33 -17
  89. data/lib/pubnub/formatter.rb +30 -3
  90. data/lib/pubnub/pam.rb +2 -11
  91. data/lib/pubnub/subscribe_callback.rb +1 -3
  92. data/lib/pubnub/subscribe_event/formatter.rb +26 -17
  93. data/lib/pubnub/subscriber.rb +5 -6
  94. data/lib/pubnub/validators/add_channels_to_push.rb +52 -0
  95. data/lib/pubnub/validators/get_all_channels_metadata.rb +29 -0
  96. data/lib/pubnub/validators/get_all_uuid_metadata.rb +29 -0
  97. data/lib/pubnub/validators/get_channel_members.rb +39 -0
  98. data/lib/pubnub/validators/get_channel_metadata.rb +39 -0
  99. data/lib/pubnub/validators/get_memberships.rb +39 -0
  100. data/lib/pubnub/validators/get_uuid_metadata.rb +39 -0
  101. data/lib/pubnub/validators/grant.rb +37 -2
  102. data/lib/pubnub/validators/list_push_provisions.rb +43 -0
  103. data/lib/pubnub/validators/remove_channel_members.rb +52 -0
  104. data/lib/pubnub/validators/remove_channel_metadata.rb +39 -0
  105. data/lib/pubnub/validators/remove_channels_from_push.rb +52 -0
  106. data/lib/pubnub/validators/remove_device_from_push.rb +43 -0
  107. data/lib/pubnub/validators/remove_memberships.rb +52 -0
  108. data/lib/pubnub/validators/remove_uuid_metadata.rb +39 -0
  109. data/lib/pubnub/validators/set_channel_members.rb +78 -0
  110. data/lib/pubnub/validators/set_channel_metadata.rb +62 -0
  111. data/lib/pubnub/validators/set_memberships.rb +78 -0
  112. data/lib/pubnub/validators/set_uuid_metadata.rb +62 -0
  113. data/lib/pubnub/version.rb +1 -1
  114. data/pubnub.gemspec +1 -1
  115. data/spec/examples/add_channels_to_push_spec.rb +178 -0
  116. data/spec/examples/{grant_examples_spec.rb → grant_examples_1_spec.rb} +0 -8973
  117. data/spec/examples/grant_examples_2_spec.rb +9107 -0
  118. data/spec/examples/history_examples_spec.rb +85 -0
  119. data/spec/examples/list_push_provisions_spec.rb +164 -0
  120. data/spec/examples/presence_examples_spec.rb +222 -186
  121. data/spec/examples/remove_channels_from_push_spec.rb +164 -0
  122. data/spec/examples/remove_device_from_push_spec.rb +164 -0
  123. data/spec/examples/revoke_examples_1_spec.rb +27013 -0
  124. data/spec/examples/revoke_examples_2_spec.rb +27012 -0
  125. data/spec/examples/revoke_examples_3_spec.rb +17967 -0
  126. data/spec/examples/status_request_message_count_exceeded_spec.rb +4 -1
  127. data/spec/examples/subscribe_examples_1_spec.rb +26972 -0
  128. data/spec/examples/subscribe_examples_2_spec.rb +19575 -0
  129. data/spec/lib/connection_callback_spec.rb +4 -3
  130. data/spec/lib/event/formatter_spec.rb +22 -0
  131. data/spec/lib/events/channel_metadata_spec.rb +58 -0
  132. data/spec/lib/events/grant_spec.rb +3 -2
  133. data/spec/lib/events/membership_spec.rb +51 -21
  134. data/spec/lib/events/presence_delta_spec.rb +9 -6
  135. data/spec/lib/events/presence_spec.rb +13 -7
  136. data/spec/lib/events/subscribe_spec.rb +102 -65
  137. data/spec/lib/events/uuid_metadata_spec.rb +86 -0
  138. data/spec/lib/subscribe_event/formatter_spec.rb +22 -0
  139. data/spec/lib/super_admin_spec.rb +8 -4
  140. data/spec/spec_helper.rb +24 -8
  141. metadata +124 -79
  142. data/fixtures/vcr_cassettes/lib/events/create_space.yml +0 -40
  143. data/fixtures/vcr_cassettes/lib/events/create_user.yml +0 -40
  144. data/fixtures/vcr_cassettes/lib/events/delete_user.yml +0 -38
  145. data/fixtures/vcr_cassettes/lib/events/get_members.yml +0 -38
  146. data/fixtures/vcr_cassettes/lib/events/get_space.yml +0 -38
  147. data/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml +0 -38
  148. data/fixtures/vcr_cassettes/lib/events/get_spaces.yml +0 -40
  149. data/fixtures/vcr_cassettes/lib/events/get_user.yml +0 -38
  150. data/fixtures/vcr_cassettes/lib/events/get_users.yml +0 -40
  151. data/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml +0 -83
  152. data/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml +0 -77
  153. data/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml +0 -77
  154. data/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml +0 -77
  155. data/fixtures/vcr_cassettes/lib/events/update_space.yml +0 -40
  156. data/fixtures/vcr_cassettes/lib/events/update_user.yml +0 -40
  157. data/lib/pubnub/events/get_members.rb +0 -93
  158. data/lib/pubnub/events/get_space.rb +0 -74
  159. data/lib/pubnub/events/get_space_memberships.rb +0 -93
  160. data/lib/pubnub/events/get_spaces.rb +0 -90
  161. data/lib/pubnub/events/get_user.rb +0 -74
  162. data/lib/pubnub/events/get_users.rb +0 -90
  163. data/lib/pubnub/events/manage_memberships.rb +0 -105
  164. data/lib/pubnub/events/update_user.rb +0 -86
  165. data/lib/pubnub/validators/create_space.rb +0 -44
  166. data/lib/pubnub/validators/create_user.rb +0 -44
  167. data/lib/pubnub/validators/delete_space.rb +0 -32
  168. data/lib/pubnub/validators/delete_user.rb +0 -32
  169. data/lib/pubnub/validators/get_members.rb +0 -32
  170. data/lib/pubnub/validators/get_space.rb +0 -32
  171. data/lib/pubnub/validators/get_space_memberships.rb +0 -32
  172. data/lib/pubnub/validators/get_spaces.rb +0 -16
  173. data/lib/pubnub/validators/get_user.rb +0 -32
  174. data/lib/pubnub/validators/get_users.rb +0 -16
  175. data/lib/pubnub/validators/manage_members.rb +0 -45
  176. data/lib/pubnub/validators/manage_memberships.rb +0 -45
  177. data/lib/pubnub/validators/push.rb +0 -43
  178. data/lib/pubnub/validators/update_space.rb +0 -45
  179. data/lib/pubnub/validators/update_user.rb +0 -45
  180. data/spec/examples/revoke_examples_spec.rb +0 -71950
  181. data/spec/examples/subscribe_examples_spec.rb +0 -45184
  182. data/spec/lib/events/space_spec.rb +0 -75
  183. data/spec/lib/events/user_spec.rb +0 -75
@@ -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 0.5
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 0.5
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 0.5
61
+ sleep @sleep_duration
61
62
  expect(@reconnect_messages.size).to be > 0
62
63
  end
63
64
  end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe "formatter" do
4
+ around :each do |example|
5
+ example.run_with_retry retry: 10
6
+ end
7
+
8
+ it "does not hide errors when formatting" do
9
+ class MockFormatter
10
+ include Pubnub::Event::EFormatter
11
+ end
12
+
13
+ class TestError < StandardError
14
+ def message
15
+ "This is a test"
16
+ end
17
+ end
18
+
19
+ # ensure the correct error is raised instead of -> NoMethodError: undefined method `body'
20
+ expect { MockFormatter.new.format_envelopes(TestError.new('error'), nil) }.to raise_error(TestError)
21
+ end
22
+ end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::SetChannelMetadata do
4
+ it_behaves_like "an event"
5
+
6
+ context "given basic parameters" do
7
+ before :each do
8
+ @pubnub = Pubnub::Client.new(
9
+ subscribe_key: "sub-a-mock-key",
10
+ publish_key: "pub-a-mock-key",
11
+ auth_key: "ruby-test-auth",
12
+ uuid: "ruby-test-uuid"
13
+ )
14
+ end
15
+
16
+ it "set_channel_metadata_works" do
17
+ VCR.use_cassette("lib/events/set_channel_metadata", record: :once) do
18
+ envelope = @pubnub.set_channel_metadata(
19
+ channel: "rb_channel",
20
+ metadata: { name: "some_name", custom: { XXX: "YYYY" } },
21
+ include: { custom: true }
22
+ ).value
23
+
24
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
25
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
26
+ end
27
+ end
28
+
29
+ it "get_channel_metadata_works" do
30
+ VCR.use_cassette("lib/events/get_channel_metadata", record: :once) do
31
+ envelope = @pubnub.get_channel_metadata(channel: "rb_channel", include: { custom: true }).value
32
+
33
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
34
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
35
+ end
36
+ end
37
+
38
+ it "get_all_channels_metadata_works" do
39
+ VCR.use_cassette("lib/events/get_all_channels_metadata", record: :once) do
40
+ envelope = @pubnub.get_all_channels_metadata(limit: 5, include: { custom: true }).value
41
+
42
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
43
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
44
+ end
45
+ end
46
+
47
+ it "remove_channel_metadata_works" do
48
+ VCR.use_cassette("lib/events/remove_channel_metadata", record: :once) do
49
+ envelope = @pubnub.remove_channel_metadata(channel: "rb_channel").value
50
+
51
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
52
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -5,9 +5,10 @@ describe Pubnub::Grant do
5
5
 
6
6
  context "given basic parameters" do
7
7
  before :each do
8
- allow_any_instance_of(Pubnub::Grant).to receive(:current_time).and_return 1463146850
9
- allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return "udCXAk-z4VaU2JA2LgjVzED2LBZAKsjj86twYJoGPnY="
8
+ allow_any_instance_of(Pubnub::Grant).to receive(:current_time).and_return 1602537897
9
+ allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return "v2.OdCTZXne_jEBewh3yY8iNDWcMCHC6BXNrg1Er9JoSTQ"
10
10
  end
11
+
11
12
  let(:pubnub) do
12
13
  Pubnub::Client.new(
13
14
  subscribe_key: "sub-a-mock-key",
@@ -1,63 +1,93 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Pubnub::ManageMemberships do
3
+ describe Pubnub::SetMemberships do
4
4
  it_behaves_like "an event"
5
5
 
6
6
  context "given basic parameters" do
7
7
  before :each do
8
8
  @pubnub = Pubnub::Client.new(
9
- subscribe_key: "demo",
10
- publish_key: "demo",
9
+ subscribe_key: "sub-a-mock-key",
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
- it "get_members_works" do
16
- VCR.use_cassette("lib/events/get_members", record: :once) do
17
- envelope = @pubnub.get_members(space_id: "space-1", include: "custom", count: true).value
15
+
16
+ it "get_channel_members_works" do
17
+ VCR.use_cassette("lib/events/get_channel_members", record: :once) do
18
+ envelope = @pubnub.get_channel_members(channel: "channel-1", include: { count: true, custom: true }).value
18
19
 
19
20
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
20
21
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
21
22
  end
22
23
  end
23
24
 
24
- it "get_space_memberships_works" do
25
- VCR.use_cassette("lib/events/get_space_memberships", record: :once) do
26
- envelope = @pubnub.get_space_memberships(user_id: "mg3", include: "custom", count: true).value
25
+ it "get_memberships_works_1" do
26
+ VCR.use_cassette("lib/events/get_memberships1", record: :once) do
27
+ envelope = @pubnub.get_memberships(uuid: "mg3", include: { count: true, custom: true }).value
27
28
 
28
29
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
29
30
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
30
31
  end
31
32
  end
32
33
 
33
- it "manage_memberships_add_works" do
34
- VCR.use_cassette("lib/events/manage_memberships_add", record: :once) do
35
- envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'add': [{'id': 'space-1'}]}, include: "custom").value
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
36
37
 
37
38
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
38
39
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
39
40
  end
40
41
  end
41
- it "manage_memberships_remove_works" do
42
- VCR.use_cassette("lib/events/manage_memberships_remove", record: :once) do
43
- envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'remove': [{'id': 'space-1'}]}, include: "custom").value
42
+
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
44
46
 
45
47
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
46
48
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
47
49
  end
48
50
  end
49
51
 
50
- it "manage_members_add_works" do
51
- VCR.use_cassette("lib/events/manage_members_add", record: :once) do
52
- envelope = @pubnub.manage_members(space_id: "space-1", data: {'add': [{'id': 'mg2'}]}, include: "custom").value
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
53
55
 
54
56
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
55
57
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
56
58
  end
57
59
  end
58
- it "manage_members_remove_works" do
59
- VCR.use_cassette("lib/events/manage_members_remove", record: :once) do
60
- envelope = @pubnub.manage_members(space_id: "space-1", data: {'remove': [{'id': 'mg2'}]}, include: "custom").value
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
73
+
74
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
75
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
76
+ end
77
+ end
78
+
79
+ it "set_channel_members_works" do
80
+ VCR.use_cassette("lib/events/set_channel_members", record: :once) do
81
+ envelope = @pubnub.set_channel_members(channel: "channel-1", uuids: [{uuid: 'mg2'}], include: { custom: true }).value
82
+
83
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
84
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
85
+ end
86
+ end
87
+
88
+ it "remove_channel_members_works" do
89
+ VCR.use_cassette("lib/events/remove_channel_members", record: :once) do
90
+ envelope = @pubnub.remove_channel_members(channel: "channel-1", uuids: ['mg2'], include: { custom: true }).value
61
91
 
62
92
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
63
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
- @messages = []
11
+ @presences = []
12
12
  @statuses = []
13
13
 
14
14
  @callbacks = Pubnub::SubscribeCallback.new(
15
15
  message: -> (_envelope) { },
16
- presence: -> (envelope) { @messages << 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
- expect(@messages[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}})
30
- expect(@messages[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}})
31
- expect(@messages[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}})
32
- expect(@messages[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}})
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
- envelope = @messages.first
38
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
39
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
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
- envelope = @statuses.first
60
- expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
61
- # expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
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
@@ -13,8 +13,8 @@ describe Pubnub::Subscribe do
13
13
  @messages = []
14
14
  @statuses = []
15
15
  @signals = []
16
- @user_events = []
17
- @space_events = []
16
+ @uuid_metadata_events = []
17
+ @channel_metadata_events = []
18
18
  @membership_events = []
19
19
 
20
20
  @callbacks = Pubnub::SubscribeCallback.new(
@@ -22,9 +22,19 @@ describe Pubnub::Subscribe do
22
22
  presence: -> (_envelope) { },
23
23
  status: -> (envelope) { @statuses << envelope },
24
24
  signal: -> (envelope) { @signals << envelope },
25
- user: -> (envelope) { @user_events << envelope },
26
- space: -> (envelope) { @space_events << envelope },
27
- membership: -> (envelope) { @membership_events << envelope }
25
+ object: -> (envelope) {
26
+ case envelope.result[:operation]
27
+ when Pubnub::Constants::OPERATION_SET_UUID_METADATA, Pubnub::Constants::OPERATION_REMOVE_UUID_METADATA
28
+ @uuid_metadata_events << envelope
29
+ when Pubnub::Constants::OPERATION_SET_CHANNEL_METADATA, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_METADATA
30
+ @channel_metadata_events << envelope
31
+ when Pubnub::Constants::OPERATION_SET_CHANNEL_MEMBERS, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_MEMBERS,
32
+ Pubnub::Constants::OPERATION_SET_MEMBERSHIPS, Pubnub::Constants::OPERATION_REMOVE_MEMBERSHIPS
33
+ @membership_events << envelope
34
+ else
35
+ puts "Unexpected operation"
36
+ end
37
+ }
28
38
  )
29
39
  end
30
40
 
@@ -43,9 +53,12 @@ describe Pubnub::Subscribe do
43
53
  @pubnub.subscribe(channel: :demo)
44
54
 
45
55
  eventually do
46
- envelope = @messages.first
47
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
48
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
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
49
62
  end
50
63
  end
51
64
  end
@@ -64,7 +77,10 @@ describe Pubnub::Subscribe do
64
77
  @pubnub.subscribe(channel: :whatever)
65
78
 
66
79
  eventually do
67
- expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
80
+ if @messages.length > 0
81
+ expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
82
+ true
83
+ end
68
84
  end
69
85
  end
70
86
  end
@@ -100,15 +116,18 @@ describe Pubnub::Subscribe do
100
116
  sleep 0.1
101
117
 
102
118
  eventually do
103
- envelope = @statuses.first
104
- expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
105
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
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
106
125
  end
107
126
  end
108
127
  end
109
128
 
110
- it "user update works" do
111
- VCR.use_cassette("lib/events/subscribe-user-update-async", record: :once) do
129
+ it "uuid metadata update works" do
130
+ VCR.use_cassette("lib/events/subscribe-uuid-metadata-set-async", record: :once) do
112
131
  @pubnub = Pubnub::Client.new(
113
132
  subscribe_key: "sub-a-mock-key",
114
133
  publish_key: "pub-a-mock-key",
@@ -118,20 +137,24 @@ describe Pubnub::Subscribe do
118
137
 
119
138
  @pubnub.add_listener(callback: @callbacks)
120
139
 
121
- @pubnub.subscribe(channel: :user_mg3)
140
+ @pubnub.subscribe(channel: :uuid_mg3)
122
141
 
123
142
  eventually do
124
- envelope = @user_events.first
125
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
126
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
127
- expect(envelope.result[:data][:message]['event']).to eq 'update'
128
- expect(envelope.result[:data][:message]['type']).to eq 'user'
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
129
152
  end
130
153
  end
131
154
  end
132
155
 
133
- it "space update works" do
134
- VCR.use_cassette("lib/events/subscribe-space-update-async", record: :once) do
156
+ it "channel metadata update works" do
157
+ VCR.use_cassette("lib/events/subscribe-channel-metadata-set-async", record: :once) do
135
158
  @pubnub = Pubnub::Client.new(
136
159
  subscribe_key: "sub-a-mock-key",
137
160
  publish_key: "pub-a-mock-key",
@@ -141,20 +164,24 @@ describe Pubnub::Subscribe do
141
164
 
142
165
  @pubnub.add_listener(callback: @callbacks)
143
166
 
144
- @pubnub.subscribe(channel: :rb_space_3)
167
+ @pubnub.subscribe(channel: :rb_channel_3)
145
168
 
146
169
  eventually do
147
- envelope = @space_events.first
148
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
149
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
150
- expect(envelope.result[:data][:message]['event']).to eq 'update'
151
- expect(envelope.result[:data][:message]['type']).to eq 'space'
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
152
179
  end
153
180
  end
154
181
  end
155
182
 
156
- it "member add works" do
157
- VCR.use_cassette("lib/events/subscribe-member-add-async", record: :once) do
183
+ it "member set works" do
184
+ VCR.use_cassette("lib/events/subscribe-member-set-async", record: :once) do
158
185
  @pubnub = Pubnub::Client.new(
159
186
  subscribe_key: "sub-a-mock-key",
160
187
  publish_key: "pub-a-mock-key",
@@ -164,21 +191,24 @@ describe Pubnub::Subscribe do
164
191
 
165
192
  @pubnub.add_listener(callback: @callbacks)
166
193
 
167
- @pubnub.subscribe(channel: :rb_space_4)
194
+ @pubnub.subscribe(channel: :rb_channel_3)
168
195
 
169
196
  eventually do
170
- envelope = @membership_events.first
171
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
172
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
173
- expect(envelope.result[:data][:message]['event']).to eq 'create'
174
- expect(envelope.result[:data][:message]['type']).to eq 'membership'
175
- expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
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
176
206
  end
177
207
  end
178
208
  end
179
209
 
180
- it "membership add works" do
181
- VCR.use_cassette("lib/events/subscribe-membership-add-async", record: :once) do
210
+ it "membership set works" do
211
+ VCR.use_cassette("lib/events/subscribe-membership-set-async", record: :once) do
182
212
  @pubnub = Pubnub::Client.new(
183
213
  subscribe_key: "sub-a-mock-key",
184
214
  publish_key: "pub-a-mock-key",
@@ -188,15 +218,18 @@ describe Pubnub::Subscribe do
188
218
 
189
219
  @pubnub.add_listener(callback: @callbacks)
190
220
 
191
- @pubnub.subscribe(channel: :user_mg4)
221
+ @pubnub.subscribe(channel: :uuid_mg5)
192
222
 
193
223
  eventually do
194
- envelope = @membership_events.first
195
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
196
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
197
- expect(envelope.result[:data][:message]['event']).to eq 'create'
198
- expect(envelope.result[:data][:message]['type']).to eq 'membership'
199
- expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
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
200
233
  end
201
234
  end
202
235
  end
@@ -217,7 +250,10 @@ describe Pubnub::Subscribe do
217
250
  @pubnub.subscribe(channel: :whatever, http_sync: true)
218
251
  @messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
219
252
  eventually do
220
- expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
253
+ if @messages.length > 0
254
+ expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
255
+ true
256
+ end
221
257
  end
222
258
  end
223
259
  end
@@ -258,8 +294,8 @@ describe Pubnub::Subscribe do
258
294
  end
259
295
  end
260
296
 
261
- it "user delete works" do
262
- VCR.use_cassette("lib/events/subscribe-user-delete-async", record: :once) do
297
+ it "uuid metadata remove works" do
298
+ VCR.use_cassette("lib/events/subscribe-uuid-metadata-remove-sync", record: :once) do
263
299
  @pubnub = Pubnub::Client.new(
264
300
  subscribe_key: "sub-a-mock-key",
265
301
  publish_key: "pub-a-mock-key",
@@ -267,19 +303,20 @@ describe Pubnub::Subscribe do
267
303
  uuid: "ruby-test-uuid"
268
304
  )
269
305
 
270
- @pubnub.subscribe(channel: :user_mg3, http_sync: true)
271
- envelopes = @pubnub.subscribe(channel: :user_mg3, http_sync: true)
306
+ @pubnub.subscribe(channel: :uuid_mg3, http_sync: true)
307
+ envelopes = @pubnub.subscribe(channel: :uuid_mg3, http_sync: true)
272
308
 
273
309
  envelope = envelopes.first
274
310
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
275
311
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
276
312
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
277
- expect(envelope.result[:data][:message]['type']).to eq 'user'
313
+ expect(envelope.result[:data][:message]['type']).to eq 'uuid'
314
+ expect(envelope.result[:data][:message]['data']['id']).to eq 'uuid_mg3'
278
315
  end
279
316
  end
280
317
 
281
- it "space delete works" do
282
- VCR.use_cassette("lib/events/subscribe-space-delete-async", record: :once) do
318
+ it "channel metadata remove works" do
319
+ VCR.use_cassette("lib/events/subscribe-channel-metadata-remove-sync", record: :once) do
283
320
  @pubnub = Pubnub::Client.new(
284
321
  subscribe_key: "sub-a-mock-key",
285
322
  publish_key: "pub-a-mock-key",
@@ -287,20 +324,20 @@ describe Pubnub::Subscribe do
287
324
  uuid: "ruby-test-uuid"
288
325
  )
289
326
 
290
- @pubnub.subscribe(channel: :rb_space_3, http_sync: true)
291
- envelopes = @pubnub.subscribe(channel: :rb_space_3, http_sync: true)
327
+ @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
328
+ envelopes = @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
292
329
 
293
330
  envelope = envelopes.first
294
331
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
295
332
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
296
333
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
297
- expect(envelope.result[:data][:message]['type']).to eq 'space'
298
- expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_space_3'
334
+ expect(envelope.result[:data][:message]['type']).to eq 'channel'
335
+ expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_channel_1'
299
336
  end
300
337
  end
301
338
 
302
339
  it "member remove works" do
303
- VCR.use_cassette("lib/events/subscribe-member-remove-async", record: :once) do
340
+ VCR.use_cassette("lib/events/subscribe-member-remove-sync", record: :once) do
304
341
  @pubnub = Pubnub::Client.new(
305
342
  subscribe_key: "sub-a-mock-key",
306
343
  publish_key: "pub-a-mock-key",
@@ -308,15 +345,15 @@ describe Pubnub::Subscribe do
308
345
  uuid: "ruby-test-uuid"
309
346
  )
310
347
 
311
- @pubnub.subscribe(channel: :rb_space_4, http_sync: true)
312
- envelopes = @pubnub.subscribe(channel: :rb_space_4, http_sync: true)
348
+ @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
349
+ envelopes = @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
313
350
 
314
351
  envelope = envelopes.first
315
352
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
316
353
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
317
354
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
318
355
  expect(envelope.result[:data][:message]['type']).to eq 'membership'
319
- expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
356
+ expect(envelope.result[:data][:message]['data']['uuid']['id']).to eq 'uuid_mg1'
320
357
  end
321
358
  end
322
359
 
@@ -329,15 +366,15 @@ describe Pubnub::Subscribe do
329
366
  uuid: "ruby-test-uuid"
330
367
  )
331
368
 
332
- @pubnub.subscribe(channel: :user_mg4, http_sync: true)
333
- envelopes = @pubnub.subscribe(channel: :user_mg4, http_sync: true)
369
+ @pubnub.subscribe(channel: :uuid_mg1, http_sync: true)
370
+ envelopes = @pubnub.subscribe(channel: :uuid_mg1, http_sync: true)
334
371
 
335
372
  envelope = envelopes.first
336
373
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
337
374
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
338
375
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
339
376
  expect(envelope.result[:data][:message]['type']).to eq 'membership'
340
- expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
377
+ expect(envelope.result[:data][:message]['data']['channel']['id']).to eq 'rb_channel_1'
341
378
  end
342
379
 
343
380
  end