From 8db6b36dc9bbfffe4d72bcf44771d26fd839709e Mon Sep 17 00:00:00 2001 From: Trevor Rowe Date: Fri, 5 Jun 2015 13:09:17 -0700 Subject: [PATCH] DynamoDB simplified attributes now supported via #stub_responses. Fixes #770 --- aws-sdk-core/lib/aws-sdk-core/dynamodb.rb | 12 ++++++++++++ aws-sdk-core/spec/aws/dynamodb/client_spec.rb | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/aws-sdk-core/lib/aws-sdk-core/dynamodb.rb b/aws-sdk-core/lib/aws-sdk-core/dynamodb.rb index 6a966cd9582..95a22731494 100644 --- a/aws-sdk-core/lib/aws-sdk-core/dynamodb.rb +++ b/aws-sdk-core/lib/aws-sdk-core/dynamodb.rb @@ -9,5 +9,17 @@ module Aws module DynamoDB autoload :AttributeValue, 'aws-sdk-core/dynamodb/attribute_value' + + class Client + def data_to_http_resp(operation_name, data) + api = config.api + operation = api.operation(operation_name) + translator = Plugins::DynamoDBSimpleAttributes::ValueTranslator + translator = translator.new(operation.output, :marshal) + data = translator.apply(data) + ParamValidator.validate!(operation.output, data) + protocol_helper.stub_data(api, operation, data) + end + end end end diff --git a/aws-sdk-core/spec/aws/dynamodb/client_spec.rb b/aws-sdk-core/spec/aws/dynamodb/client_spec.rb index e6469ddc496..7f034229b81 100644 --- a/aws-sdk-core/spec/aws/dynamodb/client_spec.rb +++ b/aws-sdk-core/spec/aws/dynamodb/client_spec.rb @@ -97,6 +97,17 @@ module DynamoDB end end + + describe '#stub_responses' do + + it 'accepts the simplified attribute format' do + client = Client.new(stub_responses: true) + client.stub_responses(:get_item, item: {'id' => 'value', }) + resp = client.get_item(table_name:'table', key: {'id' => 'value' }) + expect(resp.item).to eq('id' => 'value') + end + + end end end end