Update tests with latest code

This commit is contained in:
xhh
2015-06-30 14:32:55 +08:00
parent 609d915541
commit a75b05b952
7 changed files with 90 additions and 102 deletions

View File

@@ -36,40 +36,36 @@ end
# help
#end
def configure_swagger
Petstore::Swagger.configure do |config|
config.api_key['api_key'] = 'special-key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
end
API_CLIENT = Petstore::ApiClient.new do |config|
config.api_key['api_key'] = 'special-key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
end
# always delete and then re-create the pet object with 10002
def prepare_pet
def prepare_pet(pet_api)
# remove the pet
Petstore::PetApi.delete_pet(10002)
pet_api.delete_pet(10002)
# recreate the pet
category = Petstore::Category.new('id' => 20002, 'name' => 'category test')
tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test')
pet = Petstore::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url',
'category' => category, 'tags' => [tag], 'status' => 'pending')
Petstore::PetApi.add_pet(:'body'=> pet)
pet_api.add_pet(:'body'=> pet)
end
# always delete and then re-create the store order
def prepare_store
def prepare_store(store_api)
order = Petstore::Order.new("id" => 10002,
"petId" => 10002,
"quantity" => 789,
"shipDate" => "2015-04-06T23:42:01.678Z",
"status" => "placed",
"complete" => false)
Petstore::StoreApi.place_order(:body => order)
store_api.place_order(:body => order)
end
configure_swagger
# 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