mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
Merge pull request #1980 from wing328/ruby_add_test
[Ruby] add auto-generated test cases (rspec)
This commit is contained in:
commit
bfd17e45fe
@ -29,6 +29,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
protected String gemName;
|
protected String gemName;
|
||||||
protected String moduleName;
|
protected String moduleName;
|
||||||
protected String gemVersion = "1.0.0";
|
protected String gemVersion = "1.0.0";
|
||||||
|
protected String specFolder = "spec";
|
||||||
protected String libFolder = "lib";
|
protected String libFolder = "lib";
|
||||||
protected String gemLicense = "Apache-2.0";
|
protected String gemLicense = "Apache-2.0";
|
||||||
protected String gemHomepage = "http://swagger.io";
|
protected String gemHomepage = "http://swagger.io";
|
||||||
@ -47,6 +48,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
apiTemplateFiles.put("api.mustache", ".rb");
|
apiTemplateFiles.put("api.mustache", ".rb");
|
||||||
embeddedTemplateDir = templateDir = "ruby";
|
embeddedTemplateDir = templateDir = "ruby";
|
||||||
|
|
||||||
|
modelTestTemplateFiles.put("model_test.mustache", ".rb");
|
||||||
|
apiTestTemplateFiles.put("api_test.mustache", ".rb");
|
||||||
|
|
||||||
typeMapping.clear();
|
typeMapping.clear();
|
||||||
languageSpecificPrimitives.clear();
|
languageSpecificPrimitives.clear();
|
||||||
|
|
||||||
@ -235,6 +239,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return outputFolder + File.separator + libFolder + File.separator + gemName + File.separator + modelPackage.replace("/", File.separator);
|
return outputFolder + File.separator + libFolder + File.separator + gemName + File.separator + modelPackage.replace("/", File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiTestFileFolder() {
|
||||||
|
return outputFolder + File.separator + specFolder + File.separator + apiPackage.replace("/", File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelTestFileFolder() {
|
||||||
|
return outputFolder + File.separator + specFolder + File.separator + modelPackage.replace("/", File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Property p) {
|
public String getTypeDeclaration(Property p) {
|
||||||
if (p instanceof ArrayProperty) {
|
if (p instanceof ArrayProperty) {
|
||||||
@ -367,6 +381,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return underscore(name) + "_api";
|
return underscore(name) + "_api";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiTestFilename(String name) {
|
||||||
|
return toApiName(name) + "_spec";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelTestFilename(String name) {
|
||||||
|
return toModelName(name) + "_spec";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiName(String name) {
|
public String toApiName(String name) {
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
# Unit tests for {{moduleName}}::{{classname}}
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
{{#operations}}describe '{{classname}}' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = {{moduleName}}::{{classname}}.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of {{classname}}' do
|
||||||
|
it 'should create an instact of {{classname}}' do
|
||||||
|
@instance.should be_a({{moduleName}}::{{classname}})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{{#operation}}
|
||||||
|
# unit tests for {{operationId}}
|
||||||
|
# {{summary}}
|
||||||
|
# {{notes}}
|
||||||
|
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
||||||
|
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
||||||
|
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
||||||
|
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
||||||
|
describe '{{operationId}} test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
end
|
||||||
|
{{/operations}}
|
@ -0,0 +1,36 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for {{moduleName}}::{{classname}}
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
{{#models}}{{#model}}describe '{{classname}}' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = {{moduleName}}::{{classname}}.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of {{classname}}' do
|
||||||
|
it 'should create an instact of {{classname}}' do
|
||||||
|
@instance.should be_a({{moduleName}}::{{classname}})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{{#vars}}
|
||||||
|
describe 'test attribute "{{{name}}}"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
end
|
||||||
|
{{/model}}{{/models}}
|
@ -495,6 +495,124 @@ module Petstore
|
|||||||
end
|
end
|
||||||
return data, status_code, headers
|
return data, status_code, headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [binary]
|
||||||
|
def get_pet_by_id_with_byte_array(pet_id, opts = {})
|
||||||
|
data, status_code, headers = get_pet_by_id_with_byte_array_with_http_info(pet_id, opts)
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [Array<(binary, Fixnum, Hash)>] binary data, response status code and response headers
|
||||||
|
def get_pet_by_id_with_byte_array_with_http_info(pet_id, opts = {})
|
||||||
|
if @api_client.config.debugging
|
||||||
|
@api_client.config.logger.debug "Calling API: PetApi#get_pet_by_id_with_byte_array ..."
|
||||||
|
end
|
||||||
|
|
||||||
|
# verify the required parameter 'pet_id' is set
|
||||||
|
fail "Missing the required parameter 'pet_id' when calling get_pet_by_id_with_byte_array" if pet_id.nil?
|
||||||
|
|
||||||
|
# resource path
|
||||||
|
path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
|
# header parameters
|
||||||
|
header_params = {}
|
||||||
|
|
||||||
|
# HTTP header 'Accept' (if needed)
|
||||||
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
# http body (model)
|
||||||
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
|
auth_names = ['api_key']
|
||||||
|
data, status_code, headers = @api_client.call_api(:GET, path,
|
||||||
|
:header_params => header_params,
|
||||||
|
:query_params => query_params,
|
||||||
|
:form_params => form_params,
|
||||||
|
:body => post_body,
|
||||||
|
:auth_names => auth_names,
|
||||||
|
:return_type => 'binary')
|
||||||
|
if @api_client.config.debugging
|
||||||
|
@api_client.config.logger.debug "API called: PetApi#get_pet_by_id_with_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||||
|
end
|
||||||
|
return data, status_code, headers
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [binary] :body Pet object in the form of byte array
|
||||||
|
# @return [nil]
|
||||||
|
def add_pet_using_byte_array(opts = {})
|
||||||
|
add_pet_using_byte_array_with_http_info(opts)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [binary] :body Pet object in the form of byte array
|
||||||
|
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
||||||
|
def add_pet_using_byte_array_with_http_info(opts = {})
|
||||||
|
if @api_client.config.debugging
|
||||||
|
@api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..."
|
||||||
|
end
|
||||||
|
|
||||||
|
# resource path
|
||||||
|
path = "/pet?testing_byte_array=true".sub('{format}','json')
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
|
# header parameters
|
||||||
|
header_params = {}
|
||||||
|
|
||||||
|
# HTTP header 'Accept' (if needed)
|
||||||
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
|
_header_content_type = ['application/json', 'application/xml']
|
||||||
|
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
# http body (model)
|
||||||
|
post_body = @api_client.object_to_http_body(opts[:'body'])
|
||||||
|
|
||||||
|
|
||||||
|
auth_names = ['petstore_auth']
|
||||||
|
data, status_code, headers = @api_client.call_api(:POST, path,
|
||||||
|
:header_params => header_params,
|
||||||
|
:query_params => query_params,
|
||||||
|
:form_params => form_params,
|
||||||
|
:body => post_body,
|
||||||
|
:auth_names => auth_names)
|
||||||
|
if @api_client.config.debugging
|
||||||
|
@api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||||
|
end
|
||||||
|
return data, status_code, headers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
188
samples/client/petstore/ruby/spec/api/PetApi_spec.rb
Normal file
188
samples/client/petstore/ruby/spec/api/PetApi_spec.rb
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::PetApi
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'PetApi' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::PetApi.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of PetApi' do
|
||||||
|
it 'should create an instact of PetApi' do
|
||||||
|
@instance.should be_a(Petstore::PetApi)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for update_pet
|
||||||
|
# Update an existing pet
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
|
# @return [nil]
|
||||||
|
describe 'update_pet test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for add_pet
|
||||||
|
# Add a new pet to the store
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
|
# @return [nil]
|
||||||
|
describe 'add_pet test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for find_pets_by_status
|
||||||
|
# Finds Pets by status
|
||||||
|
# Multiple status values can be provided with comma seperated strings
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Array<String>] :status Status values that need to be considered for filter
|
||||||
|
# @return [Array<Pet>]
|
||||||
|
describe 'find_pets_by_status test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for find_pets_by_tags
|
||||||
|
# Finds Pets by tags
|
||||||
|
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Array<String>] :tags Tags to filter by
|
||||||
|
# @return [Array<Pet>]
|
||||||
|
describe 'find_pets_by_tags test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for get_pet_by_id
|
||||||
|
# Find pet by ID
|
||||||
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [Pet]
|
||||||
|
describe 'get_pet_by_id test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for update_pet_with_form
|
||||||
|
# Updates a pet in the store with form data
|
||||||
|
#
|
||||||
|
# @param pet_id ID of pet that needs to be updated
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [String] :name Updated name of the pet
|
||||||
|
# @option opts [String] :status Updated status of the pet
|
||||||
|
# @return [nil]
|
||||||
|
describe 'update_pet_with_form test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for delete_pet
|
||||||
|
# Deletes a pet
|
||||||
|
#
|
||||||
|
# @param pet_id Pet id to delete
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [String] :api_key
|
||||||
|
# @return [nil]
|
||||||
|
describe 'delete_pet test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for upload_file
|
||||||
|
# uploads an image
|
||||||
|
#
|
||||||
|
# @param pet_id ID of pet to update
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||||
|
# @option opts [File] :file file to upload
|
||||||
|
# @return [nil]
|
||||||
|
describe 'upload_file test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for get_pet_by_id_with_byte_array
|
||||||
|
# Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [binary]
|
||||||
|
describe 'get_pet_by_id_with_byte_array test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for add_pet_using_byte_array
|
||||||
|
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [binary] :body Pet object in the form of byte array
|
||||||
|
# @return [nil]
|
||||||
|
describe 'add_pet_using_byte_array test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
86
samples/client/petstore/ruby/spec/api/StoreApi_spec.rb
Normal file
86
samples/client/petstore/ruby/spec/api/StoreApi_spec.rb
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::StoreApi
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'StoreApi' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::StoreApi.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of StoreApi' do
|
||||||
|
it 'should create an instact of StoreApi' do
|
||||||
|
@instance.should be_a(Petstore::StoreApi)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for get_inventory
|
||||||
|
# Returns pet inventories by status
|
||||||
|
# Returns a map of status codes to quantities
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [Hash<String, Integer>]
|
||||||
|
describe 'get_inventory test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for place_order
|
||||||
|
# Place an order for a pet
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Order] :body order placed for purchasing the pet
|
||||||
|
# @return [Order]
|
||||||
|
describe 'place_order test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for get_order_by_id
|
||||||
|
# Find purchase order by ID
|
||||||
|
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
# @param order_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [Order]
|
||||||
|
describe 'get_order_by_id test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for delete_order
|
||||||
|
# Delete purchase order by ID
|
||||||
|
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
# @param order_id ID of the order that needs to be deleted
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [nil]
|
||||||
|
describe 'delete_order test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
152
samples/client/petstore/ruby/spec/api/UserApi_spec.rb
Normal file
152
samples/client/petstore/ruby/spec/api/UserApi_spec.rb
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::UserApi
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'UserApi' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::UserApi.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of UserApi' do
|
||||||
|
it 'should create an instact of UserApi' do
|
||||||
|
@instance.should be_a(Petstore::UserApi)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for create_user
|
||||||
|
# Create user
|
||||||
|
# This can only be done by the logged in user.
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [User] :body Created user object
|
||||||
|
# @return [nil]
|
||||||
|
describe 'create_user test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for create_users_with_array_input
|
||||||
|
# Creates list of users with given input array
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Array<User>] :body List of user object
|
||||||
|
# @return [nil]
|
||||||
|
describe 'create_users_with_array_input test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for create_users_with_list_input
|
||||||
|
# Creates list of users with given input array
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Array<User>] :body List of user object
|
||||||
|
# @return [nil]
|
||||||
|
describe 'create_users_with_list_input test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for login_user
|
||||||
|
# Logs user into the system
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [String] :username The user name for login
|
||||||
|
# @option opts [String] :password The password for login in clear text
|
||||||
|
# @return [String]
|
||||||
|
describe 'login_user test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for logout_user
|
||||||
|
# Logs out current logged in user session
|
||||||
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [nil]
|
||||||
|
describe 'logout_user test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for get_user_by_name
|
||||||
|
# Get user by user name
|
||||||
|
#
|
||||||
|
# @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [User]
|
||||||
|
describe 'get_user_by_name test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for update_user
|
||||||
|
# Updated user
|
||||||
|
# This can only be done by the logged in user.
|
||||||
|
# @param username name that need to be deleted
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [User] :body Updated user object
|
||||||
|
# @return [nil]
|
||||||
|
describe 'update_user test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# unit tests for delete_user
|
||||||
|
# Delete user
|
||||||
|
# This can only be done by the logged in user.
|
||||||
|
# @param username The name that needs to be deleted
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @return [nil]
|
||||||
|
describe 'delete_user test' do
|
||||||
|
it "should work" do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
44
samples/client/petstore/ruby/spec/models/Category_spec.rb
Normal file
44
samples/client/petstore/ruby/spec/models/Category_spec.rb
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'Category' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::Category.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of Category' do
|
||||||
|
it 'should create an instact of Category' do
|
||||||
|
@instance.should be_a(Petstore::Category)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'test attribute "id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
84
samples/client/petstore/ruby/spec/models/Order_spec.rb
Normal file
84
samples/client/petstore/ruby/spec/models/Order_spec.rb
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'Order' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::Order.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of Order' do
|
||||||
|
it 'should create an instact of Order' do
|
||||||
|
@instance.should be_a(Petstore::Order)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'test attribute "id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "pet_id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "quantity"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "ship_date"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "status"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "complete"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
84
samples/client/petstore/ruby/spec/models/Pet_spec.rb
Normal file
84
samples/client/petstore/ruby/spec/models/Pet_spec.rb
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'Pet' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::Pet.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of Pet' do
|
||||||
|
it 'should create an instact of Pet' do
|
||||||
|
@instance.should be_a(Petstore::Pet)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'test attribute "id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "category"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "photo_urls"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "tags"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "status"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
44
samples/client/petstore/ruby/spec/models/Tag_spec.rb
Normal file
44
samples/client/petstore/ruby/spec/models/Tag_spec.rb
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'Tag' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::Tag.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of Tag' do
|
||||||
|
it 'should create an instact of Tag' do
|
||||||
|
@instance.should be_a(Petstore::Tag)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'test attribute "id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
104
samples/client/petstore/ruby/spec/models/User_spec.rb
Normal file
104
samples/client/petstore/ruby/spec/models/User_spec.rb
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require 'date'
|
||||||
|
|
||||||
|
# Unit tests for Petstore::
|
||||||
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
describe 'User' do
|
||||||
|
before do
|
||||||
|
# run before each test
|
||||||
|
@instance = Petstore::User.new
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
# run after each test
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test an instance of User' do
|
||||||
|
it 'should create an instact of User' do
|
||||||
|
@instance.should be_a(Petstore::User)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'test attribute "id"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "username"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "first_name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "last_name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "email"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "password"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "phone"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "user_status"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user