Giter Club home page Giter Club logo

Comments (4)

jterapin avatar jterapin commented on July 3, 2024 1

Hi! You could do that as follows:

stub_dynamodb_client.stub_responses(
   :get_item,
  [
    { item: {"post_id" => 1 } },
    { item: {"comment_id" => 2 } },
  ],
)

To demostrate via repl:

[13] pry(Aws)> stub_dynamodb_client.get_item(table_name: '', key: {})           
[Aws::DynamoDB::Client 200 0.000822 0 retries] get_item(table_name:"foo",key:{})  
=> #<struct Aws::DynamoDB::Types::GetItemOutput item={"post_id"=>0.1e1}, consumed_capacity=nil>
[14] pry(Aws)> 
[14] pry(Aws)> stub_dynamodb_client.get_item(table_name: '', key: {})           
[Aws::DynamoDB::Client 200 0.000596 0 retries] get_item(table_name:"foo",key:{})  
=> #<struct Aws::DynamoDB::Types::GetItemOutput item={"comment_id"=>0.2e1}, consumed_capacity=nil>

I noticed that the linked docs for V2. Here's a link to V3 incase you are using that version.

The last section in the documentation, noted as "Stubbing Multiple Responses" expands on the multiple stub responses so I suggest checking that out. Hope this helps!

from aws-sdk-ruby.

namdv-1375 avatar namdv-1375 commented on July 3, 2024 1

@jterapin wow, thanks you <3

from aws-sdk-ruby.

github-actions avatar github-actions commented on July 3, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

from aws-sdk-ruby.

mullermp avatar mullermp commented on July 3, 2024

I believe also instead of an array you can pass multiple hash arguments.

from aws-sdk-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.