2015-10-06 11:47:42 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe FranceConnectService do
|
|
|
|
|
|
|
|
describe '.retrieve_user_informations' do
|
|
|
|
let(:code) { 'plop' }
|
2015-10-06 12:00:54 +02:00
|
|
|
let(:mocky) { 'my mocky' }
|
|
|
|
let(:user_info) { 'user_informations' }
|
|
|
|
subject { described_class.retrieve_user_informations code }
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(FranceConnectClient).to receive(:access_token!).and_return(mocky)
|
|
|
|
allow(mocky).to receive(:userinfo!).and_return(user_info)
|
|
|
|
end
|
2015-10-06 11:47:42 +02:00
|
|
|
it 'set code for FranceConnectClient' do
|
|
|
|
expect_any_instance_of(FranceConnectClient).to receive(:initialize).with(code: code)
|
|
|
|
described_class.retrieve_user_informations code
|
|
|
|
end
|
2015-10-06 12:00:54 +02:00
|
|
|
|
|
|
|
it 'returns user informations' do
|
|
|
|
expect(subject).to eq(user_info)
|
|
|
|
end
|
2015-10-06 11:47:42 +02:00
|
|
|
end
|
|
|
|
end
|