From 809d7151c676442a7dabfd2ea4918af902f7973a Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 15 Dec 2023 14:47:15 +0800 Subject: [PATCH] remove auto-generated ruby tests (#17402) --- .../codegen/languages/RubyClientCodegen.java | 4 - .../ruby-client/api_client_spec.mustache | 257 ------------------ .../ruby-client/configuration_spec.mustache | 111 -------- .../ruby-autoload/.openapi-generator/FILES | 2 - .../ruby-faraday/.openapi-generator/FILES | 2 - .../ruby-httpx/.openapi-generator/FILES | 2 - .../petstore/ruby/.openapi-generator/FILES | 2 - .../ruby-client/.openapi-generator/FILES | 2 - .../ruby/.openapi-generator/FILES | 2 - .../ruby-client/.openapi-generator/FILES | 2 - 10 files changed, 386 deletions(-) delete mode 100644 modules/openapi-generator/src/main/resources/ruby-client/api_client_spec.mustache delete mode 100644 modules/openapi-generator/src/main/resources/ruby-client/configuration_spec.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java index 0973688599a..96ac09a3ad1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java @@ -301,10 +301,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen { .doNotOverwrite()); supportingFiles.add(new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb") .doNotOverwrite()); - supportingFiles.add(new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb") - .doNotOverwrite()); - supportingFiles.add(new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb") - .doNotOverwrite()); // add lambda to convert a symbol to a string if an underscore is included (e.g. :'user_uuid' => 'user_uuid') additionalProperties.put("lambdaFixHeaderKey", new Mustache.Lambda() { diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_client_spec.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_client_spec.mustache deleted file mode 100644 index 324034c5f46..00000000000 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_client_spec.mustache +++ /dev/null @@ -1,257 +0,0 @@ -=begin -{{> api_info}} -=end - -require 'spec_helper' - -describe {{moduleName}}::ApiClient do - context 'initialization' do - context 'URL stuff' do - context 'host' do - it 'removes http from host' do - {{moduleName}}.configure { |c| c.host = 'http://example.com' } - expect({{moduleName}}::Configuration.default.host).to eq('example.com') - end - - it 'removes https from host' do - {{moduleName}}.configure { |c| c.host = 'https://wookiee.com' } - expect({{moduleName}}::ApiClient.default.config.host).to eq('wookiee.com') - end - - it 'removes trailing path from host' do - {{moduleName}}.configure { |c| c.host = 'hobo.com/v4' } - expect({{moduleName}}::Configuration.default.host).to eq('hobo.com') - end - end - - context 'base_path' do - it "prepends a slash to base_path" do - {{moduleName}}.configure { |c| c.base_path = 'v4/dog' } - expect({{moduleName}}::Configuration.default.base_path).to eq('/v4/dog') - end - - it "doesn't prepend a slash if one is already there" do - {{moduleName}}.configure { |c| c.base_path = '/v4/dog' } - expect({{moduleName}}::Configuration.default.base_path).to eq('/v4/dog') - end - - it "ends up as a blank string if nil" do - {{moduleName}}.configure { |c| c.base_path = nil } - expect({{moduleName}}::Configuration.default.base_path).to eq('') - end - end - end - end - -{{#isTyphoeus}} - describe 'params_encoding in #build_request' do - let(:config) { {{moduleName}}::Configuration.new } - let(:api_client) { {{moduleName}}::ApiClient.new(config) } - - it 'defaults to nil' do - expect({{moduleName}}::Configuration.default.params_encoding).to eq(nil) - expect(config.params_encoding).to eq(nil) - - request = api_client.build_request(:get, '/test') - expect(request.options[:params_encoding]).to eq(nil) - end - - it 'can be customized' do - config.params_encoding = :multi - request = api_client.build_request(:get, '/test') - expect(request.options[:params_encoding]).to eq(:multi) - end - end - - describe 'timeout in #build_request' do - let(:config) { {{moduleName}}::Configuration.new } - let(:api_client) { {{moduleName}}::ApiClient.new(config) } - - it 'defaults to 0' do - expect({{moduleName}}::Configuration.default.timeout).to eq(0) - expect(config.timeout).to eq(0) - - request = api_client.build_request(:get, '/test') - expect(request.options[:timeout]).to eq(0) - end - - it 'can be customized' do - config.timeout = 100 - request = api_client.build_request(:get, '/test') - expect(request.options[:timeout]).to eq(100) - end - end - -{{/isTyphoeus}} - -{{#isFaraday}} - describe 'proxy in #build_connection' do - let(:config) { {{moduleName}}::Configuration.new } - let(:api_client) { {{moduleName}}::ApiClient.new(config) } - let(:proxy_uri) { URI('http://example.org:8080') } - - it 'defaults to nil' do - expect({{moduleName}}::Configuration.default.proxy).to be_nil - expect(config.proxy).to be_nil - - connection = api_client.build_connection - expect(connection.proxy_for_request('/test')).to be_nil - end - - it 'can be customized with a string' do - config.proxy = proxy_uri.to_s - - connection = api_client.build_connection - configured_proxy = connection.proxy_for_request('/test') - - expect(configured_proxy).not_to be_nil - expect(configured_proxy.uri.to_s).to eq proxy_uri.to_s - end - - it 'can be customized with a hash' do - config.proxy = { uri: proxy_uri } - - connection = api_client.build_connection - configured_proxy = connection.proxy_for_request('/test') - - expect(configured_proxy).not_to be_nil - expect(configured_proxy.uri).to eq proxy_uri - end - end -{{/isFaraday}} - - describe '#deserialize' do - it "handles Array" do - api_client = {{moduleName}}::ApiClient.new - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: '[12, 34]') - data = api_client.deserialize(response, 'Array') - expect(data).to be_instance_of(Array) - expect(data).to eq([12, 34]) - end - - it 'handles Array>' do - api_client = {{moduleName}}::ApiClient.new - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: '[[12, 34], [56]]') - data = api_client.deserialize(response, 'Array>') - expect(data).to be_instance_of(Array) - expect(data).to eq([[12, 34], [56]]) - end - - it 'handles Hash' do - api_client = {{moduleName}}::ApiClient.new - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: '{"message": "Hello"}') - data = api_client.deserialize(response, 'Hash') - expect(data).to be_instance_of(Hash) - expect(data).to eq(:message => 'Hello') - end - end - - describe "#object_to_hash" do - it 'ignores nils and includes empty arrays' do - # uncomment below to test object_to_hash for model - # api_client = {{moduleName}}::ApiClient.new - # _model = {{moduleName}}::ModelName.new - # update the model attribute below - # _model.id = 1 - # update the expected value (hash) below - # expected = {id: 1, name: '', tags: []} - # expect(api_client.object_to_hash(_model)).to eq(expected) - end - end - - describe '#build_collection_param' do - let(:param) { ['aa', 'bb', 'cc'] } - let(:api_client) { {{moduleName}}::ApiClient.new } - - it 'works for csv' do - expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc') - end - - it 'works for ssv' do - expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc') - end - - it 'works for tsv' do - expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") - end - - it 'works for pipes' do - expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc') - end - - it 'works for multi' do - expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) - end - - it 'fails for invalid collection format' do - expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID') - end - end - - describe '#json_mime?' do - let(:api_client) { {{moduleName}}::ApiClient.new } - - it 'works' do - expect(api_client.json_mime?(nil)).to eq false - expect(api_client.json_mime?('')).to eq false - - expect(api_client.json_mime?('application/json')).to eq true - expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true - expect(api_client.json_mime?('APPLICATION/JSON')).to eq true - - expect(api_client.json_mime?('application/xml')).to eq false - expect(api_client.json_mime?('text/plain')).to eq false - expect(api_client.json_mime?('application/jsonp')).to eq false - end - end - - describe '#select_header_accept' do - let(:api_client) { {{moduleName}}::ApiClient.new } - - it 'works' do - expect(api_client.select_header_accept(nil)).to be_nil - expect(api_client.select_header_accept([])).to be_nil - - expect(api_client.select_header_accept(['application/json'])).to eq('application/json') - expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') - expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') - - expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml') - expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml') - end - end - - describe '#select_header_content_type' do - let(:api_client) { {{moduleName}}::ApiClient.new } - - it 'works' do - expect(api_client.select_header_content_type(nil)).to be_nil - expect(api_client.select_header_content_type([])).to be_nil - - expect(api_client.select_header_content_type(['application/json'])).to eq('application/json') - expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') - expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') - expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml') - expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain') - end - end - - describe '#sanitize_filename' do - let(:api_client) { {{moduleName}}::ApiClient.new } - - it 'works' do - expect(api_client.sanitize_filename('sun')).to eq('sun') - expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif') - expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif') - end - end -end diff --git a/modules/openapi-generator/src/main/resources/ruby-client/configuration_spec.mustache b/modules/openapi-generator/src/main/resources/ruby-client/configuration_spec.mustache deleted file mode 100644 index 69cd207b1a5..00000000000 --- a/modules/openapi-generator/src/main/resources/ruby-client/configuration_spec.mustache +++ /dev/null @@ -1,111 +0,0 @@ -=begin -{{> api_info}} -=end - -require 'spec_helper' - -describe {{moduleName}}::Configuration do - let(:config) { {{moduleName}}::Configuration.default } - - before(:each) do - # uncomment below to setup host and base_path - # require 'URI' - # uri = URI.parse("{{{basePath}}}") - # {{moduleName}}.configure do |c| - # c.host = uri.host - # c.base_path = uri.path - # end - end - - describe '#base_url' do - it 'should have the default value' do - # uncomment below to test default value of the base path - # expect(config.base_url).to eq("{{{basePath}}}") - end - - it 'should remove trailing slashes' do - [nil, '', '/', '//'].each do |base_path| - config.base_path = base_path - # uncomment below to test trailing slashes - # expect(config.base_url).to eq("{{{basePath}}}") - end - end - end -{{#isFaraday}} - - describe '#configure_faraday_connection' do - let(:faraday_connection) { Faraday::Connection.new } - - before do - stub_const('CustomAdapter', Class.new(Faraday::Adapter)) - stub_const('AnotherCustomAdapter', Class.new(Faraday::Adapter)) - - config.configure_faraday_connection do |conn| - conn.adapter CustomAdapter - conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger| - logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]') - end - end - end - - it 'adds a block that will be used to configure the connection' do - expect(faraday_connection.adapter).to eq(Faraday::Adapter::NetHttp) - expect(faraday_connection.builder.handlers).to_not include(Faraday::Response::Logger) - - config.configure_connection(faraday_connection) - - expect(faraday_connection.adapter).to eq(CustomAdapter) - expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger) - end - - it 'supports multiple configuration blocks' do - config.configure_faraday_connection do |conn| - conn.adapter AnotherCustomAdapter - end - - expect(faraday_connection.adapter).to eq(Faraday::Adapter::NetHttp) - expect(faraday_connection.builder.handlers).to_not include(Faraday::Response::Logger) - - config.configure_connection(faraday_connection) - - expect(faraday_connection.adapter).to eq(AnotherCustomAdapter) - expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger) - end - end -{{/isFaraday}} -{{#isHttpx}} - - describe '#configure' do - let(:session) { HTTPX::Session.new } - - before do - module CustomPlugin - module InstanceMethods; end - end - module AnotherCustomPlugin - module InstanceMethods; end - end - - config.configure_session do |session| - session.plugin(CustomPlugin) - end - end - - it 'adds a block that will be used to configure the connection' do - sess = config.configure(session) - - expect(sess.class.ancestors).to include(CustomPlugin::InstanceMethods) - end - - it 'supports multiple configuration blocks' do - config.configure_session do |session| - session.plugin(AnotherCustomPlugin) - end - sess = config.configure(session) - - expect(sess.class.ancestors).to include(CustomPlugin::InstanceMethods) - expect(sess.class.ancestors).to include(AnotherCustomPlugin::InstanceMethods) - end - end -{{/isHttpx}} -end diff --git a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES index fc02f30778d..7dbd2fdcd84 100644 --- a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES @@ -127,6 +127,4 @@ lib/petstore/models/test_inline_freeform_additional_properties_request.rb lib/petstore/models/user.rb lib/petstore/version.rb petstore.gemspec -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES index fc02f30778d..7dbd2fdcd84 100644 --- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES @@ -127,6 +127,4 @@ lib/petstore/models/test_inline_freeform_additional_properties_request.rb lib/petstore/models/user.rb lib/petstore/version.rb petstore.gemspec -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby-httpx/.openapi-generator/FILES b/samples/client/petstore/ruby-httpx/.openapi-generator/FILES index aa241d0edb5..41f69482281 100644 --- a/samples/client/petstore/ruby-httpx/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-httpx/.openapi-generator/FILES @@ -135,6 +135,4 @@ lib/petstore/models/whale.rb lib/petstore/models/zebra.rb lib/petstore/version.rb petstore.gemspec -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby/.openapi-generator/FILES b/samples/client/petstore/ruby/.openapi-generator/FILES index aa241d0edb5..41f69482281 100644 --- a/samples/client/petstore/ruby/.openapi-generator/FILES +++ b/samples/client/petstore/ruby/.openapi-generator/FILES @@ -135,6 +135,4 @@ lib/petstore/models/whale.rb lib/petstore/models/zebra.rb lib/petstore/version.rb petstore.gemspec -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/FILES b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/FILES index dfc08bbc7fa..fa901794fe3 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/FILES +++ b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/FILES @@ -14,7 +14,5 @@ lib/x_auth_id_alias/api_client.rb lib/x_auth_id_alias/api_error.rb lib/x_auth_id_alias/configuration.rb lib/x_auth_id_alias/version.rb -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb x_auth_id_alias.gemspec diff --git a/samples/openapi3/client/features/dynamic-servers/ruby/.openapi-generator/FILES b/samples/openapi3/client/features/dynamic-servers/ruby/.openapi-generator/FILES index 33ffe73a2d5..5a684a79906 100644 --- a/samples/openapi3/client/features/dynamic-servers/ruby/.openapi-generator/FILES +++ b/samples/openapi3/client/features/dynamic-servers/ruby/.openapi-generator/FILES @@ -15,6 +15,4 @@ lib/dynamic_servers/api_client.rb lib/dynamic_servers/api_error.rb lib/dynamic_servers/configuration.rb lib/dynamic_servers/version.rb -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/.openapi-generator/FILES b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/.openapi-generator/FILES index 3d3b3e99e4b..34265527f49 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/.openapi-generator/FILES +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/.openapi-generator/FILES @@ -19,6 +19,4 @@ lib/petstore/models/array_alias.rb lib/petstore/models/map_alias.rb lib/petstore/version.rb petstore.gemspec -spec/api_client_spec.rb -spec/configuration_spec.rb spec/spec_helper.rb