Skip to content

Commit cfbf43f

Browse files
committed
Add spec for credentials section of auth hash
1 parent 475efe4 commit cfbf43f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spec/omniauth/strategies/google_oauth2_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@
347347
end
348348
end
349349

350+
describe '#credentials' do
351+
let(:client) { OAuth2::Client.new('abc', 'def') }
352+
let(:access_token) { OAuth2::AccessToken.from_hash(client, access_token: 'valid_access_token', expires_at: 123_456_789, refresh_token: 'valid_refresh_token') }
353+
before(:each) { allow(subject).to receive(:access_token).and_return(access_token) }
354+
355+
it 'should return access token and (optionally) refresh token' do
356+
expect(subject.credentials.to_h).to \
357+
match(hash_including(
358+
'token' => 'valid_access_token',
359+
'refresh_token' => 'valid_refresh_token',
360+
'expires_at' => 123_456_789,
361+
'expires' => true
362+
))
363+
end
364+
end
365+
350366
describe '#extra' do
351367
let(:client) do
352368
OAuth2::Client.new('abc', 'def') do |builder|

0 commit comments

Comments
 (0)