3 require 'google/api_client'
4 require 'google/api_client/version'
6 describe Google::APIClient::FileStore do
7 let(:root_path) { File.expand_path(File.join(__FILE__, '..','..','..', '..','..')) }
8 let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
10 let(:credentials_hash) {{
11 "access_token"=>"my_access_token",
12 "authorization_uri"=>"https://accounts.google.com/o/oauth2/auth",
13 "client_id"=>"123456_test_client_id@.apps.googleusercontent.com",
14 "client_secret"=>"123456_client_secret",
16 "refresh_token"=>"my_refresh_token",
17 "token_credential_uri"=>"https://accounts.google.com/o/oauth2/token",
18 "issued_at"=>1384440275
21 subject{Google::APIClient::FileStore.new('a file path')}
23 it 'should have a path' do
24 expect(subject.path).to be == 'a file path'
25 subject.path = 'an other file path'
26 expect(subject.path).to be == 'an other file path'
29 it 'should load credentials' do
30 subject.path = json_file
31 credentials = subject.load_credentials
32 expect(credentials).to include('access_token', 'authorization_uri', 'refresh_token')
35 it 'should write credentials' do
36 io_stub = StringIO.new
37 expect(subject).to receive(:open).and_return(io_stub)
38 subject.write_credentials(credentials_hash)