require 'compat/multi_json'
require 'signet/oauth_1/client'
require 'google/api_client'
-require 'google/api_client/version'
-describe Google::APIClient do
+fixtures_path = File.expand_path('../../../fixtures', __FILE__)
+
+RSpec.describe Google::APIClient do
include ConnectionHelpers
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)
expect(CLIENT.preferred_version('bogus')).to eq(nil)
end
+ describe 'with zoo API' do
+ it 'should return API instance registered from file' do
+ zoo_json = File.join(fixtures_path, 'files', 'zoo.json')
+ contents = File.open(zoo_json, 'rb') { |io| io.read }
+ api = CLIENT.register_discovery_document('zoo', 'v1', contents)
+ expect(api).to be_kind_of(Google::APIClient::API)
+ end
+ end
+
describe 'with the prediction API' do
before do
CLIENT.authorization = nil
).to_env(CLIENT.connection)
end).to raise_error(ArgumentError)
end
+
+ it 'should correctly determine the service root_uri' do
+ expect(@plus.root_uri.to_s).to eq('https://www.googleapis.com/')
+ end
end
describe 'with the adsense API' do
expect(@drive.files.insert.media_upload.max_size).not_to eq(nil)
end
end
+
+ describe 'with the Pub/Sub API' do
+ before do
+ CLIENT.authorization = nil
+ @pubsub = CLIENT.discovered_api('pubsub', 'v1beta2')
+ end
+
+ it 'should generate requests against the correct URIs' do
+ conn = stub_connection do |stub|
+ stub.get('/v1beta2/projects/12345/topics') do |env|
+ expect(env[:url].host).to eq('pubsub.googleapis.com')
+ [200, {}, '{}']
+ end
+ end
+ request = CLIENT.execute(
+ :api_method => @pubsub.projects.topics.list,
+ :parameters => {'project' => 'projects/12345'},
+ :connection => conn
+ )
+ conn.verify
+ end
+
+ it 'should correctly determine the service root_uri' do
+ expect(@pubsub.root_uri.to_s).to eq('https://pubsub.googleapis.com/')
+ end
+ end
end