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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.pubnub.yml +8 -1
  3. data/.rubocop.yml +9 -3
  4. data/.travis.yml +6 -19
  5. data/CHANGELOG.md +86 -82
  6. data/Gemfile +7 -5
  7. data/Gemfile.lock +155 -157
  8. data/README.md +34 -34
  9. data/VERSION +1 -1
  10. data/gemfiles/celluloid_017.gemfile +4 -4
  11. data/gemfiles/celluloid_018.gemfile +4 -4
  12. data/gemfiles/celluloid_master.gemfile +4 -4
  13. data/gemfiles/concurrent-ruby-1.0.5.gem +0 -0
  14. data/gemfiles/concurrent-ruby-edge-0.3.1.gem +0 -0
  15. data/lib/pubnub.rb +3 -3
  16. data/lib/pubnub/client.rb +19 -16
  17. data/lib/pubnub/client/events.rb +5 -5
  18. data/lib/pubnub/client/getters_setters.rb +11 -12
  19. data/lib/pubnub/client/paged_history.rb +11 -9
  20. data/lib/pubnub/configuration.rb +1 -2
  21. data/lib/pubnub/constants.rb +47 -47
  22. data/lib/pubnub/crypto.rb +2 -2
  23. data/lib/pubnub/envelope.rb +7 -5
  24. data/lib/pubnub/error.rb +22 -15
  25. data/lib/pubnub/event.rb +24 -25
  26. data/lib/pubnub/event/formatter.rb +8 -5
  27. data/lib/pubnub/event/signature.rb +3 -3
  28. data/lib/pubnub/events/audit.rb +1 -1
  29. data/lib/pubnub/events/channel_registration.rb +10 -15
  30. data/lib/pubnub/events/delete_messages.rb +9 -9
  31. data/lib/pubnub/events/grant.rb +3 -3
  32. data/lib/pubnub/events/heartbeat.rb +4 -8
  33. data/lib/pubnub/events/here_now.rb +4 -8
  34. data/lib/pubnub/events/history.rb +10 -10
  35. data/lib/pubnub/events/leave.rb +2 -2
  36. data/lib/pubnub/events/presence.rb +1 -1
  37. data/lib/pubnub/events/publish.rb +3 -5
  38. data/lib/pubnub/events/revoke.rb +3 -3
  39. data/lib/pubnub/events/set_state.rb +3 -3
  40. data/lib/pubnub/events/state.rb +4 -6
  41. data/lib/pubnub/events/subscribe.rb +1 -1
  42. data/lib/pubnub/events/time.rb +2 -2
  43. data/lib/pubnub/events/where_now.rb +6 -6
  44. data/lib/pubnub/format.rb +73 -0
  45. data/lib/pubnub/formatter.rb +23 -21
  46. data/lib/pubnub/heart.rb +4 -4
  47. data/lib/pubnub/origin_manager.rb +3 -5
  48. data/lib/pubnub/pam.rb +5 -5
  49. data/lib/pubnub/schemas/envelope_schema.rb +1 -1
  50. data/lib/pubnub/subscribe_callback.rb +3 -3
  51. data/lib/pubnub/subscribe_event.rb +6 -10
  52. data/lib/pubnub/subscribe_event/formatter.rb +82 -80
  53. data/lib/pubnub/subscribe_event/heartbeat.rb +1 -1
  54. data/lib/pubnub/subscriber.rb +31 -32
  55. data/lib/pubnub/telemetry.rb +26 -27
  56. data/lib/pubnub/validators/audit.rb +3 -2
  57. data/lib/pubnub/validators/channel_registration.rb +6 -4
  58. data/lib/pubnub/validators/client.rb +1 -0
  59. data/lib/pubnub/validators/common_validator.rb +37 -31
  60. data/lib/pubnub/validators/delete.rb +5 -4
  61. data/lib/pubnub/validators/grant.rb +3 -2
  62. data/lib/pubnub/validators/history.rb +3 -2
  63. data/lib/pubnub/validators/leave.rb +3 -2
  64. data/lib/pubnub/validators/presence.rb +3 -2
  65. data/lib/pubnub/validators/publish.rb +15 -10
  66. data/lib/pubnub/validators/set_state.rb +0 -2
  67. data/lib/pubnub/validators/state.rb +3 -2
  68. data/lib/pubnub/version.rb +1 -1
  69. data/pubnub.gemspec +19 -18
  70. data/spec/examples/audit_examples_spec.rb +1268 -1418
  71. data/spec/examples/channel_registration_examples_spec.rb +655 -757
  72. data/spec/examples/delete_messages_examples_spec.rb +19 -21
  73. data/spec/examples/grant_examples_spec.rb +34028 -37920
  74. data/spec/examples/heartbeat_examples_spec.rb +583 -731
  75. data/spec/examples/here_now_examples_spec.rb +493 -569
  76. data/spec/examples/history_examples_spec.rb +979 -1127
  77. data/spec/examples/leave_examples_spec.rb +439 -551
  78. data/spec/examples/presence_examples_spec.rb +686 -830
  79. data/spec/examples/publish_examples_spec.rb +27223 -31547
  80. data/spec/examples/publish_with_ttl_spec.rb +11 -14
  81. data/spec/examples/revoke_examples_spec.rb +68048 -75828
  82. data/spec/examples/set_state_examples_spec.rb +295 -371
  83. data/spec/examples/state_examples_spec.rb +169 -197
  84. data/spec/examples/status_request_message_count_exceeded_spec.rb +16 -19
  85. data/spec/examples/subscribe_examples_spec.rb +43843 -52035
  86. data/spec/examples/time_examples_spec.rb +82 -98
  87. data/spec/examples/where_now_examples_spec.rb +88 -104
  88. data/spec/lib/client_spec.rb +99 -117
  89. data/spec/lib/connection_callback_spec.rb +27 -33
  90. data/spec/lib/custom_retries_examples_spec.rb +8 -11
  91. data/spec/lib/event_spec.rb +35 -42
  92. data/spec/lib/events/audit_spec.rb +19 -25
  93. data/spec/lib/events/channel_registration_spec.rb +17 -23
  94. data/spec/lib/events/delete_messages_spec.rb +14 -20
  95. data/spec/lib/events/grant_spec.rb +15 -21
  96. data/spec/lib/events/heartbeat_spec.rb +21 -27
  97. data/spec/lib/events/here_now_spec.rb +14 -20
  98. data/spec/lib/events/history_spec.rb +14 -20
  99. data/spec/lib/events/leave_spec.rb +14 -20
  100. data/spec/lib/events/presence_delta_spec.rb +15 -16
  101. data/spec/lib/events/presence_spec.rb +36 -45
  102. data/spec/lib/events/publish_spec.rb +33 -40
  103. data/spec/lib/events/revoke_spec.rb +16 -22
  104. data/spec/lib/events/state_spec.rb +16 -22
  105. data/spec/lib/events/subscribe_spec.rb +75 -85
  106. data/spec/lib/events/time_spec.rb +12 -18
  107. data/spec/lib/events/timeout_handling_spec.rb +8 -14
  108. data/spec/lib/events/where_now_spec.rb +14 -20
  109. data/spec/lib/keep_alive_spec.rb +4 -8
  110. data/spec/lib/multiple_ciphers_spec.rb +56 -60
  111. data/spec/lib/pubnub_spec.rb +10 -13
  112. data/spec/lib/signatures_spec.rb +118 -120
  113. data/spec/lib/ssl_error_spec.rb +14 -18
  114. data/spec/lib/super_admin_spec.rb +58 -66
  115. data/spec/lib/uuid_spec.rb +3 -4
  116. data/spec/spec_expectations.rb +3 -3
  117. data/spec/spec_helper.rb +29 -46
  118. metadata +52 -22
  119. data/lib/pubnub/message.rb +0 -43
@@ -1,43 +1,37 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Grant do
4
- it_behaves_like 'an event'
4
+ it_behaves_like "an event"
5
5
 
6
- around :each do |example|
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
  allow_any_instance_of(Pubnub::Grant).to receive(:current_time).and_return 1463146850
15
- allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return 'udCXAk-z4VaU2JA2LgjVzED2LBZAKsjj86twYJoGPnY='
9
+ allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return "udCXAk-z4VaU2JA2LgjVzED2LBZAKsjj86twYJoGPnY="
16
10
  end
17
11
  let(:pubnub) do
18
12
  Pubnub::Client.new(
19
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
20
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
21
- secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
22
- auth_key: 'ruby-test-auth',
23
- uuid: 'ruby-test-uuid'
13
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
14
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
15
+ secret_key: "sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy",
16
+ auth_key: "ruby-test-auth",
17
+ uuid: "ruby-test-uuid",
24
18
  )
25
19
  end
26
20
  let(:envelope) do
27
21
  pubnub.grant(
28
- channel: :demo
22
+ channel: :demo,
29
23
  ).value
30
24
  end
31
25
 
32
- it 'works' do
33
- VCR.use_cassette('lib/events/grant', record: :once) do
26
+ it "works" do
27
+ VCR.use_cassette("lib/events/grant", record: :once) do
34
28
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
35
29
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
36
30
  end
37
31
  end
38
32
 
39
- it 'forms valid ErrorEnvelope on error' do
40
- VCR.use_cassette('lib/events/grant-error', record: :once) do
33
+ it "forms valid ErrorEnvelope on error" do
34
+ VCR.use_cassette("lib/events/grant-error", record: :once) do
41
35
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
42
36
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
43
37
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
@@ -47,7 +41,7 @@ describe Pubnub::Grant do
47
41
  [
48
42
  HTTPClient::ConnectTimeoutError,
49
43
  HTTPClient::ReceiveTimeoutError,
50
- HTTPClient::SendTimeoutError
44
+ HTTPClient::SendTimeoutError,
51
45
  ].each do |error_class|
52
46
  it "forms valid ErrorEnvelope on #{error_class}" do
53
47
  allow_any_instance_of(HTTPClient).to receive(:get).and_return error_class.new
@@ -1,57 +1,51 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Heartbeat do
4
- it_behaves_like 'an event'
4
+ it_behaves_like "an event"
5
5
 
6
- around :each do |example|
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
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
16
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
17
- auth_key: 'ruby-test-auth',
18
- uuid: 'ruby-test-uuid'
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 'works with subscribe' do
16
+ it "works with subscribe" do
23
17
  @pubnub = Pubnub::Client.new(
24
- subscribe_key: 'demo',
25
- publish_key: 'demo',
26
- auth_key: 'ruby-test-auth',
27
- uuid: 'ruby-test-uuid',
28
- heartbeat: '10'
18
+ subscribe_key: "demo",
19
+ publish_key: "demo",
20
+ auth_key: "ruby-test-auth",
21
+ uuid: "ruby-test-uuid",
22
+ heartbeat: "10",
29
23
  )
30
24
 
31
25
  expect(@pubnub.current_heartbeat).to eq 10
32
26
  @pubnub.heartbeat = 3
33
27
  expect(@pubnub.current_heartbeat).to eq 3
34
28
 
35
- VCR.use_cassette('lib/events/heartbeat-sub', record: :once) do
29
+ VCR.use_cassette("lib/events/heartbeat-sub", record: :once) do
36
30
  @pubnub.subscribe(channel: :demo)
37
31
  sleep(1)
38
32
  end
39
33
  end
40
34
 
41
- it 'works' do
42
- VCR.use_cassette('lib/events/heartbeat', record: :once) do
35
+ it "works" do
36
+ VCR.use_cassette("lib/events/heartbeat", record: :once) do
43
37
  envelope = @pubnub.heartbeat(
44
- channel: :demo
38
+ channel: :demo,
45
39
  ).value
46
40
 
47
41
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
48
42
  end
49
43
  end
50
44
 
51
- it 'forms valid ErrorEnvelope on error' do
52
- VCR.use_cassette('lib/events/heartbeat-error', record: :once) do
45
+ it "forms valid ErrorEnvelope on error" do
46
+ VCR.use_cassette("lib/events/heartbeat-error", record: :once) do
53
47
  envelope = @pubnub.heartbeat(
54
- channel: :demo
48
+ channel: :demo,
55
49
  ).value
56
50
 
57
51
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -59,4 +53,4 @@ describe Pubnub::Heartbeat do
59
53
  end
60
54
  end
61
55
  end
62
- end
56
+ end
@@ -1,28 +1,22 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::HereNow do
4
- it_behaves_like 'an event'
4
+ it_behaves_like "an event"
5
5
 
6
- around :each do |example|
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
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
16
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
17
- auth_key: 'ruby-test-auth',
18
- uuid: 'ruby-test-uuid'
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 'works' do
23
- VCR.use_cassette('lib/events/here-now', record: :once) do
16
+ it "works" do
17
+ VCR.use_cassette("lib/events/here-now", record: :once) do
24
18
  envelope = @pubnub.here_now(
25
- channel: :demo
19
+ channel: :demo,
26
20
  ).value
27
21
 
28
22
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
@@ -30,10 +24,10 @@ describe Pubnub::HereNow do
30
24
  end
31
25
  end
32
26
 
33
- it 'forms valid ErrorEnvelope on error' do
34
- VCR.use_cassette('lib/events/here-now-error', record: :once) do
27
+ it "forms valid ErrorEnvelope on error" do
28
+ VCR.use_cassette("lib/events/here-now-error", record: :once) do
35
29
  envelope = @pubnub.here_now(
36
- channel: :demo
30
+ channel: :demo,
37
31
  ).value
38
32
 
39
33
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -41,4 +35,4 @@ describe Pubnub::HereNow do
41
35
  end
42
36
  end
43
37
  end
44
- end
38
+ end
@@ -1,28 +1,22 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::History do
4
- it_behaves_like 'an event'
4
+ it_behaves_like "an event"
5
5
 
6
- around :each do |example|
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
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
16
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
17
- auth_key: 'ruby-test-auth',
18
- uuid: 'ruby-test-uuid'
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 'works' do
23
- VCR.use_cassette('lib/events/history', record: :once) do
16
+ it "works" do
17
+ VCR.use_cassette("lib/events/history", record: :once) do
24
18
  envelope = @pubnub.history(
25
- channel: :demo
19
+ channel: :demo,
26
20
  ).value
27
21
 
28
22
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
@@ -30,10 +24,10 @@ describe Pubnub::History do
30
24
  end
31
25
  end
32
26
 
33
- it 'forms valid ErrorEnvelope on error' do
34
- VCR.use_cassette('lib/events/history-error', record: :once) do
27
+ it "forms valid ErrorEnvelope on error" do
28
+ VCR.use_cassette("lib/events/history-error", record: :once) do
35
29
  envelope = @pubnub.history(
36
- channel: :demo
30
+ channel: :demo,
37
31
  ).value
38
32
 
39
33
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -41,4 +35,4 @@ describe Pubnub::History do
41
35
  end
42
36
  end
43
37
  end
44
- end
38
+ end
@@ -1,38 +1,32 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Leave do
4
- it_behaves_like 'an event'
4
+ it_behaves_like "an event"
5
5
 
6
- around :each do |example|
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
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
16
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
17
- auth_key: 'ruby-test-auth',
18
- uuid: 'ruby-test-uuid'
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 'works' do
23
- VCR.use_cassette('lib/events/leave', record: :once) do
16
+ it "works" do
17
+ VCR.use_cassette("lib/events/leave", record: :once) do
24
18
  envelope = @pubnub.leave(
25
- channel: :demo
19
+ channel: :demo,
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 'forms valid ErrorEnvelope on error' do
33
- VCR.use_cassette('lib/events/leave-error', record: :once) do
26
+ it "forms valid ErrorEnvelope on error" do
27
+ VCR.use_cassette("lib/events/leave-error", record: :once) do
34
28
  envelope = @pubnub.leave(
35
- channel: :demo
29
+ channel: :demo,
36
30
  ).value
37
31
 
38
32
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -40,4 +34,4 @@ describe Pubnub::Leave do
40
34
  end
41
35
  end
42
36
  end
43
- end
37
+ end
@@ -1,38 +1,37 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Presence do
4
+
4
5
  around :each do |example|
5
- Celluloid.boot
6
- example.run
7
- Celluloid.shutdown
6
+ example.run_with_retry retry: 10
8
7
  end
9
8
 
10
- context 'with interval events and delta' do
9
+ context "with interval events and delta" do
11
10
  before :each do
12
11
  @messages = []
13
12
  @statuses = []
14
13
 
15
14
  @callbacks = Pubnub::SubscribeCallback.new(
16
- message: ->(_envelope) { },
17
- presence: ->(envelope) { @messages << envelope },
18
- status: ->(envelope) { @statuses << envelope }
15
+ message: -> (_envelope) { },
16
+ presence: -> (envelope) { @messages << envelope },
17
+ status: -> (envelope) { @statuses << envelope },
19
18
  )
20
19
  end
21
20
 
22
- it 'works' do
23
- pubnub = Pubnub.new(subscribe_key: 'sub-c-9fb06248-0a21-11e7-91d0-02ee2ddab7fe', publish_key: 'pub-c-7a6fa2a4-a4c4-4eb4-9a21-a3334d38209d', uuid: '')
21
+ it "works" do
22
+ pubnub = Pubnub.new(subscribe_key: "sub-c-9fb06248-0a21-11e7-91d0-02ee2ddab7fe", publish_key: "pub-c-7a6fa2a4-a4c4-4eb4-9a21-a3334d38209d", uuid: "")
24
23
  pubnub.add_listener(callback: @callbacks)
25
24
 
26
- VCR.use_cassette('lib/events/presence_delta', record: :once) do
25
+ VCR.use_cassette("lib/events/presence_delta", record: :once) do
27
26
  pubnub.presence(channel: :demo)
28
27
 
29
28
  eventually do
30
- 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}})
31
- 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}})
32
- 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}})
33
- 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
+ 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}})
34
33
  end
35
34
  end
36
35
  end
37
36
  end
38
- end
37
+ end
@@ -1,58 +1,53 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Presence do
4
- it_behaves_like 'an event'
5
-
6
4
  around :each do |example|
7
- Celluloid.boot
8
- example.run
9
- Celluloid.shutdown
5
+ example.run_with_retry retry: 10
10
6
  end
7
+
8
+ it_behaves_like "an event"
11
9
 
12
- context 'given basic parameters' do
10
+ context "given basic parameters" do
13
11
  before :each do
14
12
  @messages = []
15
13
  @statuses = []
16
14
 
17
15
  @callbacks = Pubnub::SubscribeCallback.new(
18
- message: ->(_envelope) { },
19
- presence: ->(envelope) { @messages << envelope },
20
- status: ->(envelope) { @statuses << envelope }
16
+ message: -> (_envelope) { },
17
+ presence: -> (envelope) { @messages << envelope },
18
+ status: -> (envelope) { @statuses << envelope },
21
19
  )
22
20
  end
23
21
 
24
- context 'async' do
25
- it 'works' do
26
- VCR.use_cassette('lib/events/presence-async', record: :once) do
22
+ context "async" do
23
+ it "works" do
24
+ VCR.use_cassette("lib/events/presence-async", record: :once) do
27
25
  @pubnub = Pubnub::Client.new(
28
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
29
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
30
- auth_key: 'ruby-test-auth',
31
- uuid: 'ruby-test-uuid'
26
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
27
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
28
+ auth_key: "ruby-test-auth",
29
+ uuid: "ruby-test-uuid",
32
30
  )
33
31
 
34
32
  @pubnub.add_listener(callback: @callbacks)
35
33
 
36
34
  @pubnub.presence(channel: :demo)
37
35
 
38
-
39
-
40
36
  eventually do
41
37
  envelope = @messages.first
42
38
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
43
39
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
44
40
  end
45
-
46
41
  end
47
42
  end
48
43
 
49
- it 'fires status callback on error' do
50
- VCR.use_cassette('lib/events/presence-async-error', record: :once) do
44
+ it "fires status callback on error" do
45
+ VCR.use_cassette("lib/events/presence-async-error", record: :once) do
51
46
  @pubnub = Pubnub::Client.new(
52
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
53
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
54
- auth_key: 'ruby-test-auth',
55
- uuid: 'ruby-test-uuid'
47
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
48
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
49
+ auth_key: "ruby-test-auth",
50
+ uuid: "ruby-test-uuid",
56
51
  )
57
52
 
58
53
  @pubnub.add_listener(callback: @callbacks)
@@ -63,41 +58,38 @@ describe Pubnub::Presence do
63
58
  eventually do
64
59
  envelope = @statuses.first
65
60
  expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
66
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
61
+ # expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
67
62
  end
68
-
69
63
  end
70
64
  end
71
65
  end
72
66
 
73
- context 'sync' do
74
- it 'works' do
75
- VCR.use_cassette('lib/events/presence-sync', record: :once) do
67
+ context "sync" do
68
+ it "works" do
69
+ VCR.use_cassette("lib/events/presence-sync", record: :once) do
76
70
  @pubnub = Pubnub::Client.new(
77
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
78
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
79
- auth_key: 'ruby-test-auth',
80
- uuid: 'ruby-test-uuid'
71
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
72
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
73
+ auth_key: "ruby-test-auth",
74
+ uuid: "ruby-test-uuid",
81
75
  )
82
76
 
83
77
  @pubnub.presence(channel: :demo, http_sync: true)
84
78
  envelopes = @pubnub.presence(channel: :demo, http_sync: true)
85
79
 
86
-
87
80
  envelope = envelopes.first
88
81
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
89
82
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
90
-
91
83
  end
92
84
  end
93
85
 
94
- it 'fires status callback on error' do
95
- VCR.use_cassette('lib/events/presence-sync-error', record: :once) do
86
+ it "fires status callback on error" do
87
+ VCR.use_cassette("lib/events/presence-sync-error", record: :once) do
96
88
  @pubnub = Pubnub::Client.new(
97
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
98
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
99
- auth_key: 'ruby-test-auth',
100
- uuid: 'ruby-test-uuid'
89
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
90
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
91
+ auth_key: "ruby-test-auth",
92
+ uuid: "ruby-test-uuid",
101
93
  )
102
94
 
103
95
  @pubnub.presence(channel: :demo, http_sync: true)
@@ -106,9 +98,8 @@ describe Pubnub::Presence do
106
98
  envelope = envelopes.first
107
99
  expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
108
100
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
109
-
110
101
  end
111
102
  end
112
103
  end
113
104
  end
114
- end
105
+ end