Sha256: 9a7361dbf6b0259424965fd7bf138ae66153c87c2d2286a23bc1d307e0730d89

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe Hillary::Slug::Bucket do
  around(:each) do |example|
    Fog.mock!
    example.run
    Fog.unmock!
  end

  let(:access_key){'public'}
  let(:secret_key){'secret'}
  let(:storage){Fog::Storage.new(provider: 'AWS', aws_access_key_id: access_key, aws_secret_access_key: secret_key)}
  let(:bucket_name){'slugbucket'}
  let(:bucket){storage.directories.get(bucket_name)}
  let(:slug_name){'g3_slug_RC2014_01_01_01_01_01.tar.gz'}
  let(:canonical_slug_name){'g3_slug_b26206aaf36207304d4fa583ce9837d0bdb48966.tar.gz'}
  let(:slug_path){'rc/' + slug_name}
  let(:canonical_slug_path){'dev/' + canonical_slug_name}
  let(:slug){bucket.files.get(slug_name)}
  let(:canonical_slug){bucket.files.get(canonical_slug_name)}
  let(:slug_file){Tempfile.new(slug_name)}
  let(:slug_file_path){slug_file.path}

  before(:each){storage.directories.create(key: bucket_name)}

  subject{Hillary::Slug::Bucket.new(bucket_name, access_key, secret_key)}

  describe '#write' do
    it 'writes the file to the bucket with the given name' do
      subject.write(canonical_slug_path, slug_file_path)
      expect(bucket.files.get(canonical_slug_path).body).to eq('')
    end
  end

  describe '#copy' do
    it 'copies the specified file to the specified location' do
      subject.write(canonical_slug_path, slug_file_path)
      subject.copy(canonical_slug_path, slug_path)

      expect(bucket.files.get(slug_path))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hillary-0.0.3 spec/hillary/slug/bucket_spec.rb
hillary-0.0.2 spec/hillary/slug/bucket_spec.rb
hillary-0.0.1 spec/hillary/slug/bucket_spec.rb