From 6c626ccc7aaa25c7f43ab626aff84dcbf77baea4 Mon Sep 17 00:00:00 2001 From: Newell Zhu Date: Tue, 17 May 2016 19:53:36 +0800 Subject: [PATCH 1/3] remove tailing spaces --- .../swagger-codegen/src/main/resources/ruby/api_doc.mustache | 2 +- .../src/main/resources/ruby/base_object.mustache | 2 +- .../src/main/resources/ruby/git_push.sh.mustache | 2 +- .../swagger-codegen/src/main/resources/ruby/model.mustache | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index a2cee7f9361..754e41db5a8 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -22,7 +22,7 @@ Method | HTTP request | Description # load the gem require '{{{gemName}}}' {{#hasAuthMethods}} -# setup authorization +# setup authorization {{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} # Configure HTTP basic authorization: {{{name}}} config.username = 'YOUR USERNAME' diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache index 87877d1763e..0c15a9929f3 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache @@ -86,7 +86,7 @@ # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache index e153ce23ecf..a9b0f28edfb 100755 --- a/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache @@ -28,7 +28,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 14f26898d2b..685b6006f97 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -216,7 +216,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} {{/isEnum}} {{/vars}} # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class{{#vars}} && @@ -224,7 +224,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end From 1c3f1b4bf84d3ce8dd11bde764765bbe558554b9 Mon Sep 17 00:00:00 2001 From: Newell Zhu Date: Tue, 17 May 2016 20:13:38 +0800 Subject: [PATCH 2/3] regenerate ruby sample after remove tailing --- samples/client/petstore/ruby/README.md | 14 +++++------ samples/client/petstore/ruby/docs/Animal.md | 1 + samples/client/petstore/ruby/docs/Cat.md | 1 + samples/client/petstore/ruby/docs/Dog.md | 1 + samples/client/petstore/ruby/docs/Name.md | 1 + samples/client/petstore/ruby/docs/PetApi.md | 16 ++++++------ samples/client/petstore/ruby/docs/StoreApi.md | 2 +- samples/client/petstore/ruby/git_push.sh | 2 +- .../ruby/lib/petstore/configuration.rb | 14 +++++------ .../ruby/lib/petstore/models/animal.rb | 25 +++++++++++++------ .../ruby/lib/petstore/models/animal_farm.rb | 6 ++--- .../ruby/lib/petstore/models/api_response.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/cat.rb | 19 +++++++++++--- .../ruby/lib/petstore/models/category.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/dog.rb | 19 +++++++++++--- .../ruby/lib/petstore/models/enum_class.rb | 6 ++--- .../ruby/lib/petstore/models/enum_test.rb | 6 ++--- .../ruby/lib/petstore/models/format_test.rb | 6 ++--- .../lib/petstore/models/model_200_response.rb | 6 ++--- .../ruby/lib/petstore/models/model_return.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/name.rb | 23 +++++++++++------ .../ruby/lib/petstore/models/order.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/pet.rb | 6 ++--- .../lib/petstore/models/special_model_name.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/tag.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/user.rb | 6 ++--- 26 files changed, 131 insertions(+), 85 deletions(-) diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index cdecd2e6cca..f8cac1383e7 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-10T14:47:49.265+08:00 +- Build date: 2016-05-17T19:54:07.493+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -138,12 +138,6 @@ Class | Method | HTTP request | Description ## Documentation for Authorization -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ### petstore_auth - **Type**: OAuth @@ -153,3 +147,9 @@ Class | Method | HTTP request | Description - write:pets: modify pets in your account - read:pets: read your pets +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + diff --git a/samples/client/petstore/ruby/docs/Animal.md b/samples/client/petstore/ruby/docs/Animal.md index 0e262c78726..5ff8837de15 100644 --- a/samples/client/petstore/ruby/docs/Animal.md +++ b/samples/client/petstore/ruby/docs/Animal.md @@ -4,5 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **String** | | +**color** | **String** | | [optional] [default to "red"] diff --git a/samples/client/petstore/ruby/docs/Cat.md b/samples/client/petstore/ruby/docs/Cat.md index 6b7dfb710df..5c13d986ece 100644 --- a/samples/client/petstore/ruby/docs/Cat.md +++ b/samples/client/petstore/ruby/docs/Cat.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **String** | | +**color** | **String** | | [optional] [default to "red"] **declawed** | **BOOLEAN** | | [optional] diff --git a/samples/client/petstore/ruby/docs/Dog.md b/samples/client/petstore/ruby/docs/Dog.md index 7af6f549d5d..9224ad05310 100644 --- a/samples/client/petstore/ruby/docs/Dog.md +++ b/samples/client/petstore/ruby/docs/Dog.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **String** | | +**color** | **String** | | [optional] [default to "red"] **breed** | **String** | | [optional] diff --git a/samples/client/petstore/ruby/docs/Name.md b/samples/client/petstore/ruby/docs/Name.md index 4858862c725..1ae49f8ee1b 100644 --- a/samples/client/petstore/ruby/docs/Name.md +++ b/samples/client/petstore/ruby/docs/Name.md @@ -6,5 +6,6 @@ Name | Type | Description | Notes **name** | **Integer** | | **snake_case** | **Integer** | | [optional] **property** | **String** | | [optional] +**_123_number** | **Integer** | | [optional] diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index d5a498c6ff0..1acc4382aa3 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -25,7 +25,7 @@ Add a new pet to the store ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -76,7 +76,7 @@ Deletes a pet ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -131,7 +131,7 @@ Multiple status values can be provided with comma separated strings ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -183,7 +183,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -235,7 +235,7 @@ Returns a single pet ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure API key authorization: api_key config.api_key['api_key'] = 'YOUR API KEY' @@ -289,7 +289,7 @@ Update an existing pet ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -340,7 +340,7 @@ Updates a pet in the store with form data ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' @@ -397,7 +397,7 @@ uploads an image ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = 'YOUR ACCESS TOKEN' diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index c38a41eeef4..a58e25c1c2f 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -67,7 +67,7 @@ Returns a map of status codes to quantities ```ruby # load the gem require 'petstore' -# setup authorization +# setup authorization Petstore.configure do |config| # Configure API key authorization: api_key config.api_key['api_key'] = 'YOUR API KEY' diff --git a/samples/client/petstore/ruby/git_push.sh b/samples/client/petstore/ruby/git_push.sh index ed374619b13..792320114fb 100644 --- a/samples/client/petstore/ruby/git_push.sh +++ b/samples/client/petstore/ruby/git_push.sh @@ -28,7 +28,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 05973753287..0a67bae014f 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -157,13 +157,6 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key', - value: api_key_with_prefix('api_key') - }, 'petstore_auth' => { type: 'oauth2', @@ -171,6 +164,13 @@ module Petstore key: 'Authorization', value: "Bearer #{access_token}" }, + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key', + value: api_key_with_prefix('api_key') + }, } end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 5612f227d09..399f56664cd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -20,17 +20,21 @@ module Petstore class Animal attr_accessor :class_name + attr_accessor :color + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'class_name' => :'className' + :'class_name' => :'className', + :'color' => :'color' } end # Attribute type mapping. def self.swagger_types { - :'class_name' => :'String' + :'class_name' => :'String', + :'color' => :'String' } end @@ -46,6 +50,12 @@ module Petstore self.class_name = attributes[:'className'] end + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = "red" + end + end # Show invalid properties with the reasons. Usually used together with valid? @@ -65,15 +75,16 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && - class_name == o.class_name + class_name == o.class_name && + color == o.color end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -81,7 +92,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [class_name].hash + [class_name, color].hash end # Builds the object from hash @@ -172,7 +183,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb index 62ca66ce38b..2327c51dc95 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb @@ -53,14 +53,14 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -159,7 +159,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 79da573e941..9cb46dd0710 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -77,7 +77,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -87,7 +87,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -186,7 +186,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 12f17b85553..0e16b88ca7e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -20,12 +20,15 @@ module Petstore class Cat attr_accessor :class_name + attr_accessor :color + attr_accessor :declawed # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'class_name' => :'className', + :'color' => :'color', :'declawed' => :'declawed' } end @@ -34,6 +37,7 @@ module Petstore def self.swagger_types { :'class_name' => :'String', + :'color' => :'String', :'declawed' => :'BOOLEAN' } end @@ -50,6 +54,12 @@ module Petstore self.class_name = attributes[:'className'] end + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = "red" + end + if attributes.has_key?(:'declawed') self.declawed = attributes[:'declawed'] end @@ -73,16 +83,17 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && class_name == o.class_name && + color == o.color && declawed == o.declawed end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -90,7 +101,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [class_name, declawed].hash + [class_name, color, declawed].hash end # Builds the object from hash @@ -181,7 +192,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index c4879d65bb4..a7235fd4d7c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -69,7 +69,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -78,7 +78,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -177,7 +177,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 90d213dbf45..64eaa7e9510 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -20,12 +20,15 @@ module Petstore class Dog attr_accessor :class_name + attr_accessor :color + attr_accessor :breed # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'class_name' => :'className', + :'color' => :'color', :'breed' => :'breed' } end @@ -34,6 +37,7 @@ module Petstore def self.swagger_types { :'class_name' => :'String', + :'color' => :'String', :'breed' => :'String' } end @@ -50,6 +54,12 @@ module Petstore self.class_name = attributes[:'className'] end + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = "red" + end + if attributes.has_key?(:'breed') self.breed = attributes[:'breed'] end @@ -73,16 +83,17 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && class_name == o.class_name && + color == o.color && breed == o.breed end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -90,7 +101,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [class_name, breed].hash + [class_name, color, breed].hash end # Builds the object from hash @@ -181,7 +192,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb index 4dc0bb6c16b..bcab08339e3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -58,14 +58,14 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -164,7 +164,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index 3f045b3490e..bcb7d5f7b52 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -119,7 +119,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -129,7 +129,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -228,7 +228,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 946e0001555..b8f6741812a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -347,7 +347,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -367,7 +367,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -466,7 +466,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 7a2473fb8b9..aa30d25f816 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -62,7 +62,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -70,7 +70,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -169,7 +169,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 0361451b290..52b35eb9c75 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -62,7 +62,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -70,7 +70,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -169,7 +169,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index d5e3ef4adb8..c6ebdb78139 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -25,12 +25,15 @@ module Petstore attr_accessor :property + attr_accessor :_123_number + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'name' => :'name', :'snake_case' => :'snake_case', - :'property' => :'property' + :'property' => :'property', + :'_123_number' => :'123Number' } end @@ -39,7 +42,8 @@ module Petstore { :'name' => :'Integer', :'snake_case' => :'Integer', - :'property' => :'String' + :'property' => :'String', + :'_123_number' => :'Integer' } end @@ -63,6 +67,10 @@ module Petstore self.property = attributes[:'property'] end + if attributes.has_key?(:'123Number') + self._123_number = attributes[:'123Number'] + end + end # Show invalid properties with the reasons. Usually used together with valid? @@ -82,17 +90,18 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && name == o.name && snake_case == o.snake_case && - property == o.property + property == o.property && + _123_number == o._123_number end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -100,7 +109,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [name, snake_case, property].hash + [name, snake_case, property, _123_number].hash end # Builds the object from hash @@ -191,7 +200,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 6c021e50ec7..8c5afb2e0c8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -118,7 +118,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -131,7 +131,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -230,7 +230,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index ba4d466df21..26ddf2ba82e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -128,7 +128,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -141,7 +141,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -240,7 +240,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 853d1e49600..b90b998087d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -61,7 +61,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -69,7 +69,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -168,7 +168,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index d6d49068e37..817ae37145d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -69,7 +69,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -78,7 +78,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -177,7 +177,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index f0c39b741d5..1e56dd5ff48 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -118,7 +118,7 @@ module Petstore end # Checks equality by comparing each attribute. - # @param [Object] Object to be compared + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -133,7 +133,7 @@ module Petstore end # @see the `==` method - # @param [Object] Object to be compared + # @param [Object] Object to be compared def eql?(o) self == o end @@ -232,7 +232,7 @@ module Petstore # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value + # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) From a62fa1c80c4cecde0cd349236a0c1ad43253d840 Mon Sep 17 00:00:00 2001 From: Newell Zhu Date: Tue, 17 May 2016 20:25:27 +0800 Subject: [PATCH 3/3] replace old syntax for rspec --- .../petstore/ruby/spec/api_client_spec.rb | 140 ++++++++-------- .../petstore/ruby/spec/configuration_spec.rb | 4 +- samples/client/petstore/ruby/spec/pet_spec.rb | 154 +++++++++--------- .../client/petstore/ruby/spec/store_spec.rb | 18 +- 4 files changed, 158 insertions(+), 158 deletions(-) diff --git a/samples/client/petstore/ruby/spec/api_client_spec.rb b/samples/client/petstore/ruby/spec/api_client_spec.rb index 3e57a432391..15468683bc3 100644 --- a/samples/client/petstore/ruby/spec/api_client_spec.rb +++ b/samples/client/petstore/ruby/spec/api_client_spec.rb @@ -10,34 +10,34 @@ describe Petstore::ApiClient do context 'host' do it 'removes http from host' do Petstore.configure { |c| c.host = 'http://example.com' } - Petstore::Configuration.default.host.should == 'example.com' + expect(Petstore::Configuration.default.host).to eq('example.com') end it 'removes https from host' do Petstore.configure { |c| c.host = 'https://wookiee.com' } - Petstore::ApiClient.default.config.host.should == 'wookiee.com' + expect(Petstore::ApiClient.default.config.host).to eq('wookiee.com') end it 'removes trailing path from host' do Petstore.configure { |c| c.host = 'hobo.com/v4' } - Petstore::Configuration.default.host.should == 'hobo.com' + expect(Petstore::Configuration.default.host).to eq('hobo.com') end end context 'base_path' do it "prepends a slash to base_path" do Petstore.configure { |c| c.base_path = 'v4/dog' } - Petstore::Configuration.default.base_path.should == '/v4/dog' + expect(Petstore::Configuration.default.base_path).to eq('/v4/dog') end it "doesn't prepend a slash if one is already there" do Petstore.configure { |c| c.base_path = '/v4/dog' } - Petstore::Configuration.default.base_path.should == '/v4/dog' + expect(Petstore::Configuration.default.base_path).to eq('/v4/dog') end it "ends up as a blank string if nil" do Petstore.configure { |c| c.base_path = nil } - Petstore::Configuration.default.base_path.should == '' + expect(Petstore::Configuration.default.base_path).to eq('') end end @@ -65,14 +65,14 @@ describe Petstore::ApiClient do header_params = {} query_params = {} api_client.update_params_for_auth! header_params, query_params, auth_names - header_params.should == {'api_key' => 'PREFIX special-key'} - query_params.should == {} + expect(header_params).to eq({'api_key' => 'PREFIX special-key'}) + expect(query_params).to eq({}) header_params = {} query_params = {} api_client2.update_params_for_auth! header_params, query_params, auth_names - header_params.should == {'api_key' => 'PREFIX2 special-key2'} - query_params.should == {} + expect(header_params).to eq({'api_key' => 'PREFIX2 special-key2'}) + expect(query_params).to eq({}) end it "sets header api-key parameter without prefix" do @@ -87,8 +87,8 @@ describe Petstore::ApiClient do query_params = {} auth_names = ['api_key', 'unknown'] api_client.update_params_for_auth! header_params, query_params, auth_names - header_params.should == {'api_key' => 'special-key'} - query_params.should == {} + expect(header_params).to eq({'api_key' => 'special-key'}) + expect(query_params).to eq({}) end end @@ -97,17 +97,17 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new(config) } it "defaults to 0" do - Petstore::Configuration.default.timeout.should == 0 - config.timeout.should == 0 + expect(Petstore::Configuration.default.timeout).to eq(0) + expect(config.timeout).to eq(0) request = api_client.build_request(:get, '/test') - request.options[:timeout].should == 0 + expect(request.options[:timeout]).to eq(0) end it "can be customized" do config.timeout = 100 request = api_client.build_request(:get, '/test') - request.options[:timeout].should == 100 + expect(request.options[:timeout]).to eq(100) end end @@ -117,8 +117,8 @@ describe Petstore::ApiClient do headers = {'Content-Type' => 'application/json'} response = double('response', headers: headers, body: '[12, 34]') data = api_client.deserialize(response, 'Array') - data.should be_a(Array) - data.should == [12, 34] + expect(data).to be_a(Array) + expect(data).to eq([12, 34]) end it "handles Array>" do @@ -126,8 +126,8 @@ describe Petstore::ApiClient do headers = {'Content-Type' => 'application/json'} response = double('response', headers: headers, body: '[[12, 34], [56]]') data = api_client.deserialize(response, 'Array>') - data.should be_a(Array) - data.should == [[12, 34], [56]] + expect(data).to be_a(Array) + expect(data).to eq([[12, 34], [56]]) end it "handles Hash" do @@ -135,8 +135,8 @@ describe Petstore::ApiClient do headers = {'Content-Type' => 'application/json'} response = double('response', headers: headers, body: '{"message": "Hello"}') data = api_client.deserialize(response, 'Hash') - data.should be_a(Hash) - data.should == {:message => 'Hello'} + expect(data).to be_a(Hash) + expect(data).to eq({:message => 'Hello'}) end it "handles Hash" do @@ -144,11 +144,11 @@ describe Petstore::ApiClient do headers = {'Content-Type' => 'application/json'} response = double('response', headers: headers, body: '{"pet": {"id": 1}}') data = api_client.deserialize(response, 'Hash') - data.should be_a(Hash) - data.keys.should == [:pet] + expect(data).to be_a(Hash) + expect(data.keys).to eq([:pet]) pet = data[:pet] - pet.should be_a(Petstore::Pet) - pet.id.should == 1 + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(1) end it "handles Hash>" do @@ -156,14 +156,14 @@ describe Petstore::ApiClient do headers = {'Content-Type' => 'application/json'} response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}') result = api_client.deserialize(response, 'Hash>') - result.should be_a(Hash) - result.keys.should == [:data] + expect(result).to be_a(Hash) + expect(result.keys).to eq([:data]) data = result[:data] - data.should be_a(Hash) - data.keys.should == [:pet] + expect(data).to be_a(Hash) + expect(data.keys).to eq([:pet]) pet = data[:pet] - pet.should be_a(Petstore::Pet) - pet.id.should == 1 + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(1) end end @@ -177,7 +177,7 @@ describe Petstore::ApiClient do pet.photo_urls = nil pet.tags = [] expected = {id: 1, name: '', tags: []} - api_client.object_to_hash(pet).should == expected + expect(api_client.object_to_hash(pet)).to eq(expected) end end @@ -186,27 +186,27 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new } it "works for csv" do - api_client.build_collection_param(param, :csv).should == 'aa,bb,cc' + expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc') end it "works for ssv" do - api_client.build_collection_param(param, :ssv).should == 'aa bb cc' + expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc') end it "works for tsv" do - api_client.build_collection_param(param, :tsv).should == "aa\tbb\tcc" + expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") end it "works for pipes" do - api_client.build_collection_param(param, :pipes).should == 'aa|bb|cc' + expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc') end it "works for multi" do - api_client.build_collection_param(param, :multi).should == ['aa', 'bb', 'cc'] + expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) end it "fails for invalid collection format" do - proc { api_client.build_collection_param(param, :INVALID) }.should raise_error(RuntimeError, 'unknown collection format: :INVALID') + expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID') end end @@ -214,16 +214,16 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new } it "works" do - api_client.json_mime?(nil).should == false - api_client.json_mime?('').should == false + expect(api_client.json_mime?(nil)).to eq(false) + expect(api_client.json_mime?('')).to eq(false) - api_client.json_mime?('application/json').should == true - api_client.json_mime?('application/json; charset=UTF8').should == true - api_client.json_mime?('APPLICATION/JSON').should == true + 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) - api_client.json_mime?('application/xml').should == false - api_client.json_mime?('text/plain').should == false - api_client.json_mime?('application/jsonp').should == false + 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 @@ -231,15 +231,15 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new } it "works" do - api_client.select_header_accept(nil).should == nil - api_client.select_header_accept([]).should == nil + expect(api_client.select_header_accept(nil)).to eq(nil) + expect(api_client.select_header_accept([])).to eq(nil) - api_client.select_header_accept(['application/json']).should == 'application/json' - api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8']).should == 'application/json; charset=UTF8' - api_client.select_header_accept(['APPLICATION/JSON', 'text/html']).should == 'APPLICATION/JSON' + 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') - api_client.select_header_accept(['application/xml']).should == 'application/xml' - api_client.select_header_accept(['text/html', 'application/xml']).should == 'text/html,application/xml' + 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 @@ -247,14 +247,14 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new } it "works" do - api_client.select_header_content_type(nil).should == 'application/json' - api_client.select_header_content_type([]).should == 'application/json' + expect(api_client.select_header_content_type(nil)).to eq('application/json') + expect(api_client.select_header_content_type([])).to eq('application/json') - api_client.select_header_content_type(['application/json']).should == 'application/json' - api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8']).should == 'application/json; charset=UTF8' - api_client.select_header_content_type(['APPLICATION/JSON', 'text/html']).should == 'APPLICATION/JSON' - api_client.select_header_content_type(['application/xml']).should == 'application/xml' - api_client.select_header_content_type(['text/plain', 'application/xml']).should == 'text/plain' + 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 @@ -262,15 +262,15 @@ describe Petstore::ApiClient do let(:api_client) { Petstore::ApiClient.new } it "works" do - api_client.sanitize_filename('sun').should == 'sun' - api_client.sanitize_filename('sun.gif').should == 'sun.gif' - api_client.sanitize_filename('../sun.gif').should == 'sun.gif' - api_client.sanitize_filename('/var/tmp/sun.gif').should == 'sun.gif' - api_client.sanitize_filename('./sun.gif').should == 'sun.gif' - api_client.sanitize_filename('..\sun.gif').should == 'sun.gif' - api_client.sanitize_filename('\var\tmp\sun.gif').should == 'sun.gif' - api_client.sanitize_filename('c:\var\tmp\sun.gif').should == 'sun.gif' - api_client.sanitize_filename('.\sun.gif').should == 'sun.gif' + 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 diff --git a/samples/client/petstore/ruby/spec/configuration_spec.rb b/samples/client/petstore/ruby/spec/configuration_spec.rb index eb29b54c2a7..45637e30d6d 100644 --- a/samples/client/petstore/ruby/spec/configuration_spec.rb +++ b/samples/client/petstore/ruby/spec/configuration_spec.rb @@ -12,13 +12,13 @@ describe Petstore::Configuration do describe '#base_url' do it 'should have the default value' do - config.base_url.should == 'http://petstore.swagger.io/v2' + expect(config.base_url).to eq('http://petstore.swagger.io/v2') end it 'should remove trailing slashes' do [nil, '', '/', '//'].each do |base_path| config.base_path = base_path - config.base_url.should == 'http://petstore.swagger.io' + expect(config.base_url).to eq('http://petstore.swagger.io') end end end diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb index 737eee56d07..4ccea494b84 100644 --- a/samples/client/petstore/ruby/spec/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/pet_spec.rb @@ -33,42 +33,42 @@ describe "Pet" do } pet = Petstore::Pet.new(pet_hash) # test new - pet.name.should == "RUBY UNIT TESTING" - pet.status.should == "pending" - pet.id.should == @pet_id - pet.tags[0].id.should == 1 - pet.tags[1].name.should == 'tag2' - pet.category.name.should == 'category unknown' + expect(pet.name).to eq("RUBY UNIT TESTING") + expect(pet.status).to eq("pending") + expect(pet.id).to eq(@pet_id) + expect(pet.tags[0].id).to eq(1) + expect(pet.tags[1].name).to eq('tag2') + expect(pet.category.name).to eq('category unknown') # test build_from_hash pet2 = Petstore::Pet.new pet2.build_from_hash(pet.to_hash) - pet.to_hash.should == pet2.to_hash + expect(pet.to_hash).to eq(pet2.to_hash) # make sure sub-object has different object id - pet.tags[0].object_id.should_not == pet2.tags[0].object_id - pet.tags[1].object_id.should_not == pet2.tags[1].object_id - pet.category.object_id.should_not == pet2.category.object_id + expect(pet.tags[0].object_id).not_to eq(pet2.tags[0].object_id) + expect(pet.tags[1].object_id).not_to eq(pet2.tags[1].object_id) + expect(pet.category.object_id).not_to eq(pet2.category.object_id) end it "should fetch a pet object" do pet = @pet_api.get_pet_by_id(@pet_id) - pet.should be_a(Petstore::Pet) - pet.id.should == @pet_id - pet.name.should == "RUBY UNIT TESTING" - pet.tags[0].name.should == "tag test" - pet.category.name.should == "category test" + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(@pet_id) + expect(pet.name).to eq("RUBY UNIT TESTING") + expect(pet.tags[0].name).to eq("tag test") + expect(pet.category.name).to eq("category test") end it "should fetch a pet object with http info" do pet, status_code, headers = @pet_api.get_pet_by_id_with_http_info(@pet_id) - status_code.should == 200 - headers['Content-Type'].should == 'application/json' - pet.should be_a(Petstore::Pet) - pet.id.should == @pet_id - pet.name.should == "RUBY UNIT TESTING" - pet.tags[0].name.should == "tag test" - pet.category.name.should == "category test" + expect(status_code).to eq(200) + expect(headers['Content-Type']).to eq('application/json') + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(@pet_id) + expect(pet.name).to eq("RUBY UNIT TESTING") + expect(pet.tags[0].name).to eq("tag test") + expect(pet.category.name).to eq("category test") end it "should not find a pet that does not exist" do @@ -76,11 +76,11 @@ describe "Pet" do @pet_api.get_pet_by_id(-@pet_id) fail 'it should raise error' rescue Petstore::ApiError => e - e.code.should == 404 - e.message.should == 'Not Found' - e.response_body.should == '{"code":1,"type":"error","message":"Pet not found"}' - e.response_headers.should be_a(Hash) - e.response_headers['Content-Type'].should == 'application/json' + expect(e.code).to eq(404) + expect(e.message).to eq('Not Found') + expect(e.response_body).to eq('{"code":1,"type":"error","message":"Pet not found"}') + expect(e.response_headers).to be_a(Hash) + expect(e.response_headers['Content-Type']).to eq('application/json') end end @@ -93,12 +93,12 @@ describe "Pet" do @pet_api.add_pet_using_byte_array(body: str) fetched_str = @pet_api.pet_pet_idtesting_byte_arraytrue_get(pet.id) - fetched_str.should be_a(String) + expect(fetched_str).to be_a(String) fetched = deserialize_json(fetched_str, 'Pet') - fetched.should be_a(Petstore::Pet) - fetched.id.should == pet.id - fetched.category.should be_a(Petstore::Category) - fetched.category.name.should == pet.category.name + expect(fetched).to be_a(Petstore::Pet) + expect(fetched.id).to eq(pet.id) + expect(fetched.category).to be_a(Petstore::Category) + expect(fetched.category.name).to eq(pet.category.name) @pet_api.delete_pet(pet.id) end @@ -107,40 +107,40 @@ describe "Pet" do # we will re-enable this after updating the petstore server xit "should get pet in object" do pet = @pet_api.get_pet_by_id_in_object(@pet_id) - pet.should be_a(Petstore::InlineResponse200) - pet.id.should == @pet_id - pet.name.should == "RUBY UNIT TESTING" - pet.category.should be_a(Hash) - pet.category[:id].should == 20002 - pet.category[:name].should == 'category test' + expect(pet).to be_a(Petstore::InlineResponse200) + expect(pet.id).to eq(@pet_id) + expect(pet.name).to eq("RUBY UNIT TESTING") + expect(pet.category).to be_a(Hash) + expect(pet.category[:id]).to eq(20002) + expect(pet.category[:name]).to eq('category test') end it "should update a pet" do pet = @pet_api.get_pet_by_id(@pet_id) - pet.id.should == @pet_id - pet.name.should == "RUBY UNIT TESTING" - pet.status.should == 'pending' + expect(pet.id).to eq(@pet_id) + expect(pet.name).to eq("RUBY UNIT TESTING") + expect(pet.status).to eq('pending') @pet_api.update_pet_with_form(@pet_id, name: 'new name', status: 'sold') fetched = @pet_api.get_pet_by_id(@pet_id) - fetched.id.should == @pet_id - fetched.name.should == "new name" - fetched.status.should == 'sold' + expect(fetched.id).to eq(@pet_id) + expect(fetched.name).to eq("new name") + expect(fetched.status).to eq('sold') end it "should find pets by status" do pets = @pet_api.find_pets_by_status(['available']) - pets.length.should >= 3 + expect(pets.length).to be >= 3 pets.each do |pet| - pet.should be_a(Petstore::Pet) - pet.status.should == 'available' + expect(pet).to be_a(Petstore::Pet) + expect(pet.status).to eq('available') end end it "should not find a pet with invalid status" do pets = @pet_api.find_pets_by_status(['invalid-status']) - pets.length.should == 0 + expect(pets.length).to eq(0) end it "should find a pet by status" do @@ -158,11 +158,11 @@ describe "Pet" do pet = Petstore::Pet.new('id' => id, 'name' => "RUBY UNIT TESTING") result = @pet_api.add_pet(pet) # nothing is returned - result.should be_nil + expect(result).to be_nil pet = @pet_api.get_pet_by_id(id) - pet.id.should == id - pet.name.should == "RUBY UNIT TESTING" + expect(pet.id).to eq(id) + expect(pet.name).to eq("RUBY UNIT TESTING") @pet_api.delete_pet(id) end @@ -170,48 +170,48 @@ describe "Pet" do it "should upload a file to a pet" do result = @pet_api.upload_file(@pet_id, file: File.new('hello.txt')) # ApiResponse is returned - result.should be_a(Petstore::ApiResponse) + expect(result).to be_a(Petstore::ApiResponse) end it "should upload a file with form parameter to a pet" do result = @pet_api.upload_file(@pet_id, file: File.new('hello.txt'), additional_metadata: 'metadata') # ApiResponse is returned - result.should be_a(Petstore::ApiResponse) + expect(result).to be_a(Petstore::ApiResponse) end it "should implement eql? and hash" do pet1 = Petstore::Pet.new pet2 = Petstore::Pet.new - pet1.should == pet2 - pet2.should == pet1 - pet1.eql?(pet2).should == true - pet2.eql?(pet1).should == true - pet1.hash.should == pet2.hash - pet1.should == pet1 - pet1.eql?(pet1).should == true - pet1.hash.should == pet1.hash + expect(pet1).to eq(pet2) + expect(pet2).to eq(pet1) + expect(pet1.eql?(pet2)).to eq(true) + expect(pet2.eql?(pet1)).to eq(true) + expect(pet1.hash).to eq(pet2.hash) + expect(pet1).to eq(pet1) + expect(pet1.eql?(pet1)).to eq(true) + expect(pet1.hash).to eq(pet1.hash) pet1.name = 'really-happy' pet1.photo_urls = ['http://foo.bar.com/1', 'http://foo.bar.com/2'] - pet1.should_not == pet2 - pet2.should_not == pet1 - pet1.eql?(pet2).should == false - pet2.eql?(pet1).should == false - pet1.hash.should_not == pet2.hash - pet1.should == pet1 - pet1.eql?(pet1).should == true - pet1.hash.should == pet1.hash + expect(pet1).not_to eq(pet2) + expect(pet2).not_to eq(pet1) + expect(pet1.eql?(pet2)).to eq(false) + expect(pet2.eql?(pet1)).to eq(false) + expect(pet1.hash).not_to eq(pet2.hash) + expect(pet1).to eq(pet1) + expect(pet1.eql?(pet1)).to eq(true) + expect(pet1.hash).to eq(pet1.hash) pet2.name = 'really-happy' pet2.photo_urls = ['http://foo.bar.com/1', 'http://foo.bar.com/2'] - pet1.should == pet2 - pet2.should == pet1 - pet1.eql?(pet2).should == true - pet2.eql?(pet1).should == true - pet1.hash.should == pet2.hash - pet2.should == pet2 - pet2.eql?(pet2).should == true - pet2.hash.should == pet2.hash + expect(pet1).to eq(pet2) + expect(pet2).to eq(pet1) + expect(pet1.eql?(pet2)).to eq(true) + expect(pet2.eql?(pet1)).to eq(true) + expect(pet1.hash).to eq(pet2.hash) + expect(pet2).to eq(pet2) + expect(pet2.eql?(pet2)).to eq(true) + expect(pet2.hash).to eq(pet2.hash) end end end diff --git a/samples/client/petstore/ruby/spec/store_spec.rb b/samples/client/petstore/ruby/spec/store_spec.rb index 229a9dfd40a..cdcaedfe44d 100644 --- a/samples/client/petstore/ruby/spec/store_spec.rb +++ b/samples/client/petstore/ruby/spec/store_spec.rb @@ -9,18 +9,18 @@ describe "Store" do @order_id = prepare_store(@api) item = @api.get_order_by_id(@order_id) - item.id.should == @order_id + expect(item.id).to eq(@order_id) @api.delete_order(@order_id) end it "should featch the inventory" do result = @api.get_inventory - result.should be_a(Hash) - result.should_not be_empty + expect(result).to be_a(Hash) + expect(result).not_to be_empty result.each do |k, v| - k.should be_a(Symbol) - v.should be_a(Integer) + expect(k).to be_a(Symbol) + expect(v).to be_a(Integer) end end @@ -28,11 +28,11 @@ describe "Store" do # will re-enable this after updating the petstore server xit "should featch the inventory in object" do result = @api.get_inventory_in_object - result.should be_a(Hash) - result.should_not be_empty + expect(result).to be_a(Hash) + expect(result).not_to be_empty result.each do |k, v| - k.should be_a(Symbol) - v.should be_a(Integer) + expect(k).to be_a(Symbol) + expect(v).to be_a(Integer) end end end