amazon-archives/aws-sdk-core-ruby

How to stub content-length of S3 object?

Closed this issue · 1 comments

I want to test that my code fetch the actual size of file from S3, but can't get stubbing right.

I'm trying to stub get_object like this

client = Aws::S3::Client.new(stub_responses: true)
client.stub_responses(:get_object, { content_length: 1024 })
puts client.get_object(bucket: 'bucket', key: 'key').content_length

but I just get empty line in to console. What I'm missing here? I also tested examples of stubbing errors from https://docs.aws.amazon.com/sdkforruby/api/Aws/ClientStubs.html and those works like expected/documented.

Thank you for reporting the issue. I've been able to reproduce this and I have a temporary fix that I will be applying. This will ship with the next patch release of the SDK. I've also opened a new issue here against the master repo:

aws/aws-sdk-ruby#823