From 637cae153c72b0f09dd4b279ab8b3e1b80001be3 Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 12 Jan 2016 18:12:54 +0800 Subject: [PATCH] Ruby: fix testing issue of deleting nonexistent pet --- samples/client/petstore/ruby/spec/spec_helper.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb index 26da98f9c42..5eff37b134a 100644 --- a/samples/client/petstore/ruby/spec/spec_helper.rb +++ b/samples/client/petstore/ruby/spec/spec_helper.rb @@ -40,8 +40,13 @@ API_CLIENT = Petstore::ApiClient.new(Petstore::Configuration.new) # always delete and then re-create the pet object with 10002 def prepare_pet(pet_api) - # remove the pet - pet_api.delete_pet(10002) + begin + # remove the pet + pet_api.delete_pet(10002) + rescue Petstore::ApiError => e + # ignore ApiError 404 (Not Found) + raise e if e.code != 404 + end # recreate the pet category = Petstore::Category.new('id' => 20002, 'name' => 'category test') tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test')