Sha256: dd1642d26dd0e6f94bb5ad4354f8589e5e30d97a389985b9db0af4e167ff3589

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Pubnub::Publish do
  it_behaves_like 'an event'

  around :each do |example|
    Celluloid.boot
    example.run
    Celluloid.shutdown
  end

  context 'given basic parameters' do
    before :each 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'
      )
    end
    it 'works' do
      VCR.use_cassette('lib/events/publish', record: :once) do
        envelope = @pubnub.publish(
            channel: :demo,
            message: 'whatever'
        ).value

        expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
      end
    end

    it 'forms valid ErrorEnvelope on error' do
      VCR.use_cassette('lib/events/publish-error', record: :once) do
        envelope = @pubnub.publish(
            channel: :demo,
            message: 'whatever'
        ).value

        expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
        expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pubnub-4.0.0beta2 spec/lib/events/publish_spec.rb
pubnub-4.0.0beta1 spec/lib/events/publish_spec.rb