21700: Install Bundler system-wide in Rails postinst
[arvados.git] / sdk / ruby-google-api-client / spec / google / api_client / client_secrets_spec.rb
1 # encoding:utf-8
2
3 # Copyright 2013 Google Inc.
4 #
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
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 require 'spec_helper'
18
19 require 'google/api_client/client_secrets'
20
21 FIXTURES_PATH = File.expand_path('../../../fixtures', __FILE__)
22
23 RSpec.describe Google::APIClient::ClientSecrets do
24   
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)}
28   
29     it 'should load the correct client ID' do
30       expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
31     end
32
33     it 'should load the correct client secret' do
34       expect(secrets.client_secret).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
35     end
36     
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"
41       end
42
43       it 'should contain the client ID' do
44         expect(hash["installed"]["client_id"]).to be == '898243283568.apps.googleusercontent.com'
45       end
46
47       it 'should contain the client secret' do
48         expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
49       end
50
51     end
52   end
53 end