Method: Aws::ClientStubs#stub_data

Defined in:
lib/aws-sdk-core/client_stubs.rb

#stub_data(operation_name, data = {}) ⇒ Structure

Generates and returns stubbed response data from the named operation.

s3 = Aws::S3::Client.new
s3.stub_data(:list_buckets)
#=> #<struct Aws::S3::Types::ListBucketsOutput buckets=[], owner=#<struct Aws::S3::Types::Owner display_name="DisplayName", id="ID">>

In addition to generating default stubs, you can provide data to apply to the response stub.

s3.stub_data(:list_buckets, buckets:[{name:'aws-sdk'}])
#=> #<struct Aws::S3::Types::ListBucketsOutput
  buckets=[#<struct Aws::S3::Types::Bucket name="aws-sdk", creation_date=nil>],
  owner=#<struct Aws::S3::Types::Owner display_name="DisplayName", id="ID">>

Parameters:

  • operation_name (Symbol)
  • data (Hash) (defaults to: {})

Returns:

  • (Structure)

    Returns a stubbed response data structure. The actual class returned will depend on the given ‘operation_name`.



188
189
190
# File 'lib/aws-sdk-core/client_stubs.rb', line 188

def stub_data(operation_name, data = {})
  Stubbing::StubData.new(operation(operation_name)).stub(data)
end