mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
move File.open(lorem) into spec_helper to DRY
This commit is contained in:
parent
9eaf469e99
commit
d220e9029b
8 changed files with 18 additions and 28 deletions
|
@ -5,8 +5,7 @@ describe 'S3.copy_object' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('fogcopyobjectsource')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file)
|
||||
s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', lorem_file)
|
||||
s3.put_bucket('fogcopyobjectdestination')
|
||||
end
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ describe 'S3.delete_bucket' do
|
|||
|
||||
it 'should raise a Conflict error if the bucket is not empty' do
|
||||
s3.put_bucket('fogdeletebucket')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('fogdeletebucket', 'fog_delete_object', file)
|
||||
s3.put_object('fogdeletebucket', 'fog_delete_object', lorem_file)
|
||||
lambda {
|
||||
s3.delete_bucket('fogdeletebucket')
|
||||
}.should raise_error(Excon::Errors::Conflict)
|
||||
|
|
|
@ -5,8 +5,7 @@ describe 'S3.delete_object' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('fogdeleteobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('fogdeleteobject', 'fog_delete_object', file)
|
||||
s3.put_object('fogdeleteobject', 'fog_delete_object', lorem_file)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
|
@ -5,10 +5,8 @@ describe 'S3.get_bucket' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('foggetbucket')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('foggetbucket', 'fog_object', file)
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('foggetbucket', 'fog_other_object', file)
|
||||
s3.put_object('foggetbucket', 'fog_object', lorem_file)
|
||||
s3.put_object('foggetbucket', 'fog_other_object', lorem_file)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
|
@ -5,8 +5,7 @@ describe 'S3.get_object' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('foggetobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('foggetobject', 'fog_get_object', file)
|
||||
s3.put_object('foggetobject', 'fog_get_object', lorem_file)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
@ -17,8 +16,7 @@ describe 'S3.get_object' do
|
|||
it 'should return proper attributes' do
|
||||
actual = s3.get_object('foggetobject', 'fog_get_object')
|
||||
actual.status.should == 200
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
data = file.read
|
||||
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)
|
||||
|
@ -27,19 +25,17 @@ describe 'S3.get_object' do
|
|||
end
|
||||
|
||||
it 'should return chunks with optional block' do
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
data = ''
|
||||
s3.get_object('foggetobject', 'fog_get_object') do |chunk|
|
||||
data << chunk
|
||||
end
|
||||
data.should == file.read
|
||||
data.should == lorem_file.read
|
||||
end
|
||||
|
||||
it 'should return a signed expiring url' do
|
||||
url = s3.get_object_url('foggetobject', 'fog_get_object', Time.now + 60 * 10)
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
unless Fog.mocking?
|
||||
open(url).read.should == file.read
|
||||
open(url).read.should == lorem_file.read
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@ describe 'S3.head_object' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('fogheadobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('fogheadobject', 'fog_head_object', file)
|
||||
s3.put_object('fogheadobject', 'fog_head_object', lorem_file)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
@ -17,8 +16,7 @@ describe 'S3.head_object' do
|
|||
it 'should return proper attributes' do
|
||||
actual = s3.head_object('fogheadobject', 'fog_head_object')
|
||||
actual.status.should == 200
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
data = file.read
|
||||
data = lorem_file.read
|
||||
actual.headers['Content-Length'].should == data.length.to_s
|
||||
actual.headers['ETag'].should be_a(String)
|
||||
actual.headers['Last-Modified'].should be_a(String)
|
||||
|
|
|
@ -5,8 +5,7 @@ describe 'S3.put_object' do
|
|||
|
||||
before(:each) do
|
||||
s3.put_bucket('fogputobject')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
@response = s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
@response = s3.put_object('fogputobject', 'fog_put_object', lorem_file)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
@ -19,8 +18,7 @@ describe 'S3.put_object' do
|
|||
end
|
||||
|
||||
it 'should not raise an error if the object already exists' do
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
actual = s3.put_object('fogputobject', 'fog_put_object', file)
|
||||
actual = s3.put_object('fogputobject', 'fog_put_object', lorem_file)
|
||||
actual.status.should == 200
|
||||
end
|
||||
|
||||
|
@ -29,8 +27,7 @@ describe 'S3.put_object' do
|
|||
|
||||
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)
|
||||
s3.put_object('fognotabucket', 'fog_put_object', lorem_file)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
|
|
|
@ -83,3 +83,7 @@ end
|
|||
unless defined?(GENTOO_AMI)
|
||||
GENTOO_AMI = 'ami-5ee70037'
|
||||
end
|
||||
|
||||
def lorem_file
|
||||
File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
|
||||
end
|
Loading…
Reference in a new issue