omniauth-ely/spec/omniauth/strategies/ely_spec.rb

51 lines
1.5 KiB
Ruby
Raw Normal View History

2016-11-24 16:45:11 +05:30
require 'spec_helper'
describe OmniAuth::Strategies::Ely do
2017-11-03 18:15:01 +05:30
let(:access_token) { double('AccessToken', :options => {}) }
let(:parsed_response) { double('ParsedResponse') }
let(:response) { double('Response', :parsed => parsed_response) }
2016-11-24 16:45:11 +05:30
subject do
OmniAuth::Strategies::Ely.new({})
end
before(:each) do
2017-11-03 18:15:01 +05:30
allow(subject).to receive(:access_token).and_return(access_token)
2016-11-24 16:45:11 +05:30
end
context 'client options' do
it 'should have correct site' do
2017-11-03 18:15:01 +05:30
expect(subject.options.client_options.site).to eq('https://account.ely.by')
2016-11-24 16:45:11 +05:30
end
it 'should have correct authorize url' do
2017-11-03 18:15:01 +05:30
expect(subject.options.client_options.authorize_url).to eq('https://account.ely.by/oauth2/v1/')
2016-11-24 16:45:11 +05:30
end
it 'should have correct token url' do
2017-11-03 18:15:01 +05:30
expect(subject.options.client_options.token_url).to eq('https://account.ely.by/api/oauth2/v1/token')
2016-11-24 16:45:11 +05:30
end
end
context '#raw_info' do
it 'should use relative paths' do
2017-11-03 18:15:01 +05:30
expect(access_token).to receive(:get).and_return(response)
expect(subject.raw_info).to eq(parsed_response)
2016-11-24 16:45:11 +05:30
end
it 'should build valid profile link' do
raw_info = Hash.new
raw_info['id'] = 1
2017-11-03 18:15:01 +05:30
allow(subject).to receive(:raw_info).and_return(raw_info)
expect(subject.profile_url).to eq('http://ely.by/u1')
2016-11-24 16:45:11 +05:30
end
it 'should build valid skin link' do
raw_info = Hash.new
raw_info['username'] = 'Steve'
2017-11-03 18:15:01 +05:30
allow(subject).to receive(:raw_info).and_return(raw_info)
expect(subject.skin_url).to eq('http://skinsystem.ely.by/skins/Steve.png')
2016-11-24 16:45:11 +05:30
end
end
end