Merge pull request #273 from rusikf/patch-5

add more detail specs for client_secrets.rb + fix docs
This commit is contained in:
Steve Bazyl 2015-08-19 12:20:56 -07:00
commit 669aaf01a4
5 changed files with 26 additions and 4 deletions

View File

@ -129,7 +129,7 @@ Media operations -- uploads & downloads -- can not be included in batch with oth
However, some APIs support batch uploads. To upload multiple files in a batch, use the `batch_upload` method instead. However, some APIs support batch uploads. To upload multiple files in a batch, use the `batch_upload` method instead.
Batch uploads should only be used when uploading multiple small files. For large files, upload files individually to Batch uploads should only be used when uploading multiple small files. For large files, upload files individually to
take advantage of the libraries built-in reusmable upload support. take advantage of the libraries built-in resumable upload support.
### Hashes ### Hashes

View File

@ -46,7 +46,6 @@ module Google
# } # }
# } # }
class ClientSecrets class ClientSecrets
## ##
# Reads client configuration from a file # Reads client configuration from a file
# #
@ -77,7 +76,7 @@ module Google
end end
## ##
# Intialize OAuth client settings. # Initialize OAuth client settings.
# #
# @param [Hash] options # @param [Hash] options
# Parsed client secrets files # Parsed client secrets files

0
spec/fixtures/files/child/.gitignore vendored Normal file
View File

1
spec/fixtures/files/invalid.json vendored Normal file
View File

@ -0,0 +1 @@
{"invalid"}

View File

@ -50,4 +50,26 @@ RSpec.describe Google::APIClient::ClientSecrets do
end end
end end
end
context 'with no existing JSON file' do
it 'should raise exception' do
file = File.join(FIXTURES_PATH, 'files', 'no_file.json')
expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(Errno::ENOENT)
end
end
context 'with invalid JSON file' do
it 'should raise exception' do
file = File.join(FIXTURES_PATH, 'files', 'invalid.json')
expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(MultiJson::ParseError)
end
end
context 'with folder name, which have json file in parents' do
it 'should load the correct client id' do
folder = File.join(FIXTURES_PATH, 'files', 'child')
secrets = Google::APIClient::ClientSecrets.load(folder)
expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
end
end
end