Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

Commit 14218c5

Browse files
author
Vasile Zaremba
committed
Add spec for all the raw user fields
1 parent f11a39e commit 14218c5

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

spec/omniauth/strategies/yoti_spec.rb

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,68 @@
5252
end
5353

5454
describe '#extra' do
55-
it 'has the correct photo' do
56-
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
57-
expect(subject.extra[:photo]).to eql(selfie)
55+
context 'when using a mock request' do
56+
it 'has the correct photo' do
57+
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
58+
expect(subject.extra[:photo]).to eql(selfie)
59+
end
60+
61+
it 'has the correct phone number' do
62+
expect(subject.extra[:mobile_number]).to eql('+447474747474')
63+
end
5864
end
5965

60-
it 'has the correct phone number' do
61-
expect(subject.extra[:mobile_number]).to eql('+447474747474')
66+
context 'when using a mock object' do
67+
before do
68+
allow(subject).to receive(:yoti_user_profile).and_return(raw_info_hash)
69+
end
70+
71+
it 'has the correct selfie' do
72+
expect(subject.extra[:photo]).to eql('photo.png')
73+
end
74+
75+
it 'has the correct given names' do
76+
expect(subject.extra[:given_names]).to eql('Given Names')
77+
end
78+
79+
it 'has the correct family name' do
80+
expect(subject.extra[:family_name]).to eql('Family Name')
81+
end
82+
83+
it 'has the correct mobile number' do
84+
expect(subject.extra[:mobile_number]).to eql('07474747474')
85+
end
86+
87+
it 'has the correct date of birth' do
88+
expect(subject.extra[:date_of_birth]).to eql('2000.12.12')
89+
end
90+
91+
it 'has the correct address' do
92+
expect(subject.extra[:address]).to eql('WC2N 4JH')
93+
end
94+
95+
it 'has the correct gender' do
96+
expect(subject.extra[:gender]).to eql('male')
97+
end
98+
99+
it 'has the correct nationality' do
100+
expect(subject.extra[:nationality]).to eql('British')
101+
end
62102
end
63103
end
104+
105+
private
106+
107+
def raw_info_hash
108+
{
109+
'selfie' => 'photo.png',
110+
'given_names' => 'Given Names',
111+
'family_name' => 'Family Name',
112+
'phone_number' => '07474747474',
113+
'date_of_birth' => '2000.12.12',
114+
'post_code' => 'WC2N 4JH',
115+
'gender' => 'male',
116+
'nationality' => 'British'
117+
}
118+
end
64119
end

0 commit comments

Comments
 (0)