-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add end to end test coverage and main entry point for bucket
Add the end-to-end feature test and document the Gem's configuration and usage. Add main entry point to the buckets and move AWS methods in the correct module
- Loading branch information
Showing
6 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe "Defra Ruby AWS" do | ||
it "Upload a file to an AWS bucket" do | ||
configure_gem | ||
stub_successful_request | ||
|
||
bucket = DefraRuby::Aws.get_bucket("bulk-test") | ||
response = bucket.load(Tempfile.new("test-bucket-load.test")) | ||
|
||
expect(response).to be_successful | ||
end | ||
|
||
it "fails gracefully" do | ||
configure_gem | ||
stub_failing_request | ||
|
||
bucket = DefraRuby::Aws.get_bucket("bulk-test") | ||
response = bucket.load(Tempfile.new("test-bucket-load.test")) | ||
|
||
expect(response).to_not be_successful | ||
expect(response.error).to be_a(Aws::S3::Errors::Forbidden) | ||
end | ||
|
||
def configure_gem | ||
DefraRuby::Aws.configure do |config| | ||
config.buckets = [{ | ||
name: "bulk-test", | ||
credentials: { | ||
access_key_id: "ACCESS_KEY_ID", | ||
secret_access_key: "SECRET_ACCESS_KEY" | ||
} | ||
}] | ||
end | ||
end | ||
|
||
def stub_successful_request | ||
stub_request(:put, /https:\/\/bulk-test\.s3\.eu-west-1\.amazonaws\.com\/test-bucket-load\..+/) | ||
end | ||
|
||
def stub_failing_request | ||
stub_request( | ||
:put, | ||
/https:\/\/bulk-test\.s3\.eu-west-1\.amazonaws\.com\/test-bucket-load\..+/ | ||
).to_return( | ||
status: 403 | ||
) | ||
end | ||
end |
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