From dadb8e4275a511c39766bac6c18d44301b120356 Mon Sep 17 00:00:00 2001 From: Ruslan Korolev Date: Wed, 5 Dec 2018 22:01:03 +0200 Subject: [PATCH] add test for invalid credentials in file storage (#277) --- .../api_client/auth/storages/file_store_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/google/api_client/auth/storages/file_store_spec.rb b/spec/google/api_client/auth/storages/file_store_spec.rb index e1f72916f..657feb0b7 100644 --- a/spec/google/api_client/auth/storages/file_store_spec.rb +++ b/spec/google/api_client/auth/storages/file_store_spec.rb @@ -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