Sha256: a49cb37a58feafe22f11ab5ee19568073f1462541c1c7731d464bde150f4b6a0

Contents?: true

Size: 1.48 KB

Versions: 14

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"

describe Pubnub::Heartbeat do
  it_behaves_like "an event"

  context "given basic parameters" do
    before :each do
      @pubnub = Pubnub::Client.new(
        subscribe_key: "sub-a-mock-key",
        publish_key: "pub-a-mock-key",
        auth_key: "ruby-test-auth",
        uuid: "ruby-test-uuid",
      )
    end

    it "works with subscribe" do
      @pubnub = Pubnub::Client.new(
        subscribe_key: "demo",
        publish_key: "demo",
        auth_key: "ruby-test-auth",
        uuid: "ruby-test-uuid",
        heartbeat: "10",
      )

      expect(@pubnub.current_heartbeat).to eq 10
      @pubnub.heartbeat = 3
      expect(@pubnub.current_heartbeat).to eq 3

      VCR.use_cassette("lib/events/heartbeat-sub", record: :once) do
        @pubnub.subscribe(channel: :demo)
        sleep(1)
      end
    end

    it "works" do
      VCR.use_cassette("lib/events/heartbeat", record: :once) do
        envelope = @pubnub.heartbeat(
          channel: :demo,
        ).value

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

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pubnub-4.6.0 spec/lib/events/heartbeat_spec.rb
pubnub-4.5.0 spec/lib/events/heartbeat_spec.rb
pubnub-4.4.0 spec/lib/events/heartbeat_spec.rb
pubnub-4.3.0 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.7 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.6 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.5 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.4 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.3 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.2 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.1 spec/lib/events/heartbeat_spec.rb
pubnub-4.2.0 spec/lib/events/heartbeat_spec.rb
pubnub-4.1.6 spec/lib/events/heartbeat_spec.rb
pubnub-4.1.5 spec/lib/events/heartbeat_spec.rb