3 # Copyright 2013 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 require 'google/api_client/client_secrets'
21 FIXTURES_PATH = File.expand_path('../../../fixtures', __FILE__)
23 RSpec.describe Google::APIClient::ClientSecrets do
25 context 'with JSON file' do
26 let(:file) { File.join(FIXTURES_PATH, 'files', 'client_secrets.json') }
27 subject(:secrets) { Google::APIClient::ClientSecrets.load(file)}
29 it 'should load the correct client ID' do
30 expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
33 it 'should load the correct client secret' do
34 expect(secrets.client_secret).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
37 context 'serialzed to hash' do
38 subject(:hash) { secrets.to_hash }
39 it 'should contain the flow as the first key' do
40 expect(hash).to have_key "installed"
43 it 'should contain the client ID' do
44 expect(hash["installed"]["client_id"]).to be == '898243283568.apps.googleusercontent.com'
47 it 'should contain the client secret' do
48 expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'