Stubbing calls to AWS in Rails tests

24-Sep-2019 2782
I use aws-sdk gem to deal with file uploads to S3 in my Rails application. I needed to add tests for the account logo upload and removal feature. I use Paperclip gem to do the file uploads.Typically, applications use file storage in test environment to avoid hitting AWS API but in this application I was constrained to not use file storage in test environment.Obviously I did not want to hit the AWS API during tests. I came up with a solution using a technique provided by aws-sdk gem.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle