spec/lib/events/subscribe_spec.rb in pubnub-4.0.5 vs spec/lib/events/subscribe_spec.rb in pubnub-4.0.6
- old
+ new
@@ -13,13 +13,13 @@
before :each do
@messages = []
@statuses = []
@callbacks = Pubnub::SubscribeCallback.new(
- message: ->(envelope) { @messages << envelope },
- presence: ->(_envelope) { },
- status: ->(envelope) { @statuses << envelope }
+ message: ->(envelope) { @messages << envelope },
+ presence: ->(_envelope) {},
+ status: ->(envelope) { @statuses << envelope }
)
end
context 'async' do
it 'works' do
@@ -115,11 +115,11 @@
cipher_key: 'demo'
)
VCR.use_cassette('lib/events/subscribe-cipher-async', record: :once) do
@pubnub.subscribe(channel: :whatever, http_sync: true)
- @messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
+ @messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
eventually do
expect(@messages.first.result[:data][:message]).to eq('text' => 'hey')
end
end
end
@@ -160,9 +160,73 @@
envelope = envelopes.first
expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
+ end
+ end
+ end
+
+ context 'aliases' do
+ it 'pass channels to channel' do
+ VCR.use_cassette('lib/events/subscribe-sync', record: :once) do
+ @pubnub = Pubnub::Client.new(
+ subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
+ publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
+ secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
+ auth_key: 'ruby-test-auth',
+ uuid: 'ruby-test-uuid'
+ )
+
+ @pubnub.subscribe(channels: :demo, http_sync: true)
+ envelopes = @pubnub.subscribe(channels: :demo, http_sync: true)
+
+
+ envelope = envelopes.first
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
+
+ end
+ end
+
+ it 'pass channel_groups to channel_group' do
+ VCR.use_cassette('lib/events/subscribe-channel-groups', record: :once) do
+
+ @pubnub = Pubnub::Client.new(
+ subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
+ publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
+ secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
+ auth_key: 'ruby-test-auth',
+ uuid: 'ruby-test-uuid'
+ )
+
+ @pubnub.subscribe(channel_groups: :demo, http_sync: true)
+ envelopes = @pubnub.subscribe(channel_groups: :demo, http_sync: true)
+
+ envelope = envelopes.first
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
+ end
+ end
+ end
+
+ context 'flags' do
+ it 'with with_presence' do
+ VCR.use_cassette('lib/events/subscribe-with-presence', record: :once) do
+ @pubnub = Pubnub::Client.new(
+ subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
+ publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
+ secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
+ auth_key: 'ruby-test-auth',
+ uuid: 'ruby-test-uuid'
+ )
+
+ @pubnub.subscribe(channels: [:demo, :demo1, 'demo.*'], with_presence: true, http_sync: true)
+ envelopes = @pubnub.subscribe(channels: [:demo, :demo1, 'demo.*'], with_presence: true, http_sync: true)
+
+ envelope = envelopes.first
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
end
end
end
end
end
\ No newline at end of file