add test for invalid credentials in file storage (#277)

This commit is contained in:
Ruslan Korolev 2018-12-05 22:01:03 +02:00 committed by Daniel Azuma
parent 3a1e54d959
commit dadb8e4275
1 changed files with 9 additions and 2 deletions

View File

@ -3,8 +3,7 @@ require 'spec_helper'
require 'google/api_client/auth/storages/file_store'
describe Google::APIClient::FileStore do
let(:root_path) { File.expand_path(File.join(__FILE__, '..','..','..', '..','..')) }
let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
let(:json_file) { File.join(FIXTURES_DIR, 'files', 'auth_stored_credentials.json') }
let(:credentials_hash) {{
"access_token"=>"my_access_token",
@ -38,4 +37,12 @@ describe Google::APIClient::FileStore do
expect(subject).to receive(:open).and_return(io_stub)
subject.write_credentials(credentials_hash)
end
it 'should not load credentials' do
file = StringIO.new
file.write "{invalid_hash}"
invalid_subject = Google::APIClient::FileStore.new(file)
expect(invalid_subject.load_credentials).to be_nil
end
end