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,33 +1,27 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::Time 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
- it 'works' do
22
- VCR.use_cassette('lib/events/time', record: :once) do
15
+ it "works" do
16
+ VCR.use_cassette("lib/events/time", record: :once) do
23
17
  envelope = @pubnub.time.value
24
18
 
25
19
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
26
20
  end
27
21
  end
28
22
 
29
- it 'forms valid ErrorEnvelope on error' do
30
- VCR.use_cassette('lib/events/time-error', record: :once) do
23
+ it "forms valid ErrorEnvelope on error" do
24
+ VCR.use_cassette("lib/events/time-error", record: :once) do
31
25
  envelope = @pubnub.time.value
32
26
 
33
27
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -35,4 +29,4 @@ describe Pubnub::Time do
35
29
  end
36
30
  end
37
31
  end
38
- end
32
+ end
@@ -1,19 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe 'timeout' do
4
- around :each do |example|
5
- Celluloid.boot
6
- example.run
7
- Celluloid.shutdown
8
- end
9
-
10
- context 'in single event' do
3
+ describe "timeout" do
4
+ context "in single event" do
11
5
  let(:pubnub) do
12
6
  Pubnub::Client.new(
13
- subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
14
- publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
15
- auth_key: 'ruby-test-auth',
16
- uuid: 'ruby-test-uuid'
7
+ subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
8
+ publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
9
+ auth_key: "ruby-test-auth",
10
+ uuid: "ruby-test-uuid",
17
11
  )
18
12
  end
19
13
  let(:envelope) { pubnub.time.value }
@@ -21,7 +15,7 @@ describe 'timeout' do
21
15
  [
22
16
  HTTPClient::ConnectTimeoutError,
23
17
  HTTPClient::ReceiveTimeoutError,
24
- HTTPClient::SendTimeoutError
18
+ HTTPClient::SendTimeoutError,
25
19
  ].each do |error_class|
26
20
  it "forms valid ErrorEnvelope on #{error_class}" do
27
21
  allow_any_instance_of(HTTPClient).to receive(:get).and_return error_class.new
@@ -1,27 +1,21 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub::WhereNow 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
- it 'works' do
22
- VCR.use_cassette('lib/events/where-now', record: :once) do
15
+ it "works" do
16
+ VCR.use_cassette("lib/events/where-now", record: :once) do
23
17
  envelope = @pubnub.where_now(
24
- uuid: 'ruby-test'
18
+ uuid: "ruby-test",
25
19
  ).value
26
20
 
27
21
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
@@ -29,10 +23,10 @@ describe Pubnub::WhereNow do
29
23
  end
30
24
  end
31
25
 
32
- it 'forms valid ErrorEnvelope on error' do
33
- VCR.use_cassette('lib/events/where-now-error', record: :once) do
26
+ it "forms valid ErrorEnvelope on error" do
27
+ VCR.use_cassette("lib/events/where-now-error", record: :once) do
34
28
  envelope = @pubnub.where_now(
35
- uuid: 'ruby-test'
29
+ uuid: "ruby-test",
36
30
  ).value
37
31
 
38
32
  expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
@@ -40,4 +34,4 @@ describe Pubnub::WhereNow do
40
34
  end
41
35
  end
42
36
  end
43
- end
37
+ end
@@ -1,13 +1,9 @@
1
- require 'spec_helper'
2
-
3
- describe 'keep_alive connection' do
1
+ require "spec_helper"
4
2
 
3
+ describe "keep_alive connection" 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
- it ''
12
-
8
+ it ""
13
9
  end
@@ -1,145 +1,141 @@
1
- require 'spec_helper'
2
-
3
- describe 'Using multiple cipher keys' do
1
+ require "spec_helper"
4
2
 
3
+ describe "Using multiple cipher keys" 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
- it 'works with publish' do
12
- @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
8
+ it "works with publish" do
9
+ @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: "this_doesnt_fit_anywhere")
13
10
 
14
- VCR.use_cassette('lib/multiple_ciphers', record: :once) do
11
+ VCR.use_cassette("lib/multiple_ciphers", record: :once) do
15
12
  # Fetch current timestamp
16
13
  @pubnub.subscribe(channel: :multiple_cipher_test, http_sync: true)
17
14
 
18
15
  @pubnub.publish(
19
16
  channel: :multiple_cipher_test,
20
- message: 'Some test message',
21
- cipher_key: 'super_secret',
22
- http_sync: true
17
+ message: "Some test message",
18
+ cipher_key: "super_secret",
19
+ http_sync: true,
23
20
  )
24
21
 
25
22
  e0 = @pubnub.subscribe(
26
23
  channel: :multiple_cipher_test,
27
- cipher_key: 'super_secret',
28
- http_sync: true
24
+ cipher_key: "super_secret",
25
+ http_sync: true,
29
26
  ).first
30
27
 
31
28
  @pubnub.publish(
32
29
  channel: :multiple_cipher_test,
33
- message: 'Another test message',
34
- cipher_key: 'another_secret',
35
- http_sync: true
30
+ message: "Another test message",
31
+ cipher_key: "another_secret",
32
+ http_sync: true,
36
33
  )
37
34
 
38
35
  e1 = @pubnub.subscribe(
39
36
  channel: :multiple_cipher_test,
40
- cipher_key: 'another_secret',
41
- http_sync: true
37
+ cipher_key: "another_secret",
38
+ http_sync: true,
42
39
  ).first
43
40
 
44
- expect(e0.result[:data][:message]).to eq 'Some test message'
45
- expect(e1.result[:data][:message]).to eq 'Another test message'
41
+ expect(e0.result[:data][:message]).to eq "Some test message"
42
+ expect(e1.result[:data][:message]).to eq "Another test message"
46
43
  end
47
44
  end
48
45
 
49
- it 'works with history' do
50
- @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
46
+ it "works with history" do
47
+ @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: "this_doesnt_fit_anywhere")
51
48
 
52
- VCR.use_cassette('lib/multiple_ciphers_history', record: :once) do
49
+ VCR.use_cassette("lib/multiple_ciphers_history", record: :once) do
53
50
  @pubnub.publish(
54
51
  channel: :multiple_cipher_test,
55
- message: 'Some test message',
56
- cipher_key: 'super_secret',
57
- http_sync: true
52
+ message: "Some test message",
53
+ cipher_key: "super_secret",
54
+ http_sync: true,
58
55
  )
59
56
 
60
57
  e0 = @pubnub.history(
61
58
  channel: :multiple_cipher_test,
62
- cipher_key: 'super_secret',
59
+ cipher_key: "super_secret",
63
60
  count: 1,
64
- http_sync: true
61
+ http_sync: true,
65
62
  )
66
63
 
67
64
  @pubnub.publish(
68
65
  channel: :multiple_cipher_test,
69
- message: 'Another test message',
70
- cipher_key: 'another_secret',
71
- http_sync: true
66
+ message: "Another test message",
67
+ cipher_key: "another_secret",
68
+ http_sync: true,
72
69
  )
73
70
 
74
71
  e1 = @pubnub.history(
75
72
  channel: :multiple_cipher_test,
76
- cipher_key: 'another_secret',
73
+ cipher_key: "another_secret",
77
74
  count: 1,
78
- http_sync: true
75
+ http_sync: true,
79
76
  )
80
77
 
81
- expect(e0.result[:data][:messages].first).to eq 'Some test message'
82
- expect(e1.result[:data][:messages].first).to eq 'Another test message'
78
+ expect(e0.result[:data][:messages].first).to eq "Some test message"
79
+ expect(e1.result[:data][:messages].first).to eq "Another test message"
83
80
  end
84
81
  end
85
82
 
86
- it 'works with async history' do
87
- @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
83
+ it "works with async history" do
84
+ @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: "this_doesnt_fit_anywhere")
88
85
 
89
- VCR.use_cassette('lib/multiple_ciphers_history', record: :once) do
86
+ VCR.use_cassette("lib/multiple_ciphers_history", record: :once) do
90
87
  @pubnub.publish(
91
88
  channel: :multiple_cipher_test,
92
- message: 'Some test message',
93
- cipher_key: 'super_secret',
94
- http_sync: true
89
+ message: "Some test message",
90
+ cipher_key: "super_secret",
91
+ http_sync: true,
95
92
  )
96
93
 
97
94
  e0 = @pubnub.history(
98
95
  channel: :multiple_cipher_test,
99
- cipher_key: 'super_secret',
100
- count: 1
96
+ cipher_key: "super_secret",
97
+ count: 1,
101
98
  ).value
102
99
 
103
100
  @pubnub.publish(
104
101
  channel: :multiple_cipher_test,
105
- message: 'Another test message',
106
- cipher_key: 'another_secret',
107
- http_sync: true
102
+ message: "Another test message",
103
+ cipher_key: "another_secret",
104
+ http_sync: true,
108
105
  )
109
106
 
110
107
  e1 = @pubnub.history(
111
108
  channel: :multiple_cipher_test,
112
- cipher_key: 'another_secret',
113
- count: 1
109
+ cipher_key: "another_secret",
110
+ count: 1,
114
111
  ).value
115
112
 
116
- expect(e0.result[:data][:messages].first).to eq 'Some test message'
117
- expect(e1.result[:data][:messages].first).to eq 'Another test message'
113
+ expect(e0.result[:data][:messages].first).to eq "Some test message"
114
+ expect(e1.result[:data][:messages].first).to eq "Another test message"
118
115
  end
119
116
  end
120
-
121
- it 'works with asynchronous subscribe and callable cipher key argument' do
117
+
118
+ it "works with asynchronous subscribe and callable cipher key argument" do
122
119
  @message = nil
123
120
  cb = Pubnub::SubscribeCallback.new(
124
- message: ->(envelope){ @message = envelope.result[:data][:message] }
121
+ message: -> (envelope) { @message = envelope.result[:data][:message] },
125
122
  )
126
123
 
127
124
  ciphers = {
128
- 'some-uuid' => 'secret'
125
+ "some-uuid" => "secret",
129
126
  }
130
127
 
131
- lambda_cipher_key = ->(data) do
128
+ lambda_cipher_key = -> (data) do
132
129
  ciphers[data[:issuing_client_id]]
133
130
  end
134
131
 
135
132
  @pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key_selector: lambda_cipher_key)
136
133
  @pubnub.add_listener(callback: cb)
137
134
 
138
- VCR.use_cassette('lib/callable_cipher_key', record: :once) do
135
+ VCR.use_cassette("lib/callable_cipher_key", record: :once) do
139
136
  @pubnub.subscribe(channel: :multiple_cipher_test)
140
137
  sleep(1)
141
- expect(@message).to eq('hello ruby!')
138
+ expect(@message).to eq("hello ruby!")
142
139
  end
143
140
  end
144
-
145
- end
141
+ end
@@ -1,28 +1,25 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pubnub do
4
-
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
- context 'version' do
12
- it 'has VERSION' do
8
+ context "version" do
9
+ it "has VERSION" do
13
10
  expect(Pubnub::VERSION).to match(/\d+\.\d+\..+/)
14
11
  end
15
12
  end
16
13
 
17
- context 'logger' do
18
- it 'is settable' do
19
- logger = Logger.new('pubnub.log')
20
- _pubnub = Pubnub.new(subscribe_key: 'valid', logger: logger)
14
+ context "logger" do
15
+ it "is settable" do
16
+ logger = Logger.new("pubnub.log")
17
+ _pubnub = Pubnub.new(subscribe_key: "valid", logger: logger)
21
18
  expect(Pubnub.logger).to be logger
22
19
  end
23
20
 
24
- it 'is set by default if not provided' do
25
- _pubnub = Pubnub.new(subscribe_key: 'valid')
21
+ it "is set by default if not provided" do
22
+ _pubnub = Pubnub.new(subscribe_key: "valid")
26
23
  expect(Pubnub.logger.class).to be Logger
27
24
  end
28
25
  end
@@ -1,206 +1,204 @@
1
- require 'spec_helper'
2
-
3
- describe 'Signatures' do
1
+ require "spec_helper"
4
2
 
3
+ describe "Signatures" 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
- it 'works all letters channel' do
12
- stub_const('Pubnub::VERSION', '4.0.21')
8
+ it "works all letters channel" do
9
+ stub_const("Pubnub::VERSION", "4.0.21")
13
10
  Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242823)
14
11
 
15
12
  pubnub = Pubnub.new(
16
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
17
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
18
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
19
- uuid: 'test'
13
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
14
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
15
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
16
+ uuid: "test",
20
17
  )
21
18
 
22
- VCR.use_cassette('lib/signatures/all-letters', record: :once) do
23
- envelope = pubnub.grant(channel: 'demo', http_sync: true)
19
+ VCR.use_cassette("lib/signatures/all-letters", record: :once) do
20
+ envelope = pubnub.grant(channel: "demo", http_sync: true)
24
21
  expect(envelope.status[:code]).to eq 200
25
22
  end
26
23
  end
27
24
 
28
- it 'works with wildcard' do
29
- stub_const('Pubnub::VERSION', '4.0.21')
25
+ it "works with wildcard" do
26
+ stub_const("Pubnub::VERSION", "4.0.21")
30
27
  Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242823)
31
28
 
32
29
  pubnub = Pubnub.new(
33
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
34
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
35
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
36
- uuid: 'test'
30
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
31
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
32
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
33
+ uuid: "test",
37
34
  )
38
35
 
39
- VCR.use_cassette('lib/signatures/wildcard', record: :once) do
40
- envelope = pubnub.grant(channel: 'demo.*', http_sync: true)
36
+ VCR.use_cassette("lib/signatures/wildcard", record: :once) do
37
+ envelope = pubnub.grant(channel: "demo.*", http_sync: true)
41
38
  expect(envelope.status[:code]).to eq 200
42
39
  end
43
40
  end
44
41
 
45
- context 'with various special characters' do
46
- it 'grant works' do
47
- stub_const('Pubnub::VERSION', '4.0.21')
42
+ context "with various special characters" do
43
+ it "grant works" do
44
+ stub_const("Pubnub::VERSION", "4.0.21")
48
45
  Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242824)
49
46
 
50
47
  pubnub = Pubnub.new(
51
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
52
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
53
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
54
- uuid: 'test'
48
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
49
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
50
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
51
+ uuid: "test",
55
52
  )
56
53
 
57
- VCR.use_cassette('lib/signatures/special', record: :once) do
54
+ VCR.use_cassette("lib/signatures/special", record: :once) do
58
55
  envelope = pubnub.grant(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
59
56
  expect(envelope.status[:code]).to eq 200
60
57
  end
61
58
  end
62
59
 
63
- it 'publish works' do
64
- stub_const('Pubnub::VERSION', '4.0.21')
60
+ it "publish works" do
61
+ stub_const("Pubnub::VERSION", "4.0.21")
65
62
  Pubnub::Publish.any_instance.stub(:current_time).and_return 1496396127
66
63
  Pubnub::Client.any_instance.stub(:generate_ortt).and_return 14963961271418600
67
64
 
68
65
  pubnub = Pubnub.new(
69
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
70
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
71
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
72
- uuid: 'test'
66
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
67
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
68
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
69
+ uuid: "test",
73
70
  )
74
71
 
75
- VCR.use_cassette('lib/signatures/publish', record: :once) do
72
+ VCR.use_cassette("lib/signatures/publish", record: :once) do
76
73
  envelope = pubnub.publish(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', message: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
77
74
  expect(envelope.status[:code]).to eq 200
78
75
  end
79
76
  end
80
77
 
81
- it 'subscribe works' do
82
- stub_const('Pubnub::VERSION', '4.0.21')
78
+ it "subscribe works" do
79
+ stub_const("Pubnub::VERSION", "4.0.21")
83
80
  Pubnub::Subscribe.any_instance.stub(:current_time).and_return 1496397558
84
81
 
85
82
  pubnub = Pubnub.new(
86
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
87
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
88
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
89
- uuid: 'test'
83
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
84
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
85
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
86
+ uuid: "test",
90
87
  )
91
88
 
92
- VCR.use_cassette('lib/signatures/subscribe', record: :once) do
89
+ VCR.use_cassette("lib/signatures/subscribe", record: :once) do
93
90
  envelope = pubnub.subscribe(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
94
91
  expect(envelope.first.status[:code]).to eq 200
95
92
  end
96
93
  end
97
94
 
98
- it 'presence works' do
99
- stub_const('Pubnub::VERSION', '4.0.21')
95
+ it "presence works" do
96
+ stub_const("Pubnub::VERSION", "4.0.21")
100
97
  Pubnub::Presence.any_instance.stub(:current_time).and_return 1496401532
101
98
 
102
99
  pubnub = Pubnub.new(
103
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
104
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
105
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
106
- uuid: 'test'
100
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
101
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
102
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
103
+ uuid: "test",
107
104
  )
108
105
 
109
- VCR.use_cassette('lib/signatures/presence', record: :once) do
106
+ VCR.use_cassette("lib/signatures/presence", record: :once) do
110
107
  envelope = pubnub.presence(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
111
108
  expect(envelope.first.status[:code]).to eq 200
112
109
  end
113
110
  end
114
111
 
115
- it 'leave works' do
116
- stub_const('Pubnub::VERSION', '4.0.21')
112
+ it "leave works" do
113
+ stub_const("Pubnub::VERSION", "4.0.21")
117
114
  Pubnub::Leave.any_instance.stub(:current_time).and_return 1496401409
118
115
 
119
116
  pubnub = Pubnub.new(
120
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
121
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
122
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
123
- uuid: 'test'
117
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
118
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
119
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
120
+ uuid: "test",
124
121
  )
125
122
 
126
- VCR.use_cassette('lib/signatures/leave', record: :once) do
123
+ VCR.use_cassette("lib/signatures/leave", record: :once) do
127
124
  envelope = pubnub.leave(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
128
125
  expect(envelope.status[:code]).to eq 200
129
126
  end
130
127
  end
131
128
 
132
- it 'history works' do
133
- stub_const('Pubnub::VERSION', '4.0.21')
129
+ it "history works" do
130
+ stub_const("Pubnub::VERSION", "4.0.21")
134
131
  Pubnub::History.any_instance.stub(:current_time).and_return 1496396745
135
132
 
136
133
  pubnub = Pubnub.new(
137
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
138
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
139
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
140
- uuid: 'test'
134
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
135
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
136
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
137
+ uuid: "test",
141
138
  )
142
139
 
143
- VCR.use_cassette('lib/signatures/history', record: :once) do
140
+ VCR.use_cassette("lib/signatures/history", record: :once) do
144
141
  envelope = pubnub.history(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
145
142
  expect(envelope.status[:code]).to eq 200
146
143
  end
147
144
  end
148
145
 
149
- it 'here-now works' do
150
- stub_const('Pubnub::VERSION', '4.0.21')
146
+ it "here-now works" do
147
+ stub_const("Pubnub::VERSION", "4.0.21")
151
148
  Pubnub::HereNow.any_instance.stub(:current_time).and_return 1496401140
152
149
 
153
150
  pubnub = Pubnub.new(
154
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
155
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
156
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
157
- uuid: 'test'
151
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
152
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
153
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
154
+ uuid: "test",
158
155
  )
159
156
 
160
- VCR.use_cassette('lib/signatures/here_now', record: :once) do
157
+ VCR.use_cassette("lib/signatures/here_now", record: :once) do
161
158
  envelope = pubnub.here_now(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
162
159
  expect(envelope.status[:code]).to eq 200
163
160
  end
164
161
  end
165
162
 
166
- it 'channel registration works' do
167
- stub_const('Pubnub::VERSION', '4.0.21')
163
+ it "channel registration works" do
164
+ stub_const("Pubnub::VERSION", "4.0.21")
168
165
  pubnub = Pubnub.new(
169
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
170
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
171
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
172
- uuid: 'test'
166
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
167
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
168
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
169
+ uuid: "test",
173
170
  )
171
+ pubnub.env[:no_telemetry] = true
174
172
 
175
- VCR.use_cassette('lib/signatures/channel_registration', record: :once) do
173
+ VCR.use_cassette("lib/signatures/channel_registration", record: :once) do
176
174
  Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
177
175
  envelope0 = pubnub.channel_registration(
178
- action: :add,
179
- channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
180
- channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
181
- http_sync: true
176
+ action: :add,
177
+ channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
178
+ channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
179
+ http_sync: true,
182
180
  )
183
181
 
184
182
  Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
185
183
  envelope1 = pubnub.channel_registration(
186
- action: :get,
187
- channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
188
- http_sync: true
184
+ action: :get,
185
+ channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
186
+ http_sync: true,
189
187
  )
190
188
 
191
189
  Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
192
190
  envelope2 = pubnub.channel_registration(
193
- action: :remove,
194
- channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
195
- channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
196
- http_sync: true
191
+ action: :remove,
192
+ channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
193
+ channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
194
+ http_sync: true,
197
195
  )
198
196
 
199
197
  Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
200
198
  envelope3 = pubnub.channel_registration(
201
- action: :remove,
202
- channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
203
- http_sync: true
199
+ action: :remove,
200
+ channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
201
+ http_sync: true,
204
202
  )
205
203
 
206
204
  expect(envelope0.status[:code]).to eq 200
@@ -210,40 +208,40 @@ describe 'Signatures' do
210
208
  end
211
209
  end
212
210
 
213
- it 'heartbeat works' do
214
- stub_const('Pubnub::VERSION', '4.0.21')
211
+ it "heartbeat works" do
212
+ stub_const("Pubnub::VERSION", "4.0.21")
215
213
  Pubnub::Heartbeat.any_instance.stub(:current_time).and_return 1496400995
216
214
 
217
215
  pubnub = Pubnub.new(
218
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
219
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
220
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
221
- uuid: 'test'
216
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
217
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
218
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
219
+ uuid: "test",
222
220
  )
223
221
 
224
- VCR.use_cassette('lib/signatures/heartbeat', record: :once) do
222
+ VCR.use_cassette("lib/signatures/heartbeat", record: :once) do
225
223
  envelope = pubnub.heartbeat(channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z', heartbeat: 10, http_sync: true)
226
224
  expect(envelope.status[:code]).to eq 200
227
225
  end
228
226
  end
229
227
 
230
- it 'state works' do
231
- stub_const('Pubnub::VERSION', '4.0.21')
228
+ it "state works" do
229
+ stub_const("Pubnub::VERSION", "4.0.21")
232
230
  Pubnub::SetState.any_instance.stub(:current_time).and_return 1496402248
233
231
  Pubnub::State.any_instance.stub(:current_time).and_return 1496402248
234
-
235
232
  pubnub = Pubnub.new(
236
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
237
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
238
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
239
- uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z'
233
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
234
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
235
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
236
+ uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
240
237
  )
238
+ pubnub.env[:no_telemetry] = true
241
239
 
242
- VCR.use_cassette('lib/signatures/state', record: :once) do
240
+ VCR.use_cassette("lib/signatures/state", record: :once) do
243
241
  envelope = pubnub.set_state(
244
- channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z',
245
- state: { something: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z' },
246
- http_sync: true
242
+ channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z',
243
+ state: {something: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z'},
244
+ http_sync: true,
247
245
  )
248
246
 
249
247
  expect(envelope.status[:code]).to eq 200
@@ -253,21 +251,21 @@ describe 'Signatures' do
253
251
  end
254
252
  end
255
253
 
256
- it 'where now works' do
257
- stub_const('Pubnub::VERSION', '4.0.21')
254
+ it "where now works" do
255
+ stub_const("Pubnub::VERSION", "4.0.21")
258
256
  Pubnub::WhereNow.any_instance.stub(:current_time).and_return 1496402114
259
257
 
260
258
  pubnub = Pubnub.new(
261
- subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
262
- publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
263
- secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
264
- uuid: 'test'
259
+ subscribe_key: "sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe",
260
+ publish_key: "pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d",
261
+ secret_key: "sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi",
262
+ uuid: "test",
265
263
  )
266
264
 
267
- VCR.use_cassette('lib/signatures/where_now', record: :once) do
265
+ VCR.use_cassette("lib/signatures/where_now", record: :once) do
268
266
  envelope = pubnub.where_now(
269
- uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
270
- http_sync: true
267
+ uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
268
+ http_sync: true,
271
269
  )
272
270
 
273
271
  expect(envelope.status[:code]).to eq 200