Update generator to use batchPath instead of hardcoded path

This commit is contained in:
Steven Bazyl 2017-03-06 12:24:30 -08:00
parent cf38f15a08
commit 687223feb4
3 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,7 @@ module Google
<% end -%>
def initialize
super('<%= api.root_url %>', '<%= api.service_path %>')
@batch_path = '<%= api.batch_path %>'
end
<% for api_method in api.all_methods -%>
<%= indent(include('method', :api_method => api_method, :api => api), 8) -%>

View File

@ -7,6 +7,7 @@
"basePath": "/test/",
"rootUrl": "https://www.googleapis.com/",
"servicePath": "test/v1/",
"batchPath": "batch/test/v1",
"rpcPath": "/rpc",
"auth": {
"oauth2": {

View File

@ -30,6 +30,7 @@ RSpec.describe Google::Apis::Generator do
puts generator.dump_api_names
tempdir = Dir.mktmpdir
generated_files.each do |key, content|
puts content
path = File.join(tempdir, key)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
@ -47,6 +48,10 @@ RSpec.describe Google::Apis::Generator do
expect(service.root_url.to_s).to eql('https://www.googleapis.com/')
end
it 'should set the batch path' do
expect(service.batch_path).to eql('batch/test/v1')
end
it 'should define global methods from discovery' do
expect(service.method(:query)).to_not be_nil
end