spec/acceptance/realtime/client_spec.rb in ably-0.8.4 vs spec/acceptance/realtime/client_spec.rb in ably-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 @@ -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