lib/submodules/ably-ruby/spec/acceptance/realtime/auth_spec.rb in ably-rest-0.8.3 vs lib/submodules/ably-ruby/spec/acceptance/realtime/auth_spec.rb in ably-rest-0.8.5
- old
+ new
@@ -6,11 +6,11 @@
#
describe Ably::Realtime::Auth, :event_machine do
vary_by_protocol do
let(:default_options) { { key: api_key, environment: environment, protocol: protocol } }
let(:client_options) { default_options }
- let(:client) { Ably::Realtime::Client.new(client_options) }
+ let(:client) { auto_close Ably::Realtime::Client.new(client_options) }
let(:auth) { client.auth }
context 'with basic auth' do
context '#authentication_security_requirements_met?' do
before do
@@ -99,22 +99,22 @@
context '#options (auth_options)' do
let(:auth_url) { "https://echo.ably.io/?type=text" }
let(:auth_params) { { :body => random_str } }
it 'contains the configured auth options' do
- auth.authorise(auth_url: auth_url, auth_params: auth_params) do
+ auth.authorise({}, auth_url: auth_url, auth_params: auth_params) do
expect(auth.options[:auth_url]).to eql(auth_url)
stop_reactor
end
end
end
context '#token_params' do
let(:custom_ttl) { 33 }
it 'contains the configured auth options' do
- auth.authorise({}, ttl: custom_ttl) do
+ auth.authorise(ttl: custom_ttl) do
expect(auth.token_params[:ttl]).to eql(custom_ttl)
stop_reactor
end
end
end
@@ -142,63 +142,63 @@
let(:custom_ttl) { 33 }
let(:custom_client_id) { random_str }
context '#create_token_request' do
it 'returns a token request asynchronously' do
- auth.create_token_request({}, { ttl: custom_ttl }) do |token_request|
+ auth.create_token_request(ttl: custom_ttl) do |token_request|
expect(token_request).to be_a(Ably::Models::TokenRequest)
expect(token_request.ttl).to eql(custom_ttl)
stop_reactor
end
end
end
context '#create_token_request_async' do
it 'returns a token request synchronously' do
- auth.create_token_request_sync(token_params: { ttl: custom_ttl }).tap do |token_request|
+ auth.create_token_request_sync(ttl: custom_ttl).tap do |token_request|
expect(token_request).to be_a(Ably::Models::TokenRequest)
expect(token_request.ttl).to eql(custom_ttl)
stop_reactor
end
end
end
context '#request_token' do
it 'returns a token asynchronously' do
- auth.request_token({ client_id: custom_client_id }, ttl: custom_ttl) do |token_details|
+ auth.request_token(client_id: custom_client_id, ttl: custom_ttl) do |token_details|
expect(token_details).to be_a(Ably::Models::TokenDetails)
expect(token_details.expires.to_i).to be_within(3).of(Time.now.to_i + custom_ttl)
expect(token_details.client_id).to eql(custom_client_id)
stop_reactor
end
end
end
context '#request_token_async' do
it 'returns a token synchronously' do
- auth.request_token_sync(client_id: custom_client_id, token_params: { ttl: custom_ttl }).tap do |token_details|
+ auth.request_token_sync(ttl: custom_ttl, client_id: custom_client_id).tap do |token_details|
expect(token_details).to be_a(Ably::Models::TokenDetails)
expect(token_details.expires.to_i).to be_within(3).of(Time.now.to_i + custom_ttl)
expect(token_details.client_id).to eql(custom_client_id)
stop_reactor
end
end
end
context '#authorise' do
it 'returns a token asynchronously' do
- auth.authorise({ client_id: custom_client_id }, ttl: custom_ttl) do |token_details|
+ auth.authorise(ttl: custom_ttl, client_id: custom_client_id) do |token_details|
expect(token_details).to be_a(Ably::Models::TokenDetails)
expect(token_details.expires.to_i).to be_within(3).of(Time.now.to_i + custom_ttl)
expect(token_details.client_id).to eql(custom_client_id)
stop_reactor
end
end
end
context '#authorise_async' do
it 'returns a token synchronously' do
- auth.authorise_sync(client_id: custom_client_id, token_params: { ttl: custom_ttl }).tap do |token_details|
+ auth.authorise_sync(ttl: custom_ttl, client_id: custom_client_id).tap do |token_details|
expect(auth.authorise_sync).to be_a(Ably::Models::TokenDetails)
expect(token_details.expires.to_i).to be_within(3).of(Time.now.to_i + custom_ttl)
expect(token_details.client_id).to eql(custom_client_id)
stop_reactor
end