mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
more casting/testing
This commit is contained in:
parent
bd7db29ef6
commit
0cbafe1d9e
6 changed files with 41 additions and 14 deletions
|
@ -50,7 +50,7 @@ module Fog
|
|||
break
|
||||
end
|
||||
header = data.split(': ')
|
||||
response.headers[header[0]] = header[1]
|
||||
response.headers[capitalize(header[0])] = header[1]
|
||||
end
|
||||
unless params[:method] == 'HEAD'
|
||||
if response.headers['Content-Length']
|
||||
|
@ -69,6 +69,17 @@ module Fog
|
|||
response
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def capitalize(header)
|
||||
words = header.split('-')
|
||||
header = ''
|
||||
for word in words
|
||||
header << word[0..0].upcase << word[1..-1] << '-'
|
||||
end
|
||||
header.chop!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Response
|
||||
|
|
|
@ -71,21 +71,25 @@ module Fog
|
|||
when 'ID'
|
||||
@object[:owner][:id] = @value
|
||||
when 'IsTruncated'
|
||||
@response[:is_truncated] = @value
|
||||
if @value == 'true'
|
||||
@response[:is_truncated] = true
|
||||
else
|
||||
@response[:is_truncated] = false
|
||||
end
|
||||
when 'Key'
|
||||
@object[:key] = @value
|
||||
when 'LastModified'
|
||||
@object[:last_modified] = @value
|
||||
@object[:last_modified] = Time.parse(@value)
|
||||
when 'Marker'
|
||||
@response[:marker] = @value
|
||||
when 'MaxKeys'
|
||||
@response[:max_keys] = @value
|
||||
@response[:max_keys] = @value.to_i
|
||||
when 'Name'
|
||||
@response[:name] = @value
|
||||
when 'Prefix'
|
||||
@response[:prefix] = @value
|
||||
when 'Size'
|
||||
@object[:size] = @value
|
||||
@object[:size] = @value.to_i
|
||||
when 'StorageClass'
|
||||
@object[:storage_class] = @value
|
||||
end
|
||||
|
|
|
@ -11,10 +11,9 @@ describe 'S3.get_location' do
|
|||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
p 'SHOULD CHECK FOR PROPER ATTRIBUTES'
|
||||
actual = s3.get_bucket_location('foggetlocation')
|
||||
actual.status.should == 200
|
||||
p actual
|
||||
actual.body[:location_constraint].should == 'EU'
|
||||
end
|
||||
|
||||
end
|
|
@ -4,17 +4,31 @@ describe 'S3.get_bucket' do
|
|||
|
||||
before(:all) do
|
||||
s3.put_bucket('foggetbucket')
|
||||
file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
|
||||
s3.put_object('foggetbucket', 'fog_get_bucket', file)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
s3.delete_object('foggetbucket', 'fog_get_bucket')
|
||||
s3.delete_bucket('foggetbucket')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
p 'SHOULD CHECK FOR PROPER ATTRIBUTES'
|
||||
actual = s3.get_bucket('foggetbucket')
|
||||
actual.status.should == 200
|
||||
p actual
|
||||
actual.body[:name].should be_a(String)
|
||||
actual.body[:is_truncated].should == false
|
||||
actual.body[:marker].should be_a(String)
|
||||
actual.body[:max_keys].should be_an(Integer)
|
||||
actual.body[:prefix].should be_a(String)
|
||||
actual.body[:contents].should be_an(Array)
|
||||
object = actual.body[:contents].first
|
||||
object[:key].should == 'fog_get_bucket'
|
||||
object[:last_modified].should be_a(Time)
|
||||
object[:owner][:display_name].should be_a(String)
|
||||
object[:owner][:id].should be_a(String)
|
||||
object[:size].should be_an(Integer)
|
||||
object[:storage_class].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -11,10 +11,9 @@ describe 'S3.get_request_payment' do
|
|||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
p 'SHOULD CHECK FOR PROPER ATTRIBUTES'
|
||||
actual = s3.get_request_payment('foggetrequestpayment')
|
||||
actual.status.should == 200
|
||||
p actual
|
||||
actual.body[:payer].should == 'BucketOwner'
|
||||
end
|
||||
|
||||
end
|
|
@ -13,12 +13,12 @@ describe 'S3.get_service' do
|
|||
it 'should return proper_attributes' do
|
||||
actual = s3.get_service
|
||||
actual.status.should == 200
|
||||
actual.body[:owner][:id].should be_a(String)
|
||||
actual.body[:owner][:display_name].should be_a(String)
|
||||
actual.body[:buckets].should be_a(Array)
|
||||
actual.body[:owner][:id].should be_a(String)
|
||||
actual.body[:buckets].should be_an(Array)
|
||||
bucket = actual.body[:buckets].select {|bucket| bucket[:name] == 'foggetservice'}.first
|
||||
bucket[:name].should be_a(String)
|
||||
bucket[:creation_date].should be_a(Time)
|
||||
bucket[:name].should == 'foggetservice'
|
||||
end
|
||||
|
||||
it 'should include foggetservice in get_service' do
|
||||
|
|
Loading…
Reference in a new issue