Sha256: 8c4ba4824059ce5de4ca7bd08a46da0a817fc26beff083382a9637b55830415f

Contents?: true

Size: 1.19 KB

Versions: 64

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Ably::Realtime::Client, '#time', :event_machine do
  vary_by_protocol do
    let(:client) do
      auto_close Ably::Realtime::Client.new(key: api_key, environment: environment, protocol: protocol)
    end

    describe 'fetching the service time' do
      it 'should return the service time as a Time object' do
        run_reactor do
          client.time do |time|
            expect(time).to be_within(2).of(Time.now)
            stop_reactor
          end
        end
      end

      it 'returns a SafeDeferrable that catches exceptions in callbacks and logs them' do
        run_reactor do
          expect(client.time).to be_a(Ably::Util::SafeDeferrable)
          stop_reactor
        end
      end

      context 'with reconfigured HTTP timeout' do
        let(:client) do
          auto_close Ably::Realtime::Client.new(http_request_timeout: 0.0001, key: api_key, environment: environment, protocol: protocol, log_level: :fatal)
        end

        it 'should raise a timeout exception' do
          client.time.errback do |error|
            expect(error).to be_a Ably::Exceptions::ConnectionTimeout
            stop_reactor
          end
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
ably-rest-1.1.5 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.5 spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.4 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.4 spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.4.rc lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.4.rc spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.3 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.3 spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.2 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.2 spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.2.rc1 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.1 spec/acceptance/realtime/time_spec.rb
ably-rest-1.1.0 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.1.0 spec/acceptance/realtime/time_spec.rb
ably-1.0.7 spec/acceptance/realtime/time_spec.rb
ably-rest-1.0.6 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.0.6 spec/acceptance/realtime/time_spec.rb
ably-rest-1.0.5 lib/submodules/ably-ruby/spec/acceptance/realtime/time_spec.rb
ably-1.0.5 spec/acceptance/realtime/time_spec.rb
ably-1.0.4 spec/acceptance/realtime/time_spec.rb