Skip to content

Commit

Permalink
Add spec for credentials section of auth hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Feb 28, 2022
1 parent 475efe4 commit cfbf43f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/omniauth/strategies/google_oauth2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,22 @@
end
end

describe '#credentials' do
let(:client) { OAuth2::Client.new('abc', 'def') }
let(:access_token) { OAuth2::AccessToken.from_hash(client, access_token: 'valid_access_token', expires_at: 123_456_789, refresh_token: 'valid_refresh_token') }
before(:each) { allow(subject).to receive(:access_token).and_return(access_token) }

it 'should return access token and (optionally) refresh token' do
expect(subject.credentials.to_h).to \
match(hash_including(
'token' => 'valid_access_token',
'refresh_token' => 'valid_refresh_token',
'expires_at' => 123_456_789,
'expires' => true
))
end
end

describe '#extra' do
let(:client) do
OAuth2::Client.new('abc', 'def') do |builder|
Expand Down

0 comments on commit cfbf43f

Please sign in to comment.