If you are using aws-sdk gem version 2, add:
Aws.config.update(stub_responses: true)
into your RSpec.configure block (usually located in the rails_helper.rb file)
While the above works, it will return empty answers if you do not specify additional response content - not necessarily correct, but trimmed.
You can generate and return delayed response data from a 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">>
For more details see: http://docs.aws.amazon.com/sdkforruby/api/Aws/ClientStubs.html
source share