From 687223feb4fb5c54a43ade6498f6d8228910cf5d Mon Sep 17 00:00:00 2001 From: Steven Bazyl Date: Mon, 6 Mar 2017 12:24:30 -0800 Subject: [PATCH] Update generator to use batchPath instead of hardcoded path --- lib/google/apis/generator/templates/service.rb.tmpl | 1 + spec/fixtures/files/test_api.json | 1 + spec/google/apis/generator/generator_spec.rb | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/lib/google/apis/generator/templates/service.rb.tmpl b/lib/google/apis/generator/templates/service.rb.tmpl index 7bf7315ee..6eb622ba7 100644 --- a/lib/google/apis/generator/templates/service.rb.tmpl +++ b/lib/google/apis/generator/templates/service.rb.tmpl @@ -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) -%> diff --git a/spec/fixtures/files/test_api.json b/spec/fixtures/files/test_api.json index 3447ac5be..29a46871a 100644 --- a/spec/fixtures/files/test_api.json +++ b/spec/fixtures/files/test_api.json @@ -7,6 +7,7 @@ "basePath": "/test/", "rootUrl": "https://www.googleapis.com/", "servicePath": "test/v1/", + "batchPath": "batch/test/v1", "rpcPath": "/rpc", "auth": { "oauth2": { diff --git a/spec/google/apis/generator/generator_spec.rb b/spec/google/apis/generator/generator_spec.rb index 07dd53283..ce0fde179 100644 --- a/spec/google/apis/generator/generator_spec.rb +++ b/spec/google/apis/generator/generator_spec.rb @@ -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