Last active
September 24, 2020 12:59
-
-
Save danhodge/38f7bb0f8d883cbe5b58c07863fed918 to your computer and use it in GitHub Desktop.
AWS SDK for Ruby Tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When using stubbed responses & a proc, you must explicitly pass in a proc - the implicit block parameter is ignored | |
# works | |
client.stub_responses(:get_object, proc { |context| { body: StringIO.new("Hi") } }) | |
# does not work | |
client.stub_responses(:get_object) do |context| | |
# will never get here b/c the implicit block parameter is ignored | |
{ body: StringIO.new("HI") } | |
end | |
# pass in an array of responses to stub out consecutive calls | |
client.stub_responses(:get_object, [{ body: StringIO("first") }, { body: StringIO("second") }]) | |
# stubbing responses via Aws.config | |
Aws.config[:s3] = { stub_responses: { put_object: ->(context) { expect(context.params[:bucket]).to eq(exp_bucket) } } } | |
# clearing the stubs | |
Aws.config[:s3] = {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment