Sha256: 0b8ac683fdb3f72b982e7d67f6ea8049c7b3f1b04aaeef4d1d4cc80e43c5b7b3
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true describe BrowseEverything::Auth::Google::Credentials do subject(:credentials) { described_class.new } describe '#fetch_access_token' do let(:response) { double } before do WebMock.disable! allow(response).to receive(:status_code).and_return('200') allow(response).to receive(:body).and_return('{}') allow(response).to receive(:header).and_return(content_type: 'application/json') connection = instance_double(Faraday::Connection) allow(connection).to receive(:post).and_return(response) faraday = class_double('Faraday').as_stubbed_const(transfer_nested_constants: true) allow(faraday).to receive(:default_connection).and_return(connection) end context 'when an access has already been retrieved' do before do credentials.access_token = 'test-token' end it 'generates a Hash if an access token has already been set' do expect(credentials.fetch_access_token).to be_a Hash expect(credentials.fetch_access_token).to include('access_token' => 'test-token') end end it 'requests a new token from the OAuth provider' do expect(credentials.fetch_access_token).to be_a Hash expect(credentials.fetch_access_token).to eq({ "granted_scopes" => nil }) end after do WebMock.enable! end end end
Version data entries
3 entries across 3 versions & 1 rubygems