lib/submodules/ably-ruby/spec/acceptance/realtime/client_spec.rb in ably-rest-0.8.3 vs lib/submodules/ably-ruby/spec/acceptance/realtime/client_spec.rb in ably-rest-0.8.5

- old
+ new

@@ -9,11 +9,11 @@ let(:client_options) { default_options } let(:connection) { subject.connection } let(:auth_params) { subject.auth.auth_params_sync } - subject { Ably::Realtime::Client.new(client_options) } + subject { auto_close Ably::Realtime::Client.new(client_options) } context 'initialization' do context 'basic auth' do it 'is enabled by default with a provided :key option' do connection.on(:connected) do @@ -29,12 +29,12 @@ let(:client_options) { default_options.merge(tls: false, log_level: :none) } it 'fails to connect because a private key cannot be sent over a non-secure connection' do connection.on(:connected) { raise 'Should not have connected' } - connection.on(:failed) do |error| - expect(error).to be_a(Ably::Exceptions::InsecureRequest) + connection.on(:failed) do |connection_state_change| + expect(connection_state_change.reason).to be_a(Ably::Exceptions::InsecureRequest) stop_reactor end end end end @@ -42,11 +42,12 @@ context 'token auth' do [true, false].each do |tls_enabled| context "with TLS #{tls_enabled ? 'enabled' : 'disabled'}" do let(:capability) { { :foo => ["publish"] } } - let(:token_details) { Ably::Realtime::Client.new(default_options).auth.request_token_sync(capability: capability) } + let(:token_client) { auto_close Ably::Realtime::Client.new(default_options) } + let(:token_details) { token_client.auth.request_token_sync(capability: capability) } let(:client_options) { default_options.merge(token: token_details.token) } context 'and a pre-generated Token provided with the :token option' do it 'connects using token auth' do connection.on(:connected) do @@ -91,10 +92,10 @@ context 'with a Proc for the :auth_callback option' do let(:client_id) { random_str } let(:auth) { subject.auth } subject do - Ably::Realtime::Client.new(client_options.merge(auth_callback: Proc.new do + auto_close Ably::Realtime::Client.new(client_options.merge(auth_callback: Proc.new do @block_called = true auth.create_token_request_sync(client_id: client_id) end)) end