pubnub 4.0.27 → 4.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +8 -1
- data/.rubocop.yml +9 -3
- data/.travis.yml +6 -19
- data/CHANGELOG.md +86 -82
- data/Gemfile +7 -5
- data/Gemfile.lock +155 -157
- data/README.md +34 -34
- data/VERSION +1 -1
- data/gemfiles/celluloid_017.gemfile +4 -4
- data/gemfiles/celluloid_018.gemfile +4 -4
- data/gemfiles/celluloid_master.gemfile +4 -4
- data/gemfiles/concurrent-ruby-1.0.5.gem +0 -0
- data/gemfiles/concurrent-ruby-edge-0.3.1.gem +0 -0
- data/lib/pubnub.rb +3 -3
- data/lib/pubnub/client.rb +19 -16
- data/lib/pubnub/client/events.rb +5 -5
- data/lib/pubnub/client/getters_setters.rb +11 -12
- data/lib/pubnub/client/paged_history.rb +11 -9
- data/lib/pubnub/configuration.rb +1 -2
- data/lib/pubnub/constants.rb +47 -47
- data/lib/pubnub/crypto.rb +2 -2
- data/lib/pubnub/envelope.rb +7 -5
- data/lib/pubnub/error.rb +22 -15
- data/lib/pubnub/event.rb +24 -25
- data/lib/pubnub/event/formatter.rb +8 -5
- data/lib/pubnub/event/signature.rb +3 -3
- data/lib/pubnub/events/audit.rb +1 -1
- data/lib/pubnub/events/channel_registration.rb +10 -15
- data/lib/pubnub/events/delete_messages.rb +9 -9
- data/lib/pubnub/events/grant.rb +3 -3
- data/lib/pubnub/events/heartbeat.rb +4 -8
- data/lib/pubnub/events/here_now.rb +4 -8
- data/lib/pubnub/events/history.rb +10 -10
- data/lib/pubnub/events/leave.rb +2 -2
- data/lib/pubnub/events/presence.rb +1 -1
- data/lib/pubnub/events/publish.rb +3 -5
- data/lib/pubnub/events/revoke.rb +3 -3
- data/lib/pubnub/events/set_state.rb +3 -3
- data/lib/pubnub/events/state.rb +4 -6
- data/lib/pubnub/events/subscribe.rb +1 -1
- data/lib/pubnub/events/time.rb +2 -2
- data/lib/pubnub/events/where_now.rb +6 -6
- data/lib/pubnub/format.rb +73 -0
- data/lib/pubnub/formatter.rb +23 -21
- data/lib/pubnub/heart.rb +4 -4
- data/lib/pubnub/origin_manager.rb +3 -5
- data/lib/pubnub/pam.rb +5 -5
- data/lib/pubnub/schemas/envelope_schema.rb +1 -1
- data/lib/pubnub/subscribe_callback.rb +3 -3
- data/lib/pubnub/subscribe_event.rb +6 -10
- data/lib/pubnub/subscribe_event/formatter.rb +82 -80
- data/lib/pubnub/subscribe_event/heartbeat.rb +1 -1
- data/lib/pubnub/subscriber.rb +31 -32
- data/lib/pubnub/telemetry.rb +26 -27
- data/lib/pubnub/validators/audit.rb +3 -2
- data/lib/pubnub/validators/channel_registration.rb +6 -4
- data/lib/pubnub/validators/client.rb +1 -0
- data/lib/pubnub/validators/common_validator.rb +37 -31
- data/lib/pubnub/validators/delete.rb +5 -4
- data/lib/pubnub/validators/grant.rb +3 -2
- data/lib/pubnub/validators/history.rb +3 -2
- data/lib/pubnub/validators/leave.rb +3 -2
- data/lib/pubnub/validators/presence.rb +3 -2
- data/lib/pubnub/validators/publish.rb +15 -10
- data/lib/pubnub/validators/set_state.rb +0 -2
- data/lib/pubnub/validators/state.rb +3 -2
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +19 -18
- data/spec/examples/audit_examples_spec.rb +1268 -1418
- data/spec/examples/channel_registration_examples_spec.rb +655 -757
- data/spec/examples/delete_messages_examples_spec.rb +19 -21
- data/spec/examples/grant_examples_spec.rb +34028 -37920
- data/spec/examples/heartbeat_examples_spec.rb +583 -731
- data/spec/examples/here_now_examples_spec.rb +493 -569
- data/spec/examples/history_examples_spec.rb +979 -1127
- data/spec/examples/leave_examples_spec.rb +439 -551
- data/spec/examples/presence_examples_spec.rb +686 -830
- data/spec/examples/publish_examples_spec.rb +27223 -31547
- data/spec/examples/publish_with_ttl_spec.rb +11 -14
- data/spec/examples/revoke_examples_spec.rb +68048 -75828
- data/spec/examples/set_state_examples_spec.rb +295 -371
- data/spec/examples/state_examples_spec.rb +169 -197
- data/spec/examples/status_request_message_count_exceeded_spec.rb +16 -19
- data/spec/examples/subscribe_examples_spec.rb +43843 -52035
- data/spec/examples/time_examples_spec.rb +82 -98
- data/spec/examples/where_now_examples_spec.rb +88 -104
- data/spec/lib/client_spec.rb +99 -117
- data/spec/lib/connection_callback_spec.rb +27 -33
- data/spec/lib/custom_retries_examples_spec.rb +8 -11
- data/spec/lib/event_spec.rb +35 -42
- data/spec/lib/events/audit_spec.rb +19 -25
- data/spec/lib/events/channel_registration_spec.rb +17 -23
- data/spec/lib/events/delete_messages_spec.rb +14 -20
- data/spec/lib/events/grant_spec.rb +15 -21
- data/spec/lib/events/heartbeat_spec.rb +21 -27
- data/spec/lib/events/here_now_spec.rb +14 -20
- data/spec/lib/events/history_spec.rb +14 -20
- data/spec/lib/events/leave_spec.rb +14 -20
- data/spec/lib/events/presence_delta_spec.rb +15 -16
- data/spec/lib/events/presence_spec.rb +36 -45
- data/spec/lib/events/publish_spec.rb +33 -40
- data/spec/lib/events/revoke_spec.rb +16 -22
- data/spec/lib/events/state_spec.rb +16 -22
- data/spec/lib/events/subscribe_spec.rb +75 -85
- data/spec/lib/events/time_spec.rb +12 -18
- data/spec/lib/events/timeout_handling_spec.rb +8 -14
- data/spec/lib/events/where_now_spec.rb +14 -20
- data/spec/lib/keep_alive_spec.rb +4 -8
- data/spec/lib/multiple_ciphers_spec.rb +56 -60
- data/spec/lib/pubnub_spec.rb +10 -13
- data/spec/lib/signatures_spec.rb +118 -120
- data/spec/lib/ssl_error_spec.rb +14 -18
- data/spec/lib/super_admin_spec.rb +58 -66
- data/spec/lib/uuid_spec.rb +3 -4
- data/spec/spec_expectations.rb +3 -3
- data/spec/spec_helper.rb +29 -46
- metadata +52 -22
- data/lib/pubnub/message.rb +0 -43
@@ -1,70 +1,64 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe 'Connect, disconnect and reconnect callbacks' do
|
1
|
+
require "spec_helper"
|
4
2
|
|
3
|
+
describe "Connect, disconnect and reconnect callbacks" do
|
5
4
|
around :each do |example|
|
6
|
-
|
7
|
-
example.run
|
8
|
-
Celluloid.shutdown
|
5
|
+
example.run_with_retry retry: 10
|
9
6
|
end
|
10
7
|
|
11
8
|
before(:each) do
|
12
9
|
@connect_messages, @reconnect_messages, @disconnect_messages = [], [], []
|
13
10
|
|
14
11
|
callback = Pubnub::SubscribeCallback.new(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@pubnub.leave(channel: :demo)
|
27
|
-
end
|
12
|
+
message: -> (_envelope) { },
|
13
|
+
presence: -> (_envelope) { },
|
14
|
+
status: lambda do |envelope|
|
15
|
+
if envelope.error?
|
16
|
+
@disconnect_messages << envelope
|
17
|
+
else
|
18
|
+
if envelope.status[:last_timetoken] == 0 && !@disconnect_messages.empty?
|
19
|
+
@reconnect_messages << envelope
|
20
|
+
elsif envelope.status[:last_timetoken] == 0 # Connected!
|
21
|
+
@connect_messages << envelope
|
22
|
+
@pubnub.leave(channel: :demo)
|
28
23
|
end
|
29
24
|
end
|
25
|
+
end,
|
30
26
|
)
|
31
27
|
|
32
28
|
@pubnub = Pubnub.new(
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
subscribe_key: :demo,
|
30
|
+
publish_key: :demo,
|
31
|
+
reconnect_interval: 0,
|
36
32
|
)
|
37
33
|
|
38
34
|
@pubnub.add_listener(callback: callback)
|
39
35
|
end
|
40
36
|
|
41
|
-
it
|
42
|
-
VCR.use_cassette(
|
37
|
+
it "fire connect callback when connection is made" do
|
38
|
+
VCR.use_cassette("client/connection_callbacks_0", :record => :once) do
|
43
39
|
@pubnub.subscribe(channel: :demo)
|
44
40
|
sleep 0.5
|
45
41
|
expect(@connect_messages.size).to be > 0
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
49
|
-
it
|
45
|
+
it "fire status callback when connection is lost" do
|
46
|
+
Pubnub::SubscribeEvent.any_instance.stub(:request_dispatcher) { Pubnub::SubscribeEvent.any_instance.unstub(:request_dispatcher); raise "error" }
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
VCR.use_cassette('client/connection_callbacks_1', :record => :once) do
|
48
|
+
VCR.use_cassette("client/connection_callbacks_1", :record => :once) do
|
54
49
|
@pubnub.subscribe(channel: :demo)
|
55
50
|
sleep 0.5
|
56
51
|
expect(@disconnect_messages.size).to be > 0
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
|
-
it
|
61
|
-
Pubnub::SubscribeEvent.any_instance.stub(:request_dispatcher) { Pubnub::SubscribeEvent.any_instance.unstub(:request_dispatcher); raise
|
55
|
+
it "fire reconnect callback when connection is reestablished" do
|
56
|
+
Pubnub::SubscribeEvent.any_instance.stub(:request_dispatcher) { Pubnub::SubscribeEvent.any_instance.unstub(:request_dispatcher); raise "error" }
|
62
57
|
|
63
|
-
VCR.use_cassette(
|
58
|
+
VCR.use_cassette("client/connection_callbacks_2", :record => :once) do
|
64
59
|
@pubnub.subscribe(channel: :demo)
|
65
60
|
sleep 0.5
|
66
61
|
expect(@reconnect_messages.size).to be > 0
|
67
62
|
end
|
68
63
|
end
|
69
|
-
|
70
|
-
end
|
64
|
+
end
|
@@ -1,19 +1,16 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe 'Custom retries' do
|
1
|
+
require "spec_helper"
|
4
2
|
|
3
|
+
describe "Custom retries" do
|
5
4
|
around :each do |example|
|
6
|
-
|
7
|
-
example.run
|
8
|
-
Celluloid.shutdown
|
5
|
+
example.run_with_retry retry: 10
|
9
6
|
end
|
10
7
|
|
11
8
|
before(:each) do
|
12
9
|
@pubnub = Pubnub.new(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
subscribe_key: "sub-c-446d9780-c606-11e5-a316-0619f8945a4f",
|
11
|
+
publish_key: "pub-c-63eb50a0-98ed-43b2-999a-c32efb85c747",
|
12
|
+
secret_key: "sec-c-MTQyMzhjZGUtNTJiYi00MDU0LThkZWQtZDRmMGUwZDk4NjQz",
|
13
|
+
uuid: "ruby-test-client",
|
17
14
|
)
|
18
15
|
end
|
19
16
|
|
@@ -57,4 +54,4 @@ describe 'Custom retries' do
|
|
57
54
|
# expect(@success_envelope.timetoken).to eq '14573583203711342'
|
58
55
|
# end
|
59
56
|
|
60
|
-
end
|
57
|
+
end
|
data/spec/lib/event_spec.rb
CHANGED
@@ -1,86 +1,79 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
shared_examples 'an event' do
|
1
|
+
require "spec_helper"
|
4
2
|
|
3
|
+
shared_examples "an event" do
|
5
4
|
around :each do |example|
|
6
|
-
|
7
|
-
example.run
|
8
|
-
Celluloid.shutdown
|
5
|
+
example.run_with_retry retry: 10
|
9
6
|
end
|
10
7
|
|
11
|
-
it
|
8
|
+
it "is async" do
|
12
9
|
expect(
|
13
|
-
|
14
|
-
.select { |o| o.class == Module }.include?
|
10
|
+
described_class.ancestors
|
11
|
+
.select { |o| o.class == Module }.include? Concurrent::Async
|
15
12
|
).to eq true
|
16
13
|
end
|
17
14
|
|
18
|
-
context
|
19
|
-
let(:pubnub_client) { Pubnub.new(subscribe_key:
|
15
|
+
context "#initialize" do
|
16
|
+
let(:pubnub_client) { Pubnub.new(subscribe_key: "demo") }
|
20
17
|
|
21
|
-
it
|
22
|
-
event = described_class.new({
|
23
|
-
expect(event.instance_variable_get(:@group)).to eq [
|
18
|
+
it "sets :channel_group parameter as @group internal variable" do
|
19
|
+
event = described_class.new({channel_group: "somegroup", skip_validate: true}, pubnub_client)
|
20
|
+
expect(event.instance_variable_get(:@group)).to eq ["somegroup"]
|
24
21
|
end
|
25
22
|
|
26
|
-
it
|
27
|
-
event = described_class.new({
|
28
|
-
expect(event.instance_variable_get(
|
23
|
+
it "sets Pubnub::Client as @app" do
|
24
|
+
event = described_class.new({channel: "channel", skip_validate: true}, pubnub_client)
|
25
|
+
expect(event.instance_variable_get("@app")).to eq pubnub_client
|
29
26
|
end
|
30
27
|
|
31
|
-
it
|
28
|
+
it "logs when initialized" do
|
32
29
|
rd, wr = IO.pipe
|
33
30
|
logger = Logger.new(wr)
|
34
31
|
pubnub = Pubnub.new(subscribe_key: :key, logger: logger)
|
35
32
|
|
36
|
-
described_class.new({
|
33
|
+
described_class.new({channel: "channel", skip_validate: true}, pubnub)
|
37
34
|
|
38
35
|
wr.close
|
39
36
|
messages = rd.read
|
40
37
|
|
41
|
-
expect(messages)
|
42
|
-
.to match(/.*Initialized\s#{described_class}.*/)
|
38
|
+
expect(messages).to match(/.*Initialized\s#{described_class}.*/)
|
43
39
|
end
|
44
40
|
|
45
|
-
|
46
|
-
it 'creates specific instance variables from options' do
|
41
|
+
it "creates specific instance variables from options" do
|
47
42
|
vars = [:@origin, :@channel, :@message, :@http_sync, :@callback,
|
48
43
|
:@ssl, :@cipher_key,
|
49
44
|
:@secret_key, :@auth_key, :@publish_key, :@subscribe_key,
|
50
45
|
:@timetoken, :@channels, :@customs]
|
51
46
|
|
52
|
-
event = described_class.new({
|
47
|
+
event = described_class.new({channel: "channel", skip_validate: true}, pubnub_client)
|
53
48
|
expect(vars - event.instance_variables).to eq []
|
54
49
|
end
|
55
50
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
event = described_class.new({
|
59
|
-
expect(event.instance_variable_get(:@subscribe_key)).to eq
|
51
|
+
context "variables" do
|
52
|
+
it "merges variables from app and options" do
|
53
|
+
event = described_class.new({channel: "chan", skip_validate: true}, pubnub_client)
|
54
|
+
expect(event.instance_variable_get(:@subscribe_key)).to eq "demo"
|
60
55
|
if described_class == Pubnub::Presence
|
61
|
-
expect(event.instance_variable_get(:@channel)).to
|
56
|
+
expect(event.instance_variable_get(:@channel)).to eq ["chan-pnpres"]
|
62
57
|
else
|
63
|
-
expect(event.instance_variable_get(:@channel)).to
|
58
|
+
expect(event.instance_variable_get(:@channel)).to eq ["chan"]
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
67
|
-
it
|
68
|
-
event = described_class.new({
|
69
|
-
expect(event.instance_variable_get(:@subscribe_key)).to eq
|
62
|
+
it "merges variables from app and options overwriting apps" do
|
63
|
+
event = described_class.new({subscribe_key: "key", skip_validate: true}, pubnub_client)
|
64
|
+
expect(event.instance_variable_get(:@subscribe_key)).to eq "key"
|
70
65
|
end
|
71
66
|
|
72
|
-
context
|
67
|
+
context "@channel" do
|
73
68
|
if described_class == Pubnub::Presence
|
74
|
-
it
|
75
|
-
event = described_class.new({
|
76
|
-
expect(event.instance_variable_get(:@channel))
|
77
|
-
.to eq ['chan-pnpres']
|
69
|
+
it "is set properly when passed as :channels" do
|
70
|
+
event = described_class.new({channels: "chan", skip_validate: true}, pubnub_client)
|
71
|
+
expect(event.instance_variable_get(:@channel)).to eq ["chan-pnpres"]
|
78
72
|
end
|
79
73
|
|
80
|
-
it
|
81
|
-
event = described_class.new({
|
82
|
-
expect(event.instance_variable_get(:@channel).class)
|
83
|
-
.to eq Array
|
74
|
+
it "is formatted to be an array" do
|
75
|
+
event = described_class.new({channel: "chan", skip_validate: true}, pubnub_client)
|
76
|
+
expect(event.instance_variable_get(:@channel).class).to eq Array
|
84
77
|
end
|
85
78
|
|
86
79
|
# it 'is formatted when given as string' do
|
@@ -1,32 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Audit do
|
4
|
-
it_behaves_like
|
4
|
+
it_behaves_like "an event"
|
5
5
|
|
6
|
-
|
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::Audit.any_instance.stub(:current_time).and_return 1462972157
|
15
|
-
Pubnub::Audit.any_instance.stub(:signature).and_return
|
9
|
+
Pubnub::Audit.any_instance.stub(:signature).and_return "P3xhzqxwFJSFthJbnByZog-U4j1S5TMFeuUxqKNgMM0="
|
16
10
|
|
17
11
|
@pubnub = Pubnub::Client.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
13
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
14
|
+
secret_key: "sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy",
|
15
|
+
auth_key: "ruby-test-auth",
|
16
|
+
uuid: "ruby-test-uuid",
|
23
17
|
)
|
24
18
|
end
|
25
19
|
|
26
|
-
it
|
27
|
-
VCR.use_cassette(
|
20
|
+
it "works" do
|
21
|
+
VCR.use_cassette("lib/events/audit-works", record: :once) do
|
28
22
|
envelope = @pubnub.audit(
|
29
|
-
|
23
|
+
channel: :demo,
|
30
24
|
).value
|
31
25
|
|
32
26
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
@@ -34,10 +28,10 @@ describe Pubnub::Audit do
|
|
34
28
|
end
|
35
29
|
end
|
36
30
|
|
37
|
-
it
|
38
|
-
VCR.use_cassette(
|
31
|
+
it "forms valid ErrorEnvelope on error" do
|
32
|
+
VCR.use_cassette("lib/events/audit-error", record: :once) do
|
39
33
|
envelope = @pubnub.audit(
|
40
|
-
|
34
|
+
channel: :demo,
|
41
35
|
).value
|
42
36
|
|
43
37
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -46,10 +40,10 @@ describe Pubnub::Audit do
|
|
46
40
|
end
|
47
41
|
end
|
48
42
|
|
49
|
-
it
|
50
|
-
VCR.use_cassette(
|
43
|
+
it "forms valid ErrorEnvelope on json error" do
|
44
|
+
VCR.use_cassette("lib/events/audit-json-error", record: :once) do
|
51
45
|
envelope = @pubnub.audit(
|
52
|
-
|
46
|
+
channel: :demo,
|
53
47
|
).value
|
54
48
|
|
55
49
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -58,4 +52,4 @@ describe Pubnub::Audit do
|
|
58
52
|
end
|
59
53
|
end
|
60
54
|
end
|
61
|
-
end
|
55
|
+
end
|
@@ -1,30 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::ChannelRegistration do
|
4
4
|
# it_behaves_like 'an event'
|
5
5
|
|
6
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
23
|
-
VCR.use_cassette(
|
16
|
+
it "works" do
|
17
|
+
VCR.use_cassette("lib/events/channel-registration", record: :once) do
|
24
18
|
envelope = @pubnub.channel_registration(
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
action: :add,
|
20
|
+
channel: :demo,
|
21
|
+
group: :demo,
|
28
22
|
).value
|
29
23
|
|
30
24
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
@@ -32,12 +26,12 @@ describe Pubnub::ChannelRegistration do
|
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
35
|
-
it
|
36
|
-
VCR.use_cassette(
|
29
|
+
it "forms valid ErrorEnvelope on error" do
|
30
|
+
VCR.use_cassette("lib/events/channel-registration-error", record: :once) do
|
37
31
|
envelope = @pubnub.channel_registration(
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
action: :add,
|
33
|
+
channel: :demo,
|
34
|
+
group: :demo,
|
41
35
|
).value
|
42
36
|
|
43
37
|
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
@@ -45,4 +39,4 @@ describe Pubnub::ChannelRegistration do
|
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|
48
|
-
end
|
42
|
+
end
|
@@ -1,38 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::DeleteMessages do
|
4
|
-
it_behaves_like
|
4
|
+
it_behaves_like "an event"
|
5
5
|
|
6
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
subscribe_key: "sub-c-fc6c9226-655d-11e7-b272-02ee2ddab7fe",
|
10
|
+
publish_key: "pub-c-b458bb23-c95d-4f43-9992-e2c118557e80",
|
11
|
+
auth_key: "ruby-test-auth",
|
12
|
+
uuid: "ruby-test-uuid",
|
19
13
|
)
|
20
14
|
end
|
21
15
|
|
22
|
-
it
|
23
|
-
VCR.use_cassette(
|
16
|
+
it "works" do
|
17
|
+
VCR.use_cassette("lib/events/delete_messages", record: :once) do
|
24
18
|
envelope = @pubnub.delete_messages(
|
25
|
-
|
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
|
33
|
-
VCR.use_cassette(
|
26
|
+
it "forms valid ErrorEnvelope on error" do
|
27
|
+
VCR.use_cassette("lib/events/delete_messages-error", record: :once) do
|
34
28
|
envelope = @pubnub.delete_messages(
|
35
|
-
|
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::DeleteMessages do
|
|
40
34
|
end
|
41
35
|
end
|
42
36
|
end
|
43
|
-
end
|
37
|
+
end
|