I have some code that uploads a file to Amazon S3, using the aws-sdk
gem. Apparently it does an HTTP put to upload the file.
Is there a good way to mock thi
If you're using version 2 of the aws-sdk gem try adding:
Aws.config.update(stub_responses: true)
to your RSpec.configure
block (usually found in your rails_helper.rb file)
While the above works, it will return empty responses if you don't further specify response content - not necessarily valid, but stubbed.
You can generate and return stubbed response data from a named operation:
s3 = Aws::S3::Client.new
s3.stub_data(:list_buckets)
#=> #>
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'}])
#=> #], owner=#>
For more details refer to: http://docs.aws.amazon.com/sdkforruby/api/Aws/ClientStubs.html