2009-06-07 01:37:54 -07:00
|
|
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
|
|
|
|
|
describe 'S3.get_object' do
|
|
|
|
|
2009-06-08 15:49:24 -07:00
|
|
|
before(:all) do
|
2009-08-11 21:40:59 -07:00
|
|
|
@s3 = Fog::AWS::S3.gen
|
2009-08-08 12:31:32 -07:00
|
|
|
@s3.put_bucket('foggetobject')
|
2009-06-08 15:49:24 -07:00
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
|
2009-08-08 12:31:32 -07:00
|
|
|
@s3.put_object('foggetobject', 'fog_get_object', file)
|
2009-06-08 15:49:24 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:all) do
|
2009-08-08 12:31:32 -07:00
|
|
|
@s3.delete_object('foggetobject', 'fog_get_object')
|
|
|
|
@s3.delete_bucket('foggetobject')
|
2009-06-08 15:49:24 -07:00
|
|
|
end
|
|
|
|
|
2009-06-07 01:37:54 -07:00
|
|
|
it 'should return proper attributes' do
|
2009-08-08 12:31:32 -07:00
|
|
|
actual = @s3.get_object('foggetobject', 'fog_get_object')
|
2009-06-25 00:32:27 -07:00
|
|
|
actual.status.should == 200
|
2009-06-29 22:23:14 -07:00
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
|
|
|
|
data = file.read
|
|
|
|
actual.body.should == data
|
|
|
|
actual.headers['Content-Length'].should == data.length.to_s
|
|
|
|
actual.headers['ETag'].should be_a(String)
|
|
|
|
actual.headers['Last-Modified'].should be_a(String)
|
2009-06-07 01:37:54 -07:00
|
|
|
end
|
|
|
|
|
2009-08-16 13:31:36 -07:00
|
|
|
it 'should raise a NotFound error if the bucket does not exist' do
|
|
|
|
lambda {
|
|
|
|
@s3.get_object('fognotabucket', 'fog_get_object')
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should raise a NotFound error if the object does not exist' do
|
|
|
|
lambda {
|
|
|
|
@s3.get_object('foggetobject', 'fog_not_an_object')
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
|
|
|
|
2009-06-29 22:23:14 -07:00
|
|
|
end
|