changed google auth spec to verify use of environment variablse

This commit is contained in:
Mark Ryall
2012-11-17 12:00:42 +10:00
parent 7fbcc4f78b
commit 5890a5dd37
+16 -13
View File
@@ -2,19 +2,22 @@ require 'spec_helper'
describe Google::APIClient do
describe :build do
it 'builds google api client for localhost' do
client = Google::APIClient.build
client.authorization.redirect_uri.to_s.should == 'http://localhost:3000/home/verify_g_callback'
end
let(:authorization) { stub 'authorization' }
let(:client) { stub 'client', authorization: authorization }
before { Google::APIClient.should_receive(:new).and_return client }
#it 'builds google api client for staging' do
# client = Google::APIClient.build
# client.authorization.redirect_uri.to_s.should == 'http://ocelots-staging.herokuapp.com/home/verify_g_callback'
#end
#
#it 'builds google api client for production' do
# client = Google::APIClient.build
# client.authorization.redirect_uri.to_s.should == 'http://iocelots.com/home/verify_g_callback'
#end
it "builds google api client using environment variables" do
[
['client_id', 'GOOGLE_OAUTH_CLIENT_ID', 'client_id'],
['client_secret', 'GOOGLE_OAUTH_CLIENT_SECRET', 'client_secret'],
['redirect_uri', 'GOOGLE_OAUTH_REDIRECT', 'http://domain/redirect']
].each do |values|
m, variable, value = *values
ENV.should_receive(:[]).with(variable).and_return value
authorization.should_receive("#{m}=").with value
end
authorization.should_receive("scope=").with 'https://www.googleapis.com/auth/userinfo.email'
Google::APIClient.build
end
end
end