diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-11 00:31:50 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-11 00:31:50 -0700 |
| commit | d569fbe03f0431da241c3765ce383bc2bde74b95 (patch) | |
| tree | 6e36870319e1fd3713785221293f64eefb4c6e47 /spec/services | |
| parent | 02869327553106ca8ee3732f586d670c3a09af3a (diff) | |
run blob storage specs if key specified.
Diffstat (limited to 'spec/services')
| -rw-r--r-- | spec/services/infrastructure/blob_storage_spec.rb | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/spec/services/infrastructure/blob_storage_spec.rb b/spec/services/infrastructure/blob_storage_spec.rb index 82d462c6..e9f0f3e8 100644 --- a/spec/services/infrastructure/blob_storage_spec.rb +++ b/spec/services/infrastructure/blob_storage_spec.rb @@ -1,31 +1,34 @@ require "rails_helper" -describe BlobStorage do - let(:bucket) { ENV['FOG_DIRECTORY'] } - subject { BlobStorage.new } +if ENV['AWS_SECRET_ACCESS_KEY'].present? + describe BlobStorage do + let(:bucket) { ENV['FOG_DIRECTORY'] } + subject { BlobStorage.new } - let(:file) { File.join(Rails.root, 'spec/fixtures/images/gorilla.jpg') } + let(:file) { File.join(Rails.root, 'spec/fixtures/images/gorilla.jpg') } - context "when uploading" do - it "uploads to s3" do - key = "test#{SecureRandom.uuid}" - subject.upload(key, file) + context "when uploading" do + let(:key) { "test#{SecureRandom.uuid}" } - object = AWS::S3.new.buckets[bucket].objects[key] - expect(object.exists?).to be_truthy + it "uploads to s3" do + subject.upload(key, file) + + object = AWS::S3.new.buckets[bucket].objects[key] + expect(object.exists?).to be_truthy + end end - end - describe "#download" do - let(:key) { "test/upload/#{SecureRandom.uuid}" } + describe "#download" do + let(:key) { "test/upload/#{SecureRandom.uuid}" } - it 'downloads a file from blob storage' do - subject.upload(key, file) + it 'downloads a file from blob storage' do + subject.upload(key, file) - sha = subject.download(key) do |temp_file| - Digest::SHA256.file(temp_file.path).hexdigest + sha = subject.download(key) do |temp_file| + Digest::SHA256.file(temp_file.path).hexdigest + end + expect(sha).to eql(Digest::SHA256.file(file).hexdigest) end - expect(sha).to eql(Digest::SHA256.file(file).hexdigest) end end end |
