From a59d4ba346ebf40e46f0661e5a091e231d35ef05 Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 15 Jun 2015 16:51:38 +0800 Subject: [PATCH] Add test case for finding nonexistent pet --- samples/client/petstore/ruby/spec/pet_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb index e05dd726f13..52030b7bf51 100644 --- a/samples/client/petstore/ruby/spec/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/pet_spec.rb @@ -50,6 +50,19 @@ describe "Pet" do pet.category.name.should == "category test" end + it "should not find a pet that does not exist" do + begin + SwaggerClient::PetApi.get_pet_by_id(-1) + fail 'it should raise error' + rescue SwaggerClient::Swagger::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' + end + end + it "should find pets by status" do pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'available') pets.length.should >= 3