Skip to content

Instantly share code, notes, and snippets.

@dimroc
Created December 26, 2014 16:00
Show Gist options
  • Select an option

  • Save dimroc/87dd394b82ed8273044f to your computer and use it in GitHub Desktop.

Select an option

Save dimroc/87dd394b82ed8273044f to your computer and use it in GitHub Desktop.
module Stubs
module S3
def s3_succeeds_to_get_fixture(fixture)
WebMock.stub_request(:get, /https:\/\/s3\.amazonaws\.com\/test\.loopandtie\.com\/csv_imports\/.*#{fixture}/).
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>''}).
to_return(:status => 200, :body => fixture_url(fixture), :headers => {})
end
def s3_succeeds_to_check_files
WebMock.stub_request(:head, /https:\/\/s3\.amazonaws\.com\/test\.loopandtie\.com\/.*/).
to_return(:status => 200, :body => "", :headers => {})
end
def s3_succeeds_to_upload_files
WebMock.stub_request(:put, /https:\/\/s3\.amazonaws\.com\/test\.loopandtie\.com\/.*/).
with(:headers => {'Accept'=>'*/*'}).
to_return(:status => 200, :body => "", :headers => {})
end
end
end
RSpec.configure do |config|
config.include Stubs::S3
end
@dimroc
Copy link
Copy Markdown
Author

dimroc commented Dec 26, 2014

Stubbing S3 with WebMock to return a spec fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment