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,246 +1,218 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::State do
4
4
  around :each do |example|
5
- Celluloid.boot
6
-
7
5
  @fired = false
8
6
 
9
- @callback = ->(_envelope) do
7
+ @callback = -> (_envelope) do
10
8
  @fired = true
11
9
  end
12
10
 
13
11
  @pubnub = Pubnub.new(
14
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
15
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
16
- uuid: 'ruby-test-uuid-client-one',
17
- auth_key: 'ruby-test-auth-client-one'
12
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
13
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
18
16
  )
19
17
 
20
- example.run
21
- Celluloid.shutdown
18
+ example.run_with_retry retry: 10
22
19
  end
23
20
 
24
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback__nil_' do
25
- VCR.use_cassette('examples/state/11', record: :none) do
26
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: true)
27
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
28
- expect(envelope.error?).to eq false
29
-
30
- expect(envelope.status[:code]).to eq(200)
31
- expect(envelope.status[:category]).to eq(:ack)
32
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
33
-
34
- expect(envelope.result[:code]).to eq(200)
35
- expect(envelope.result[:operation]).to eq(:get_state)
36
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
37
-
38
- end
39
- end
40
-
41
-
42
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___block_' do
43
- VCR.use_cassette('examples/state/9', record: :none) do
44
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: true, &@callback)
45
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
46
- expect(envelope.error?).to eq false
47
-
48
- expect(envelope.status[:code]).to eq(200)
49
- expect(envelope.status[:category]).to eq(:ack)
50
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
51
-
52
- expect(envelope.result[:code]).to eq(200)
53
- expect(envelope.result[:operation]).to eq(:get_state)
54
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
21
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback__nil_" do
22
+ VCR.use_cassette("examples/state/11", record: :none) do
23
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true)
24
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
25
+ expect(envelope.error?).to eq false
55
26
 
56
- end
57
- end
58
-
59
-
60
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___lambda_' do
61
- VCR.use_cassette('examples/state/10', record: :none) do
62
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: true, callback: @callback)
63
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
64
- expect(envelope.error?).to eq false
65
-
66
- expect(envelope.status[:code]).to eq(200)
67
- expect(envelope.status[:category]).to eq(:ack)
68
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
69
-
70
- expect(envelope.result[:code]).to eq(200)
71
- expect(envelope.result[:operation]).to eq(:get_state)
72
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
73
-
74
- end
75
- end
27
+ expect(envelope.status[:code]).to eq(200)
28
+ expect(envelope.status[:category]).to eq(:ack)
29
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
76
30
 
31
+ expect(envelope.result[:code]).to eq(200)
32
+ expect(envelope.result[:operation]).to eq(:get_state)
33
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
34
+ end
35
+ end
77
36
 
78
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback__nil_' do
79
- VCR.use_cassette('examples/state/8', record: :none) do
80
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: false)
81
- envelope = envelope.value
82
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
83
- expect(envelope.error?).to eq false
84
-
85
- expect(envelope.status[:code]).to eq(200)
86
- expect(envelope.status[:category]).to eq(:ack)
87
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
88
-
89
- expect(envelope.result[:code]).to eq(200)
90
- expect(envelope.result[:operation]).to eq(:get_state)
91
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
92
-
93
- end
94
- end
95
-
96
-
97
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___block_' do
98
- VCR.use_cassette('examples/state/6', record: :none) do
99
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: false, &@callback)
100
- envelope = envelope.value
101
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
102
- expect(envelope.error?).to eq false
103
-
104
- expect(envelope.status[:code]).to eq(200)
105
- expect(envelope.status[:category]).to eq(:ack)
106
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
107
-
108
- expect(envelope.result[:code]).to eq(200)
109
- expect(envelope.result[:operation]).to eq(:get_state)
110
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
111
-
112
- end
113
- end
114
-
115
-
116
- it '__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___lambda_' do
117
- VCR.use_cassette('examples/state/7', record: :none) do
118
- envelope = @pubnub.state(channel: :demo, uuid: 'ruby-test-uuid', http_sync: false, callback: @callback)
119
- envelope = envelope.value
120
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
121
- expect(envelope.error?).to eq false
122
-
123
- expect(envelope.status[:code]).to eq(200)
124
- expect(envelope.status[:category]).to eq(:ack)
125
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
126
-
127
- expect(envelope.result[:code]).to eq(200)
128
- expect(envelope.result[:operation]).to eq(:get_state)
129
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
130
-
131
- end
132
- end
37
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___block_" do
38
+ VCR.use_cassette("examples/state/9", record: :none) do
39
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true, &@callback)
40
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
41
+ expect(envelope.error?).to eq false
133
42
 
43
+ expect(envelope.status[:code]).to eq(200)
44
+ expect(envelope.status[:category]).to eq(:ack)
45
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
134
46
 
135
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback__nil_' do
136
- VCR.use_cassette('examples/state/5', record: :none) do
137
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: true)
138
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
139
- expect(envelope.error?).to eq false
47
+ expect(envelope.result[:code]).to eq(200)
48
+ expect(envelope.result[:operation]).to eq(:get_state)
49
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
50
+ end
51
+ end
140
52
 
141
- expect(envelope.status[:code]).to eq(200)
142
- expect(envelope.status[:category]).to eq(:ack)
143
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
53
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__true___callback___lambda_" do
54
+ VCR.use_cassette("examples/state/10", record: :none) do
55
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: true, callback: @callback)
56
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
57
+ expect(envelope.error?).to eq false
144
58
 
145
- expect(envelope.result[:code]).to eq(200)
146
- expect(envelope.result[:operation]).to eq(:get_state)
147
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
59
+ expect(envelope.status[:code]).to eq(200)
60
+ expect(envelope.status[:category]).to eq(:ack)
61
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
148
62
 
149
- end
150
- end
63
+ expect(envelope.result[:code]).to eq(200)
64
+ expect(envelope.result[:operation]).to eq(:get_state)
65
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
66
+ end
67
+ end
151
68
 
69
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback__nil_" do
70
+ VCR.use_cassette("examples/state/8", record: :none) do
71
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false)
72
+ envelope = envelope.value
73
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
74
+ expect(envelope.error?).to eq false
152
75
 
153
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___block_' do
154
- VCR.use_cassette('examples/state/3', record: :none) do
155
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: true, &@callback)
156
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
157
- expect(envelope.error?).to eq false
76
+ expect(envelope.status[:code]).to eq(200)
77
+ expect(envelope.status[:category]).to eq(:ack)
78
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
158
79
 
159
- expect(envelope.status[:code]).to eq(200)
160
- expect(envelope.status[:category]).to eq(:ack)
161
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
80
+ expect(envelope.result[:code]).to eq(200)
81
+ expect(envelope.result[:operation]).to eq(:get_state)
82
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
83
+ end
84
+ end
162
85
 
163
- expect(envelope.result[:code]).to eq(200)
164
- expect(envelope.result[:operation]).to eq(:get_state)
165
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
86
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___block_" do
87
+ VCR.use_cassette("examples/state/6", record: :none) do
88
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false, &@callback)
89
+ envelope = envelope.value
90
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
91
+ expect(envelope.error?).to eq false
166
92
 
167
- end
168
- end
93
+ expect(envelope.status[:code]).to eq(200)
94
+ expect(envelope.status[:category]).to eq(:ack)
95
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
169
96
 
97
+ expect(envelope.result[:code]).to eq(200)
98
+ expect(envelope.result[:operation]).to eq(:get_state)
99
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
100
+ end
101
+ end
170
102
 
171
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___lambda_' do
172
- VCR.use_cassette('examples/state/4', record: :none) do
173
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: true, callback: @callback)
174
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
175
- expect(envelope.error?).to eq false
103
+ it "__channel___demo___uuid___ruby-test-uuid____http_sync__false___callback___lambda_" do
104
+ VCR.use_cassette("examples/state/7", record: :none) do
105
+ envelope = @pubnub.state(channel: :demo, uuid: "ruby-test-uuid", http_sync: false, callback: @callback)
106
+ envelope = envelope.value
107
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
108
+ expect(envelope.error?).to eq false
176
109
 
177
- expect(envelope.status[:code]).to eq(200)
178
- expect(envelope.status[:category]).to eq(:ack)
179
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
110
+ expect(envelope.status[:code]).to eq(200)
111
+ expect(envelope.status[:category]).to eq(:ack)
112
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
180
113
 
181
- expect(envelope.result[:code]).to eq(200)
182
- expect(envelope.result[:operation]).to eq(:get_state)
183
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
114
+ expect(envelope.result[:code]).to eq(200)
115
+ expect(envelope.result[:operation]).to eq(:get_state)
116
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
117
+ end
118
+ end
184
119
 
185
- end
186
- end
120
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback__nil_" do
121
+ VCR.use_cassette("examples/state/5", record: :none) do
122
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true)
123
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
124
+ expect(envelope.error?).to eq false
187
125
 
126
+ expect(envelope.status[:code]).to eq(200)
127
+ expect(envelope.status[:category]).to eq(:ack)
128
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
188
129
 
189
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback__nil_' do
190
- VCR.use_cassette('examples/state/2', record: :none) do
191
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: false)
192
- envelope = envelope.value
193
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
194
- expect(envelope.error?).to eq false
130
+ expect(envelope.result[:code]).to eq(200)
131
+ expect(envelope.result[:operation]).to eq(:get_state)
132
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
133
+ end
134
+ end
195
135
 
196
- expect(envelope.status[:code]).to eq(200)
197
- expect(envelope.status[:category]).to eq(:ack)
198
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
136
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___block_" do
137
+ VCR.use_cassette("examples/state/3", record: :none) do
138
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true, &@callback)
139
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
140
+ expect(envelope.error?).to eq false
199
141
 
200
- expect(envelope.result[:code]).to eq(200)
201
- expect(envelope.result[:operation]).to eq(:get_state)
202
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
142
+ expect(envelope.status[:code]).to eq(200)
143
+ expect(envelope.status[:category]).to eq(:ack)
144
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
203
145
 
204
- end
205
- end
146
+ expect(envelope.result[:code]).to eq(200)
147
+ expect(envelope.result[:operation]).to eq(:get_state)
148
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
149
+ end
150
+ end
206
151
 
152
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__true___callback___lambda_" do
153
+ VCR.use_cassette("examples/state/4", record: :none) do
154
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: true, callback: @callback)
155
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
156
+ expect(envelope.error?).to eq false
207
157
 
208
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___block_' do
209
- VCR.use_cassette('examples/state/0', record: :none) do
210
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: false, &@callback)
211
- envelope = envelope.value
212
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
213
- expect(envelope.error?).to eq false
158
+ expect(envelope.status[:code]).to eq(200)
159
+ expect(envelope.status[:category]).to eq(:ack)
160
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
214
161
 
215
- expect(envelope.status[:code]).to eq(200)
216
- expect(envelope.status[:category]).to eq(:ack)
217
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
162
+ expect(envelope.result[:code]).to eq(200)
163
+ expect(envelope.result[:operation]).to eq(:get_state)
164
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
165
+ end
166
+ end
218
167
 
219
- expect(envelope.result[:code]).to eq(200)
220
- expect(envelope.result[:operation]).to eq(:get_state)
221
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
168
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback__nil_" do
169
+ VCR.use_cassette("examples/state/2", record: :none) do
170
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false)
171
+ envelope = envelope.value
172
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
173
+ expect(envelope.error?).to eq false
222
174
 
223
- end
224
- end
175
+ expect(envelope.status[:code]).to eq(200)
176
+ expect(envelope.status[:category]).to eq(:ack)
177
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
225
178
 
179
+ expect(envelope.result[:code]).to eq(200)
180
+ expect(envelope.result[:operation]).to eq(:get_state)
181
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
182
+ end
183
+ end
226
184
 
227
- it '__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___lambda_' do
228
- VCR.use_cassette('examples/state/1', record: :none) do
229
- envelope = @pubnub.state(channel: 'demo', uuid: 'ruby-test-uuid', http_sync: false, callback: @callback)
230
- envelope = envelope.value
231
- expect(envelope.is_a?(Pubnub::Envelope)).to eq true
232
- expect(envelope.error?).to eq false
185
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___block_" do
186
+ VCR.use_cassette("examples/state/0", record: :none) do
187
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false, &@callback)
188
+ envelope = envelope.value
189
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
190
+ expect(envelope.error?).to eq false
233
191
 
234
- expect(envelope.status[:code]).to eq(200)
235
- expect(envelope.status[:category]).to eq(:ack)
236
- expect(envelope.status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
192
+ expect(envelope.status[:code]).to eq(200)
193
+ expect(envelope.status[:category]).to eq(:ack)
194
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
237
195
 
238
- expect(envelope.result[:code]).to eq(200)
239
- expect(envelope.result[:operation]).to eq(:get_state)
240
- expect(envelope.result[:data]).to eq({:state=>{}, :channel=>"demo"})
196
+ expect(envelope.result[:code]).to eq(200)
197
+ expect(envelope.result[:operation]).to eq(:get_state)
198
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
199
+ end
200
+ end
241
201
 
242
- end
243
- end
202
+ it "__channel___demo____uuid___ruby-test-uuid____http_sync__false___callback___lambda_" do
203
+ VCR.use_cassette("examples/state/1", record: :none) do
204
+ envelope = @pubnub.state(channel: "demo", uuid: "ruby-test-uuid", http_sync: false, callback: @callback)
205
+ envelope = envelope.value
206
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
207
+ expect(envelope.error?).to eq false
244
208
 
209
+ expect(envelope.status[:code]).to eq(200)
210
+ expect(envelope.status[:category]).to eq(:ack)
211
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
245
212
 
213
+ expect(envelope.result[:code]).to eq(200)
214
+ expect(envelope.result[:operation]).to eq(:get_state)
215
+ expect(envelope.result[:data]).to eq({:state => {}, :channel => "demo"})
216
+ end
217
+ end
246
218
  end
@@ -1,41 +1,38 @@
1
- require 'spec_helper'
2
-
3
- describe 'Status request message count exceeded' do
1
+ require "spec_helper"
4
2
 
3
+ describe "Status request message count exceeded" do
5
4
  around :each do |example|
6
- Celluloid.boot
7
- example.run
8
- Celluloid.shutdown
5
+ example.run_with_retry retry: 10
9
6
  end
10
7
 
11
8
  before(:each) do
12
- @messages = []
13
- @statuses = []
9
+ @messages = []
10
+ @statuses = []
14
11
  @presences = []
15
12
 
16
13
  @callbacks = Pubnub::SubscribeCallback.new(
17
- message: ->(envelope) { @messages << envelope },
18
- presence: ->(envelope) { @presences << envelope },
19
- status: ->(envelope) { @statuses << envelope }
14
+ message: -> (envelope) { @messages << envelope },
15
+ presence: -> (envelope) { @presences << envelope },
16
+ status: -> (envelope) { @statuses << envelope },
20
17
  )
21
18
 
22
19
  @pubnub = Pubnub.new(
23
- subscribe_key: 'demo',
24
- publish_key: 'demo',
25
- uuid: 'ruby-test',
26
- request_message_count_threshold: 100
20
+ subscribe_key: "demo",
21
+ publish_key: "demo",
22
+ uuid: "ruby-test",
23
+ request_message_count_threshold: 100,
27
24
  )
28
25
 
29
26
  @pubnub.add_listener(callback: @callbacks)
30
27
  end
31
28
 
32
- it 'works' do
33
- VCR.use_cassette('examples/status_request_message_count_exceeded', record: :once) do
34
- @pubnub.subscribe(channel: :demo)
29
+ it "works" do
30
+ VCR.use_cassette("examples/status_request_message_count_exceeded", record: :once) do
31
+ @pubnub.subscribe(channel: :demo)
35
32
 
36
33
  eventually do
37
34
  expect(@statuses[1].status[:category]).to eq(Pubnub::Constants::STATUS_REQUEST_MESSAGE_COUNT_EXCEEDED)
38
35
  end
39
36
  end
40
37
  end
41
- end
38
+ end