Sha256: bb1690586b8b528ee5c4b0246cc8350db61f25c117b0e626a3b0a4656d876241
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' describe OAuthSession do let(:session) { Fabricate :oauth_session } let(:response) { double('response', code: 201, parsed_response: 'some_response') } describe '#initialize' do it 'sets the access_token instance variable' do session = Roqua::CoreApi.oauth_session access_token: 'some_access_token' expect(session.access_token).to eq('some_access_token') end it 'allows to override the core_host variable' do session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_host: 'some_core_host' expect(session.core_host).to eq('some_core_host') end it 'defaults the AuthSession core_host CORE_HOST env variable default value' do orginal_env_core_host = ENV['CORE_HOST'] ENV['CORE_HOST'] = 'some_env_core_host' session = Roqua::CoreApi.oauth_session access_token: 'some_access_token' ENV['CORE_HOST'] = orginal_env_core_host expect(session.core_host).to eq('some_env_core_host') end end describe '#logout_url' do it 'returns the oauth session destroy url with an escaped redirect_to parameter' do expect(session.logout_url redirect_to: 'some redirect to') .to eq('http://core.dev/session/destroy?token=some_access_token&redirect_to=some+redirect+to') end end describe 'headers' do it 'sets the Authorization header' do expect(HTTParty).to receive(:get).with(an_instance_of(String), headers: {"Authorization" => "Bearer some_access_token"}, query: {}, basic_auth: nil, timeout: 5).and_return(response) session.get 'some_path' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roqua-core-api-0.0.13 | spec/lib/roqua/core_api/sessions/oauth_session_spec.rb |