Sha256: 74d0be3dd5a093ce4521fba6edf589ae683c808bf1b42ee6ada74b2d9d4f03a2

Contents?: true

Size: 1.32 KB

Versions: 19

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Pubnub::Event do
  before(:each) do

    @callback_counter       = 0
    @error_callback_counter = 0

    @callback       = lambda do |envelope|
      @callback_counter += 1
    end

    @error_callback = lambda do |envelope|
      @error_callback_counter += 1
    end

    @pubnub = Pubnub.new(
        :subscribe_key => :demo,
        :publish_key => :demo,
        :max_retries => 5,
        :error_callback => @error_callback,
        :auth_key => :demoish_authkey,
        :uuid => :rubytests
    )
  end

  context 'single event' do
    context 'when gets non200 response' do
      it 'doesn\'t retry' do
        VCR.use_cassette('single-event-non200', :record => :none) do
          @pubnub.publish(:channel => "demo", :message => {:text => "hey"}, &@callback)
          eventually do
            @callback_counter.should eq 0
            @error_callback_counter.should eq 1
          end
        end
      end
    end

    context 'when gets invalid JSON' do
      it 'do retry' do
        VCR.use_cassette('single-event-invalid-json', :record => :none) do
          @pubnub.publish(:channel => "demo", :message => {:text => "hey"}, &@callback)
          eventually do
            @callback_counter.should eq 1
            @error_callback_counter.should eq 0
          end
        end
      end
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pubnub-3.7.12 spec/lib/retry_logic_spec.rb
pubnub-3.7.11 spec/lib/retry_logic_spec.rb
pubnub-3.7.10 spec/lib/retry_logic_spec.rb
pubnub-3.7.9 spec/lib/retry_logic_spec.rb
pubnub-3.7.7 spec/lib/retry_logic_spec.rb
pubnub-3.7.5 spec/lib/retry_logic_spec.rb
pubnub-3.7.1 spec/lib/retry_logic_spec.rb
pubnub-3.7.0 spec/lib/retry_logic_spec.rb
pubnub-3.6.10 spec/lib/retry_logic_spec.rb
pubnub-3.6.9 spec/lib/retry_logic_spec.rb
pubnub-3.6.7 spec/lib/retry_logic_spec.rb
pubnub-3.5.14 spec/lib/retry_logic_spec.rb
pubnub-3.5.12 spec/lib/retry_logic_spec.rb
pubnub-3.5.8 spec/lib/retry_logic_spec.rb
pubnub-3.5.7 spec/lib/retry_logic_spec.rb
pubnub-3.5.6 spec/lib/retry_logic_spec.rb
pubnub-3.5.5 spec/lib/retry_logic_spec.rb
pubnub-3.5.3 spec/lib/retry_logic_spec.rb
pubnub-3.5.1 spec/lib/retry_logic_spec.rb