Sha256: d81d506a0a294ed3e379f88ed25f113853a14445ae03220dd1b60ff212722ae3

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

describe 'Storage.get_object' do
  describe 'success' do

    before(:each) do
      AWS[:storage].put_bucket('foggetobject')
      AWS[:storage].put_object('foggetobject', 'fog_get_object', lorem_file)
    end

    after(:each) do
      AWS[:storage].delete_object('foggetobject', 'fog_get_object')
      AWS[:storage].delete_bucket('foggetobject')
    end

    it 'should return proper attributes' do
      actual = AWS[:storage].get_object('foggetobject', 'fog_get_object')
      actual.status.should == 200
      data = lorem_file.read
      actual.body.should == data
      actual.headers['Content-Length'].should == data.length.to_s
      actual.headers['Content-Type'].should be_a(String)
      actual.headers['ETag'].should be_a(String)
      actual.headers['Last-Modified'].should be_a(String)
    end

    it 'should return chunks with optional block' do
      data = ''
      AWS[:storage].get_object('foggetobject', 'fog_get_object') do |chunk|
        data << chunk
      end
      data.should == lorem_file.read
    end

    it 'should return a signed expiring url' do
      url = AWS[:storage].get_object_url('foggetobject', 'fog_get_object', Time.now + 60 * 10)
      unless Fog.mocking?
        open(url).read.should == lorem_file.read
      end
    end

  end
  describe 'failure' do

    it 'should raise a NotFound error if the bucket does not exist' do
      lambda {
        AWS[:storage].get_object('fognotabucket', 'fog_get_object')
      }.should raise_error(Excon::Errors::NotFound)
    end

    it 'should raise a NotFound error if the object does not exist' do
      lambda {
        AWS[:storage].get_object('foggetobject', 'fog_not_an_object')
      }.should raise_error(Excon::Errors::NotFound)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.3.7 spec/aws/requests/storage/get_object_spec.rb
fog-0.3.6 spec/aws/requests/storage/get_object_spec.rb
fog-0.3.5 spec/aws/requests/s3/get_object_spec.rb
fog-0.3.4 spec/aws/requests/s3/get_object_spec.rb
fog-0.3.3 spec/aws/requests/s3/get_object_spec.rb
fog-0.3.2 spec/aws/requests/s3/get_object_spec.rb
fog-0.3.1 spec/aws/requests/s3/get_object_spec.rb
fog-0.3.0 spec/aws/requests/s3/get_object_spec.rb