Skip to content

Commit

Permalink
DynamoDB simplified attributes now supported via #stub_responses.
Browse files Browse the repository at this point in the history
Fixes #770
  • Loading branch information
trevorrowe committed Jun 5, 2015
1 parent 2f72c00 commit 8db6b36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions aws-sdk-core/lib/aws-sdk-core/dynamodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions aws-sdk-core/spec/aws/dynamodb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8db6b36

Please sign in to comment.