{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/1908","repository_url":"https://api.github.com/repos/aws/aws-sdk-ruby","labels_url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/1908/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/1908/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/1908/events","html_url":"https://github.com/aws/aws-sdk-ruby/issues/1908","id":378498619,"node_id":"MDU6SXNzdWUzNzg0OTg2MTk=","number":1908,"title":"Stubbing multiple responses using Aws.config","user":{"login":"itmart","id":10606050,"node_id":"MDQ6VXNlcjEwNjA2MDUw","avatar_url":"https://avatars0.githubusercontent.com/u/10606050?v=4","gravatar_id":"","url":"https://api.github.com/users/itmart","html_url":"https://github.com/itmart","followers_url":"https://api.github.com/users/itmart/followers","following_url":"https://api.github.com/users/itmart/following{/other_user}","gists_url":"https://api.github.com/users/itmart/gists{/gist_id}","starred_url":"https://api.github.com/users/itmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itmart/subscriptions","organizations_url":"https://api.github.com/users/itmart/orgs","repos_url":"https://api.github.com/users/itmart/repos","events_url":"https://api.github.com/users/itmart/events{/privacy}","received_events_url":"https://api.github.com/users/itmart/received_events","type":"User","site_admin":false},"labels":[{"id":1110554188,"node_id":"MDU6TGFiZWwxMTEwNTU0MTg4","url":"https://api.github.com/repos/aws/aws-sdk-ruby/labels/guidance","name":"guidance","color":"8a19e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-07T22:34:22Z","updated_at":"2018-11-12T19:18:03Z","closed_at":null,"author_association":"NONE","body":"I'm trying to stub multiple responses to simulate a connection error to S3 server. We are using the [retriable gem](https://github.com/kamui/retriable) to try again if an error occurred. I want to stub the `#list_objects` method to raise an `Errno::ECONNREFUSED` exception first, then return a valid file the next time to make sure our app is handling errors properly. However, it seems I got the exception both times in my test. My stub:\r\n```\r\nAws.config[:s3] = {\r\n  stub_responses: {\r\n    list_objects: {\r\n      contents: [Errno::ECONNREFUSED, { key: \"key/aws_file.pdf\" }]\r\n    },\r\n    get_object: [Errno::ECONNREFUSED, file_fixture('aws_file.pdf').read]\r\n  }\r\n}\r\n```\r\n\r\nThe code to download the file from S3 (I want this to fail the first time, then retriable would try again and should work the 2nd time):\r\n```\r\ndef self.download_file(bucket_name, object_key)\r\n  s3 = Aws::S3::Resource.new\r\n  bucket = s3.bucket(bucket_name)\r\n  bucket_objects = bucket.objects.select do |item|\r\n    item.key.start_with? object_key\r\n  end\r\n\r\n  latest_object = bucket_objects.last\r\n  latest_object.presigned_url(:get)\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/comments/437997757","html_url":"https://github.com/aws/aws-sdk-ruby/issues/1908#issuecomment-437997757","issue_url":"https://api.github.com/repos/aws/aws-sdk-ruby/issues/1908","id":437997757,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzk5Nzc1Nw==","user":{"login":"srchase","id":782571,"node_id":"MDQ6VXNlcjc4MjU3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/782571?v=4","gravatar_id":"","url":"https://api.github.com/users/srchase","html_url":"https://github.com/srchase","followers_url":"https://api.github.com/users/srchase/followers","following_url":"https://api.github.com/users/srchase/following{/other_user}","gists_url":"https://api.github.com/users/srchase/gists{/gist_id}","starred_url":"https://api.github.com/users/srchase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srchase/subscriptions","organizations_url":"https://api.github.com/users/srchase/orgs","repos_url":"https://api.github.com/users/srchase/repos","events_url":"https://api.github.com/users/srchase/events{/privacy}","received_events_url":"https://api.github.com/users/srchase/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T19:18:03Z","updated_at":"2018-11-12T19:18:03Z","author_association":"CONTRIBUTOR","body":"@itmart \r\n\r\nRather than define the s3 resource again, can you reuse it?  Or am I misunderstanding where you are having the issue?"}}
{"actor":{"display_login":"srchase"}}