diff --git a/samples/client/petstore/ruby/spec/api_client_spec.rb b/samples/client/petstore/ruby/spec/api_client_spec.rb index aeb4eefad51..347b9876cf7 100644 --- a/samples/client/petstore/ruby/spec/api_client_spec.rb +++ b/samples/client/petstore/ruby/spec/api_client_spec.rb @@ -112,6 +112,24 @@ describe Petstore::ApiClient do end describe "#deserialize" do + it "handles Array" do + api_client = Petstore::ApiClient.new + 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] + end + + it "handles Array>" do + api_client = Petstore::ApiClient.new + 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]] + end + it "handles Hash" do api_client = Petstore::ApiClient.new headers = {'Content-Type' => 'application/json'} @@ -132,6 +150,21 @@ describe Petstore::ApiClient do pet.should be_a(Petstore::Pet) pet.id.should == 1 end + + it "handles Hash>" do + api_client = Petstore::ApiClient.new + 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] + data = result[:data] + data.should be_a(Hash) + data.keys.should == [:pet] + pet = data[:pet] + pet.should be_a(Petstore::Pet) + pet.id.should == 1 + end end describe "#object_to_hash" do