update ruby test files

This commit is contained in:
wing328 2016-05-10 14:56:14 +08:00
parent d54877b5d3
commit 31daa2b092
26 changed files with 283 additions and 535 deletions

View File

@ -228,6 +228,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
writeOptional(outputFolder, new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb")); writeOptional(outputFolder, new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb"));
writeOptional(outputFolder, new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb")); writeOptional(outputFolder, new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb"));
writeOptional(outputFolder, new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb")); writeOptional(outputFolder, new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb"));
// not including base object test as the moment as not all API has model
//writeOptional(outputFolder, new SupportingFile("base_object_spec.mustache", specFolder, "base_object_spec.rb"));
} }
@Override @Override

View File

@ -0,0 +1,109 @@
require 'spec_helper'
class ArrayMapObject < Petstore::Category
attr_accessor :int_arr, :pet_arr, :int_map, :pet_map, :int_arr_map, :pet_arr_map, :boolean_true_arr, :boolean_false_arr
def self.attribute_map
{
:int_arr => :int_arr,
:pet_arr => :pet_arr,
:int_map => :int_map,
:pet_map => :pet_map,
:int_arr_map => :int_arr_map,
:pet_arr_map => :pet_arr_map,
:boolean_true_arr => :boolean_true_arr,
:boolean_false_arr => :boolean_false_arr,
}
end
def self.swagger_types
{
:int_arr => :'Array<Integer>',
:pet_arr => :'Array<Pet>',
:int_map => :'Hash<String, Integer>',
:pet_map => :'Hash<String, Pet>',
:int_arr_map => :'Hash<String, Array<Integer>>',
:pet_arr_map => :'Hash<String, Array<Pet>>',
:boolean_true_arr => :'Array<BOOLEAN>',
:boolean_false_arr => :'Array<BOOLEAN>',
}
end
end
describe 'BaseObject' do
describe 'boolean values' do
let(:obj) { Petstore::Cat.new({declawed: false}) }
it 'should have values set' do
expect(obj.declawed).not_to be_nil
expect(obj.declawed).to eq(false)
end
end
describe 'array and map properties' do
let(:obj) { ArrayMapObject.new }
let(:data) do
{int_arr: [123, 456],
pet_arr: [{name: 'Kitty'}],
int_map: {'int' => 123},
pet_map: {'pet' => {name: 'Kitty'}},
int_arr_map: {'int_arr' => [123, 456]},
pet_arr_map: {'pet_arr' => [{name: 'Kitty'}]},
boolean_true_arr: [true, "true", "TruE", 1, "y", "yes", "1", "t", "T"],
boolean_false_arr: [false, "", 0, "0", "f", nil, "null"],
}
end
it 'works for #build_from_hash' do
obj.build_from_hash(data)
expect(obj.int_arr).to match_array([123, 456])
expect(obj.pet_arr).to be_instance_of(Array)
expect(obj.pet_arr).to be_instance_of(1)
pet = obj.pet_arr.first
expect(pet).to be_instance_of(Petstore::Pet)
expect(pet.name).to eq('Kitty')
expect(obj.int_map).to be_instance_of(Hash)
expect(obj.int_map).to eq({'int' => 123})
expect(obj.pet_map).to be_instance_of(Hash)
pet = obj.pet_map['pet']
expect(pet).to be_instance_of(Petstore::Pet)
expect(pet.name).to eq('Kitty')
expect(obj.int_arr_map).to be_instance_of(Hash)
arr = obj.int_arr_map['int_arr']
expect(arr).to match_array([123, 456])
expect(obj.pet_arr_map).to be_instance_of(Hash)
arr = obj.pet_arr_map['pet_arr']
expect(arr).to be_instance_of(Array)
expect(arr.size).to eq(1)
pet = arr.first
expect(pet).to be_instance_of(Petstore::Pet)
expect(pet.name).to eq('Kitty')
expect(obj.boolean_true_arr).to be_instance_of(Array)
obj.boolean_true_arr.each do |b|
expect(b).to eq(true)
end
expect(obj.boolean_false_arr).to be_instance_of(Array)
obj.boolean_false_arr.each do |b|
expect(b).to eq(false)
end
end
it 'works for #to_hash' do
obj.build_from_hash(data)
expect_data = data.dup
expect_data[:boolean_true_arr].map! {true}
expect_data[:boolean_false_arr].map! {false}
expect(obj.to_hash).to eq(expect_data)
end
end
end

View File

@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0 - API version: 1.0.0
- Package version: 1.0.0 - Package version: 1.0.0
- Build date: 2016-05-10T14:06:27.504+08:00 - Build date: 2016-05-10T14:47:49.265+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen - Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation ## Installation

View File

@ -32,13 +32,13 @@ describe 'FakeApi' do
describe 'test an instance of FakeApi' do describe 'test an instance of FakeApi' do
it 'should create an instact of FakeApi' do it 'should create an instact of FakeApi' do
@instance.should be_a(Petstore::FakeApi) expect(@instance).to be_instance_of(Petstore::FakeApi)
end end
end end
# unit tests for test_endpoint_parameters # unit tests for test_endpoint_parameters
# Fake endpoint for testing various parameters # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# Fake endpoint for testing various parameters # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# @param number None # @param number None
# @param double None # @param double None
# @param string None # @param string None
@ -55,11 +55,7 @@ describe 'FakeApi' do
# @return [nil] # @return [nil]
describe 'test_endpoint_parameters test' do describe 'test_endpoint_parameters test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -32,7 +32,7 @@ describe 'PetApi' do
describe 'test an instance of PetApi' do describe 'test an instance of PetApi' do
it 'should create an instact of PetApi' do it 'should create an instact of PetApi' do
@instance.should be_a(Petstore::PetApi) expect(@instance).to be_instance_of(Petstore::PetApi)
end end
end end
@ -44,11 +44,7 @@ describe 'PetApi' do
# @return [nil] # @return [nil]
describe 'add_pet test' do describe 'add_pet test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -61,11 +57,7 @@ describe 'PetApi' do
# @return [nil] # @return [nil]
describe 'delete_pet test' do describe 'delete_pet test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -77,11 +69,7 @@ describe 'PetApi' do
# @return [Array<Pet>] # @return [Array<Pet>]
describe 'find_pets_by_status test' do describe 'find_pets_by_status test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -93,11 +81,7 @@ describe 'PetApi' do
# @return [Array<Pet>] # @return [Array<Pet>]
describe 'find_pets_by_tags test' do describe 'find_pets_by_tags test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -109,11 +93,7 @@ describe 'PetApi' do
# @return [Pet] # @return [Pet]
describe 'get_pet_by_id test' do describe 'get_pet_by_id test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -125,11 +105,7 @@ describe 'PetApi' do
# @return [nil] # @return [nil]
describe 'update_pet test' do describe 'update_pet test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -143,11 +119,7 @@ describe 'PetApi' do
# @return [nil] # @return [nil]
describe 'update_pet_with_form test' do describe 'update_pet_with_form test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -161,11 +133,7 @@ describe 'PetApi' do
# @return [ApiResponse] # @return [ApiResponse]
describe 'upload_file test' do describe 'upload_file test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -32,7 +32,7 @@ describe 'StoreApi' do
describe 'test an instance of StoreApi' do describe 'test an instance of StoreApi' do
it 'should create an instact of StoreApi' do it 'should create an instact of StoreApi' do
@instance.should be_a(Petstore::StoreApi) expect(@instance).to be_instance_of(Petstore::StoreApi)
end end
end end
@ -44,11 +44,7 @@ describe 'StoreApi' do
# @return [nil] # @return [nil]
describe 'delete_order test' do describe 'delete_order test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -59,27 +55,19 @@ describe 'StoreApi' do
# @return [Hash<String, Integer>] # @return [Hash<String, Integer>]
describe 'get_inventory test' do describe 'get_inventory test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
# unit tests for get_order_by_id # unit tests for get_order_by_id
# Find purchase order by ID # Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions # For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched # @param order_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Order] # @return [Order]
describe 'get_order_by_id test' do describe 'get_order_by_id test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -91,11 +79,7 @@ describe 'StoreApi' do
# @return [Order] # @return [Order]
describe 'place_order test' do describe 'place_order test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -32,7 +32,7 @@ describe 'UserApi' do
describe 'test an instance of UserApi' do describe 'test an instance of UserApi' do
it 'should create an instact of UserApi' do it 'should create an instact of UserApi' do
@instance.should be_a(Petstore::UserApi) expect(@instance).to be_instance_of(Petstore::UserApi)
end end
end end
@ -44,11 +44,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'create_user test' do describe 'create_user test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -60,11 +56,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'create_users_with_array_input test' do describe 'create_users_with_array_input test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -76,11 +68,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'create_users_with_list_input test' do describe 'create_users_with_list_input test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -92,11 +80,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'delete_user test' do describe 'delete_user test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -108,11 +92,7 @@ describe 'UserApi' do
# @return [User] # @return [User]
describe 'get_user_by_name test' do describe 'get_user_by_name test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -125,11 +105,7 @@ describe 'UserApi' do
# @return [String] # @return [String]
describe 'login_user test' do describe 'login_user test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -140,11 +116,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'logout_user test' do describe 'logout_user test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
@ -157,11 +129,7 @@ describe 'UserApi' do
# @return [nil] # @return [nil]
describe 'update_user test' do describe 'update_user test' do
it "should work" do it "should work" do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -35,8 +35,8 @@ describe 'BaseObject' do
let(:obj) { Petstore::Cat.new({declawed: false}) } let(:obj) { Petstore::Cat.new({declawed: false}) }
it 'should have values set' do it 'should have values set' do
obj.declawed.should_not eq nil expect(obj.declawed).not_to be_nil
obj.declawed.should eq false expect(obj.declawed).to eq(false)
end end
end end
@ -58,42 +58,43 @@ describe 'BaseObject' do
it 'works for #build_from_hash' do it 'works for #build_from_hash' do
obj.build_from_hash(data) obj.build_from_hash(data)
obj.int_arr.should == [123, 456] expect(obj.int_arr).to match_array([123, 456])
expect(obj.pet_arr).to be_instance_of(Array)
expect(obj.pet_arr.size).to eq(1)
obj.pet_arr.should be_a(Array)
obj.pet_arr.size.should == 1
pet = obj.pet_arr.first pet = obj.pet_arr.first
pet.should be_a(Petstore::Pet) expect(pet).to be_instance_of(Petstore::Pet)
pet.name.should == 'Kitty' expect(pet.name).to eq('Kitty')
obj.int_map.should be_a(Hash) expect(obj.int_map).to be_instance_of(Hash)
obj.int_map.should == {'int' => 123} expect(obj.int_map).to eq({'int' => 123})
obj.pet_map.should be_a(Hash) expect(obj.pet_map).to be_instance_of(Hash)
pet = obj.pet_map['pet'] pet = obj.pet_map['pet']
pet.should be_a(Petstore::Pet) expect(pet).to be_instance_of(Petstore::Pet)
pet.name.should == 'Kitty' expect(pet.name).to eq('Kitty')
obj.int_arr_map.should be_a(Hash) expect(obj.int_arr_map).to be_instance_of(Hash)
arr = obj.int_arr_map['int_arr'] arr = obj.int_arr_map['int_arr']
arr.should == [123, 456] expect(arr).to match_array([123, 456])
obj.pet_arr_map.should be_a(Hash) expect(obj.pet_arr_map).to be_instance_of(Hash)
arr = obj.pet_arr_map['pet_arr'] arr = obj.pet_arr_map['pet_arr']
arr.should be_a(Array) expect(arr).to be_instance_of(Array)
arr.size.should == 1 expect(arr.size).to eq(1)
pet = arr.first pet = arr.first
pet.should be_a(Petstore::Pet) expect(pet).to be_instance_of(Petstore::Pet)
pet.name.should == 'Kitty' expect(pet.name).to eq('Kitty')
obj.boolean_true_arr.should be_a(Array) expect(obj.boolean_true_arr).to be_instance_of(Array)
obj.boolean_true_arr.each do |b| obj.boolean_true_arr.each do |b|
b.should eq true expect(b).to eq(true)
end end
obj.boolean_false_arr.should be_a(Array) expect(obj.boolean_false_arr).to be_instance_of(Array)
obj.boolean_false_arr.each do |b| obj.boolean_false_arr.each do |b|
b.should eq false expect(b).to eq(false)
end end
end end
@ -102,7 +103,7 @@ describe 'BaseObject' do
expect_data = data.dup expect_data = data.dup
expect_data[:boolean_true_arr].map! {true} expect_data[:boolean_true_arr].map! {true}
expect_data[:boolean_false_arr].map! {false} expect_data[:boolean_false_arr].map! {false}
obj.to_hash.should == expect_data expect(obj.to_hash).to eq(expect_data)
end end
end end
end end

View File

@ -33,16 +33,12 @@ describe 'Animal' do
describe 'test an instance of Animal' do describe 'test an instance of Animal' do
it 'should create an instact of Animal' do it 'should create an instact of Animal' do
@instance.should be_a(Petstore::Animal) expect(@instance).to be_instance_of(Petstore::Animal)
end end
end end
describe 'test attribute "class_name"' do describe 'test attribute "class_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,36 +33,24 @@ describe 'ApiResponse' do
describe 'test an instance of ApiResponse' do describe 'test an instance of ApiResponse' do
it 'should create an instact of ApiResponse' do it 'should create an instact of ApiResponse' do
@instance.should be_a(Petstore::ApiResponse) expect(@instance).to be_instance_of(Petstore::ApiResponse)
end end
end end
describe 'test attribute "code"' do describe 'test attribute "code"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "type"' do describe 'test attribute "type"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "message"' do describe 'test attribute "message"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,26 +33,18 @@ describe 'Cat' do
describe 'test an instance of Cat' do describe 'test an instance of Cat' do
it 'should create an instact of Cat' do it 'should create an instact of Cat' do
@instance.should be_a(Petstore::Cat) expect(@instance).to be_instance_of(Petstore::Cat)
end end
end end
describe 'test attribute "class_name"' do describe 'test attribute "class_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "declawed"' do describe 'test attribute "declawed"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,26 +33,18 @@ describe 'Category' do
describe 'test an instance of Category' do describe 'test an instance of Category' do
it 'should create an instact of Category' do it 'should create an instact of Category' do
@instance.should be_a(Petstore::Category) expect(@instance).to be_instance_of(Petstore::Category)
end end
end end
describe 'test attribute "id"' do describe 'test attribute "id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "name"' do describe 'test attribute "name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,26 +33,18 @@ describe 'Dog' do
describe 'test an instance of Dog' do describe 'test an instance of Dog' do
it 'should create an instact of Dog' do it 'should create an instact of Dog' do
@instance.should be_a(Petstore::Dog) expect(@instance).to be_instance_of(Petstore::Dog)
end end
end end
describe 'test attribute "breed"' do describe 'test attribute "class_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "class_name"' do describe 'test attribute "breed"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,136 +33,84 @@ describe 'FormatTest' do
describe 'test an instance of FormatTest' do describe 'test an instance of FormatTest' do
it 'should create an instact of FormatTest' do it 'should create an instact of FormatTest' do
@instance.should be_a(Petstore::FormatTest) expect(@instance).to be_instance_of(Petstore::FormatTest)
end end
end end
describe 'test attribute "integer"' do describe 'test attribute "integer"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "int32"' do describe 'test attribute "int32"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "int64"' do describe 'test attribute "int64"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "number"' do describe 'test attribute "number"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "float"' do describe 'test attribute "float"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "double"' do describe 'test attribute "double"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "string"' do describe 'test attribute "string"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "byte"' do describe 'test attribute "byte"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "binary"' do describe 'test attribute "binary"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "date"' do describe 'test attribute "date"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "date_time"' do describe 'test attribute "date_time"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "uuid"' do describe 'test attribute "uuid"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "password"' do describe 'test attribute "password"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -1,100 +0,0 @@
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
Terms of Service: http://swagger.io/terms/
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineResponse200
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'InlineResponse200', pending: "Original spec does not have InlineResponse200 and we'll renable this after updating Petstore server" do
before do
# run before each test
@instance = Petstore::InlineResponse200.new
end
after do
# run after each test
end
describe 'test an instance of InlineResponse200' do
it 'should create an instact of InlineResponse200' do
@instance.should be_a(Petstore::InlineResponse200)
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 "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 "status"' 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
end

View File

@ -33,16 +33,12 @@ describe 'Model200Response' do
describe 'test an instance of Model200Response' do describe 'test an instance of Model200Response' do
it 'should create an instact of Model200Response' do it 'should create an instact of Model200Response' do
@instance.should be_a(Petstore::Model200Response) expect(@instance).to be_instance_of(Petstore::Model200Response)
end end
end end
describe 'test attribute "name"' do describe 'test attribute "name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,16 +33,12 @@ describe 'ModelReturn' do
describe 'test an instance of ModelReturn' do describe 'test an instance of ModelReturn' do
it 'should create an instact of ModelReturn' do it 'should create an instact of ModelReturn' do
@instance.should be_a(Petstore::ModelReturn) expect(@instance).to be_instance_of(Petstore::ModelReturn)
end end
end end
describe 'test attribute "_return"' do describe 'test attribute "_return"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,36 +33,24 @@ describe 'Name' do
describe 'test an instance of Name' do describe 'test an instance of Name' do
it 'should create an instact of Name' do it 'should create an instact of Name' do
@instance.should be_a(Petstore::Name) expect(@instance).to be_instance_of(Petstore::Name)
end end
end end
describe 'test attribute "name"' do describe 'test attribute "name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "snake_case"' do describe 'test attribute "snake_case"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "property"' do describe 'test attribute "property"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,66 +33,42 @@ describe 'Order' do
describe 'test an instance of Order' do describe 'test an instance of Order' do
it 'should create an instact of Order' do it 'should create an instact of Order' do
@instance.should be_a(Petstore::Order) expect(@instance).to be_instance_of(Petstore::Order)
end end
end end
describe 'test attribute "id"' do describe 'test attribute "id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "pet_id"' do describe 'test attribute "pet_id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "quantity"' do describe 'test attribute "quantity"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "ship_date"' do describe 'test attribute "ship_date"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "status"' do describe 'test attribute "status"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "complete"' do describe 'test attribute "complete"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -25,84 +25,50 @@ describe 'Pet' do
before do before do
# run before each test # run before each test
@instance = Petstore::Pet.new @instance = Petstore::Pet.new
@pet_api = Petstore::PetApi.new(API_CLIENT)
@pet_id = prepare_pet(@pet_api)
end end
after do after do
# run after each test # run after each test
# remove the testing pet
begin
@pet_api.delete_pet(@pet_id)
rescue Petstore::ApiError => e
# ignore ApiError 404 (Not Found)
raise e if e.code != 404
end
end end
describe 'test an instance of Pet' do describe 'test an instance of Pet' do
it 'should create an instact of Pet' do it 'should create an instact of Pet' do
@instance.should be_a(Petstore::Pet) expect(@instance).to be_instance_of(Petstore::Pet)
end end
end end
describe 'test attribute "id"' do describe 'test attribute "id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "category"' do describe 'test attribute "category"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "name"' do describe 'test attribute "name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "photo_urls"' do describe 'test attribute "photo_urls"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "tags"' do describe 'test attribute "tags"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "status"' do describe 'test attribute "status"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,16 +33,12 @@ describe 'SpecialModelName' do
describe 'test an instance of SpecialModelName' do describe 'test an instance of SpecialModelName' do
it 'should create an instact of SpecialModelName' do it 'should create an instact of SpecialModelName' do
@instance.should be_a(Petstore::SpecialModelName) expect(@instance).to be_instance_of(Petstore::SpecialModelName)
end end
end end
describe 'test attribute "special_property_name"' do describe 'test attribute "special_property_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,26 +33,18 @@ describe 'Tag' do
describe 'test an instance of Tag' do describe 'test an instance of Tag' do
it 'should create an instact of Tag' do it 'should create an instact of Tag' do
@instance.should be_a(Petstore::Tag) expect(@instance).to be_instance_of(Petstore::Tag)
end end
end end
describe 'test attribute "id"' do describe 'test attribute "id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "name"' do describe 'test attribute "name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -33,86 +33,54 @@ describe 'User' do
describe 'test an instance of User' do describe 'test an instance of User' do
it 'should create an instact of User' do it 'should create an instact of User' do
@instance.should be_a(Petstore::User) expect(@instance).to be_instance_of(Petstore::User)
end end
end end
describe 'test attribute "id"' do describe 'test attribute "id"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "username"' do describe 'test attribute "username"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "first_name"' do describe 'test attribute "first_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "last_name"' do describe 'test attribute "last_name"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "email"' do describe 'test attribute "email"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "password"' do describe 'test attribute "password"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "phone"' do describe 'test attribute "phone"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end
describe 'test attribute "user_status"' do describe 'test attribute "user_status"' do
it 'should work' do it 'should work' do
# assertion here # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# should be_a()
# should be_nil
# should ==
# should_not ==
end end
end end

View File

@ -1,16 +1,6 @@
require 'spec_helper' require 'spec_helper'
require 'json' require 'json'
def serialize_json(o)
API_CLIENT.object_to_http_body(o)
end
def deserialize_json(s, type)
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: s)
API_CLIENT.deserialize(response, type)
end
describe "Pet" do describe "Pet" do
before do before do
@pet_api = Petstore::PetApi.new(API_CLIENT) @pet_api = Petstore::PetApi.new(API_CLIENT)

View File

@ -1,4 +0,0 @@
--colour
--format progress
--loadby mtime
--reverse

View File

@ -1,4 +1,7 @@
# This file was generated by the `rspec --init` command. Conventionally, all # load the gem
require 'petstore'
# The following was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause # The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any # this file to always be loaded, without a need to explicitly require it in any
@ -95,5 +98,50 @@ RSpec.configure do |config|
=end =end
end end
require 'SwaggerClient' # API client (shared between all the test cases)
API_CLIENT = Petstore::ApiClient.new(Petstore::Configuration.new)
# randomly generate an ID
def random_id
rand(1000000) + 20000
end
# create a random pet, return its id
def prepare_pet(pet_api)
pet_id = random_id
category = Petstore::Category.new('id' => 20002, 'name' => 'category test')
tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test')
pet = Petstore::Pet.new('id' => pet_id, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url',
'category' => category, 'tags' => [tag], 'status' => 'pending')
pet_api.add_pet(pet)
return pet_id
end
# create a random order, return its id
def prepare_store(store_api)
order_id = 5
order = Petstore::Order.new("id" => order_id,
"petId" => 123,
"quantity" => 789,
"shipDate" => "2015-04-06T23:42:01.678Z",
"status" => "placed",
"complete" => false)
store_api.place_order(order)
return order_id
end
# A random string to tack onto stuff to ensure we're not seeing
# data from a previous test run
RAND = ("a".."z").to_a.sample(8).join
# helper method to serialize object to json string
def serialize_json(o)
API_CLIENT.object_to_http_body(o)
end
# helper method to deserialize json string back to object
def deserialize_json(s, type)
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: s)
API_CLIENT.deserialize(response, type)
end