spec/unit/realtime/client_spec.rb in ably-0.1.5 vs spec/unit/realtime/client_spec.rb in ably-0.1.6
- old
+ new
@@ -1,8 +1,38 @@
require 'spec_helper'
require "support/protocol_msgbus_helper"
describe Ably::Realtime::Client do
+ let(:client_options) { 'appid.keyuid:keysecret' }
subject do
- Ably::Realtime::Client.new('appid.keyuid:keysecret')
+ Ably::Realtime::Client.new(client_options)
+ end
+
+ context 'delegation to the Rest Client' do
+ let(:options) { { arbitrary: 'value' } }
+
+ it 'passes on the options to the initializer' do
+ rest_client = instance_double('Ably::Rest::Client', auth: instance_double('Ably::Auth'), options: {})
+ expect(Ably::Rest::Client).to receive(:new).with(client_options).and_return(rest_client)
+ subject
+ end
+
+ specify '#time' do
+ expect(subject.rest_client).to receive(:time)
+ subject.time
+ end
+
+ specify '#stats' do
+ expect(subject.rest_client).to receive(:stats).with(options)
+ subject.stats options
+ end
+
+ context 'for attribute' do
+ [:environment, :use_tls?, :logger, :log_level].each do |attribute|
+ specify "##{attribute}" do
+ expect(subject.rest_client).to receive(attribute)
+ subject.public_send attribute
+ end
+ end
+ end
end
end