2009-08-17 15:55:30 -07:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2009-06-07 15:42:51 -07:00
|
|
|
|
|
|
|
describe 'S3.put_object' do
|
2009-08-19 20:32:57 -07:00
|
|
|
describe 'success' do
|
2009-06-07 15:42:51 -07:00
|
|
|
|
2009-08-19 20:32:57 -07:00
|
|
|
before(:each) do
|
2009-08-19 19:11:57 -07:00
|
|
|
s3.put_bucket('fogputobject')
|
2009-08-19 20:32:57 -07:00
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
|
|
|
@response = s3.put_object('fogputobject', 'fog_put_object', file)
|
2009-08-19 19:11:57 -07:00
|
|
|
end
|
2009-06-07 15:42:51 -07:00
|
|
|
|
2009-08-19 20:32:57 -07:00
|
|
|
after(:each) do
|
2009-08-19 19:11:57 -07:00
|
|
|
s3.delete_object('fogputobject', 'fog_put_object')
|
|
|
|
s3.delete_bucket('fogputobject')
|
|
|
|
end
|
2009-06-07 15:42:51 -07:00
|
|
|
|
2009-08-19 19:11:57 -07:00
|
|
|
it 'should return proper attributes' do
|
2009-08-19 20:32:57 -07:00
|
|
|
@response.status.should == 200
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not raise an error if the object already exists' do
|
2009-08-19 19:11:57 -07:00
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
|
|
|
actual = s3.put_object('fogputobject', 'fog_put_object', file)
|
|
|
|
actual.status.should == 200
|
|
|
|
end
|
2009-06-07 15:42:51 -07:00
|
|
|
|
2009-08-19 20:32:57 -07:00
|
|
|
end
|
|
|
|
describe 'failure' do
|
|
|
|
|
2009-08-19 19:11:57 -07:00
|
|
|
it 'should raise a NotFound error if the bucket does not exist' do
|
|
|
|
lambda {
|
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
|
|
|
s3.put_object('fognotabucket', 'fog_put_object', file)
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
|
|
|
|
2009-08-16 13:31:36 -07:00
|
|
|
end
|
2009-08-19 19:11:57 -07:00
|
|
|
end
|