spec/lib/events/subscribe_spec.rb in pubnub-4.0.0beta2 vs spec/lib/events/subscribe_spec.rb in pubnub-4.0.0

- old
+ new

@@ -1,9 +1,9 @@ require 'spec_helper' describe Pubnub::Subscribe do - it_behaves_like 'an event' + # it_behaves_like 'an event' around :each do |example| Celluloid.boot example.run Celluloid.shutdown @@ -43,10 +43,46 @@ end end end + it 'works with cipher key' do + @pubnub = Pubnub::Client.new( + subscribe_key: 'demo', + publish_key: 'demo', + uuid: 'ruby-test-uuid', + cipher_key: 'demo' + ) + + @pubnub.add_listener(callback: @callbacks) + + VCR.use_cassette('lib/events/subscribe-cipher-async', record: :once) do + @pubnub.subscribe(channel: :whatever) + + eventually do + expect(@messages.first.result[:data][:message]).to eq('text' => 'hey') + end + end + end + + it 'allows subscribing additional channels' do + @pubnub = Pubnub::Client.new( + subscribe_key: 'demo', + publish_key: 'demo', + uuid: 'ruby-test-uuid' + ) + + VCR.use_cassette('lib/events/subscribe-playing-async', record: :once) do + @pubnub.subscribe(channel: :demo) + #sleep(0.1) + @pubnub.subscribe(channel: :whatever) + #sleep(0.1) + @pubnub.leave(channel: [:whatever, :demo]) + end + + end + it 'fires status callback on error' do VCR.use_cassette('lib/events/subscribe-async-error', 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', @@ -69,9 +105,26 @@ end end end context 'sync' do + it 'works with cipher key' do + @pubnub = Pubnub::Client.new( + subscribe_key: 'demo', + publish_key: 'demo', + uuid: 'ruby-test-uuid', + 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) + eventually do + expect(@messages.first.result[:data][:message]).to eq('text' => 'hey') + end + end + end + it 'works' 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', \ No newline at end of file