Sha256: c8d9ae47092277e82a9c9eeb04733f31033f41dfe56a7799c0133e9b101cf9c8

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

describe Pubnub::Client do
  it 'has valid version constant' do
    expect(Pubnub::Client::VERSION).to match(/\d+\.\d+\..+/)
  end

  context '#inititalize' do
    it 'requires arguments' do
      expect{ Pubnub.new() }.to raise_error
    end

    context 'parameter :subscribe_key' do
      it 'is required' do
        expect{ Pubnub.new(:http_sync => true) }.to raise_error(Pubnub::InitializationError)
      end

      it 'must be valid' do
        expect{ Pubnub.new(:subscribe_key => 123) }.to raise_error(Pubnub::InitializationError)
        expect{ Pubnub.new(:subscribe_key => [] ) }.to raise_error(Pubnub::InitializationError)
        expect{ Pubnub.new(:subscribe_key => {} ) }.to raise_error(Pubnub::InitializationError)

        expect{ Pubnub.new(:subscribe_key => 'key') }.not_to raise_error
        expect{ Pubnub.new(:subscribe_key => :key ) }.not_to raise_error
      end
    end

    context 'parameter :publish_key' do
      it 'must be valid' do
        expect{ Pubnub.new(:subscribe_key => 'valid', :publish_key => ['invalid']) }.to raise_error(Pubnub::InitializationError)
        expect{ Pubnub.new(:subscribe_key => 'valid', :publish_key => {'invalid' => 'yeah'}) }.to raise_error(Pubnub::InitializationError)
        expect{ Pubnub.new(:subscribe_key => 'valid', :publish_key => ['invalid']) }.to raise_error(Pubnub::InitializationError)

        expect{ Pubnub.new(:subscribe_key => 'valid', :publish_key => 'key') }.not_to raise_error
        expect{ Pubnub.new(:subscribe_key => 'valid', :publish_key => :key ) }.not_to raise_error
      end
    end

    it 'doesnt start EventMachine reactor' do
      pubnub = Pubnub.new(:subscribe_key => 'key')
      sleep(0.1)
      expect(EM.reactor_running?).to eq(false)
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pubnub-3.7.12 spec/lib/client_spec.rb
pubnub-3.7.11 spec/lib/client_spec.rb
pubnub-3.7.10 spec/lib/client_spec.rb
pubnub-3.7.9 spec/lib/client_spec.rb
pubnub-3.7.7 spec/lib/client_spec.rb
pubnub-3.7.5 spec/lib/client_spec.rb
pubnub-3.7.1 spec/lib/client_spec.rb
pubnub-3.7.0 spec/lib/client_spec.rb
pubnub-3.6.10 spec/lib/client_spec.rb
pubnub-3.6.9 spec/lib/client_spec.rb
pubnub-3.6.7 spec/lib/client_spec.rb