1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

cleanup/decouple specs

This commit is contained in:
Wesley Beary 2009-08-19 20:32:57 -07:00
parent 5cdb40d261
commit 09e9315be9
50 changed files with 791 additions and 700 deletions

View file

@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.allocate_address' do
describe 'success'
describe 'success' do
after(:all) do
after(:each) do
ec2.release_address(@public_ip)
end

View file

@ -1,21 +1,23 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.associate_address' do
describe 'success' do
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
@public_ip = ec2.allocate_address.body['publicIp']
end
after(:each) do
ec2.release_address(@public_ip)
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.associate_address(@instance_id, @public_ip)
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
@public_ip = ec2.allocate_address.body['publicIp']
end
after(:all) do
ec2.release_address(@public_ip)
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.associate_address(@instance_id, @public_ip)
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
end

View file

@ -1,32 +1,34 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.attach_volume' do
describe 'success' do
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end
after(:all) do
eventually do
ec2.detach_volume(@volume_id)
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end
eventually do
ec2.delete_volume(@volume_id)
ec2.terminate_instances([@instance_id])
end
end
it "should return proper attributes" do
eventually(128) do
actual = ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
actual.body['attachTime'].should be_a(Time)
actual.body['device'].should be_a(String)
actual.body['instanceId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['status'].should be_a(String)
actual.body['volumeId'].should be_a(String)
after(:each) do
eventually do
ec2.detach_volume(@volume_id)
end
eventually do
ec2.delete_volume(@volume_id)
ec2.terminate_instances([@instance_id])
end
end
end
it "should return proper attributes" do
eventually(128) do
actual = ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
actual.body['attachTime'].should be_a(Time)
actual.body['device'].should be_a(String)
actual.body['instanceId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['status'].should be_a(String)
actual.body['volumeId'].should be_a(String)
end
end
end
end

View file

@ -1,24 +1,26 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.authorize_security_group_ingress' do
describe 'success' do
before(:each) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
after(:each) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes" do
actual = ec2.authorize_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80,
})
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
before(:all) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
after(:all) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes" do
actual = ec2.authorize_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80,
})
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
end

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.create_key_pair' do
describe 'success' do
after(:all) do
after(:each) do
ec2.delete_key_pair('fog_key_pair')
end
@ -18,6 +18,14 @@ describe 'EC2.create_key_pair' do
end
describe 'failure' do
before(:each) do
ec2.create_key_pair('fog_key_pair')
end
after(:each) do
ec2.delete_key_pair('fog_key_pair')
end
it "should raise a BadRequest when the key pair already exists" do
lambda {
ec2.create_key_pair('fog_key_pair')

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.create_security_group' do
describe 'success' do
after(:all) do
after(:each) do
ec2.delete_security_group('fog_security_group')
end
@ -16,6 +16,14 @@ describe 'EC2.create_security_group' do
end
describe 'failure' do
before(:each) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
after(:each) do
ec2.delete_security_group('fog_security_group')
end
it "should raise a BadRequest error when the security group already exists" do
lambda {
ec2.create_security_group('fog_security_group', 'a security group for testing fog')

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.create_snapshot' do
describe "success" do
describe 'success' do
before(:all) do
before(:each) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end
after(:all) do
after(:each) do
ec2.delete_volume(@volume_id)
eventually do
ec2.delete_snapshot(@snapshot_id)
@ -25,7 +25,7 @@ describe 'EC2.create_snapshot' do
end
end
describe "failure" do
describe 'failure' do
it "should raise a BadRequest error if the volume does not exist" do
lambda {

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.create_volume' do
describe 'success' do
after(:all) do
after(:each) do
ec2.delete_volume(@volume_id)
end

View file

@ -3,18 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.delete_key_pair' do
describe 'success' do
before(:all) do
ec2.create_key_pair('fog_key_pair')
before(:each) do
ec2.create_key_pair('fog_key_name')
@response = ec2.delete_key_pair('fog_key_name')
end
it "should return proper attributes" do
actual = ec2.delete_key_pair('fog_key_pair')
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
@response.body['requestId'].should be_a(String)
[false, true].should include(@response.body['return'])
end
it "should not raise an error if the key pair does not exist" do
ec2.delete_key_pair('not_a_key_pair')
ec2.delete_key_pair('not_a_key_name')
end
end

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.delete_security_group' do
describe 'success' do
before(:all) do
before(:each) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end

View file

@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.delete_snapshot' do
describe 'success' do
before(:all) do
before(:each) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
end
after(:all) do
after(:each) do
ec2.delete_volume(@volume_id)
end

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.create_volume' do
describe 'success' do
before(:all) do
before(:each) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end

View file

@ -1,33 +1,38 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_addresses' do
describe 'success' do
before(:each) do
@public_ip = ec2.allocate_address.body['publicIp']
end
after(:each) do
ec2.release_address(@public_ip)
end
it "should return proper attributes with no params" do
actual = ec2.describe_addresses
actual.body['requestId'].should be_a(String)
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
item.should_not be_nil
end
it "should return proper attributes for specific ip" do
actual = ec2.describe_addresses(@public_ip)
actual.body['requestId'].should be_a(String)
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
item.should_not be_nil
end
before(:all) do
@public_ip = ec2.allocate_address.body['publicIp']
end
describe 'failure' do
it "should raise a BadRequest error if ip does not exist" do
lambda {
ec2.describe_addresses('127.0.0.1')
}.should raise_error(Fog::Errors::BadRequest)
end
after(:all) do
ec2.release_address(@public_ip)
end
it "should return proper attributes with no params" do
actual = ec2.describe_addresses
actual.body['requestId'].should be_a(String)
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
item.should_not be_nil
end
it "should return proper attributes for specific ip" do
actual = ec2.describe_addresses(@public_ip)
actual.body['requestId'].should be_a(String)
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
item.should_not be_nil
end
it "should raise a BadRequest error if ip does not exist" do
lambda {
ec2.describe_addresses('127.0.0.1')
}.should raise_error(Fog::Errors::BadRequest)
end
end

View file

@ -1,21 +1,23 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_availability_zones' do
describe 'success' do
it "should return proper attributes with no params" do
actual = ec2.describe_availability_zones
zone = actual.body['availabilityZoneInfo'].first
zone['regionName'].should be_a(String)
zone['zoneName'].should be_a(String)
zone['zoneState'].should be_a(String)
end
it "should return proper attribute with params" do
actual = ec2.describe_availability_zones(['us-east-1a'])
zone = actual.body['availabilityZoneInfo'].first
zone['regionName'].should be_a(String)
zone['zoneName'].should be_a(String)
zone['zoneState'].should be_a(String)
end
it "should return proper attributes with no params" do
actual = ec2.describe_availability_zones
zone = actual.body['availabilityZoneInfo'].first
zone['regionName'].should be_a(String)
zone['zoneName'].should be_a(String)
zone['zoneState'].should be_a(String)
end
it "should return proper attribute with params" do
actual = ec2.describe_availability_zones(['us-east-1a'])
zone = actual.body['availabilityZoneInfo'].first
zone['regionName'].should be_a(String)
zone['zoneName'].should be_a(String)
zone['zoneState'].should be_a(String)
end
end

View file

@ -1,37 +1,39 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_images' do
describe 'success' do
it "should return proper attributes with no params" do
actual = ec2.describe_images
actual.body['requestId'].should be_a(String)
image = actual.body['imagesSet'].first
image['architecture'].should be_a(String)
image['imageId'].should be_a(String)
image['imageLocation'].should be_a(String)
image['imageOwnerId'].should be_a(String)
image['imageState'].should be_a(String)
image['imageType'].should be_a(String)
[false, true].should include(image['isPublic'])
image['kernelId'].should be_a(String) if image['kernelId']
image['platform'].should be_a(String) if image['platform']
image['ramdiskId'].should be_a(String) if image['ramdiskId']
end
it "should return proper attributes with params" do
actual = ec2.describe_images('ImageId' => 'ami-5ee70037')
actual.body['requestId'].should be_a(String)
image = actual.body['imagesSet'].first
image['architecture'].should be_a(String)
image['imageId'].should be_a(String)
image['imageLocation'].should be_a(String)
image['imageOwnerId'].should be_a(String)
image['imageState'].should be_a(String)
image['imageType'].should be_a(String)
[false, true].should include(image['isPublic'])
image['kernelId'].should be_a(String) if image['kernelId']
image['platform'].should be_a(String) if image['platform']
image['ramdiskId'].should be_a(String) if image['ramdiskId']
end
it "should return proper attributes with no params" do
actual = ec2.describe_images
actual.body['requestId'].should be_a(String)
image = actual.body['imagesSet'].first
image['architecture'].should be_a(String)
image['imageId'].should be_a(String)
image['imageLocation'].should be_a(String)
image['imageOwnerId'].should be_a(String)
image['imageState'].should be_a(String)
image['imageType'].should be_a(String)
[false, true].should include(image['isPublic'])
image['kernelId'].should be_a(String) if image['kernelId']
image['platform'].should be_a(String) if image['platform']
image['ramdiskId'].should be_a(String) if image['ramdiskId']
end
it "should return proper attributes with params" do
actual = ec2.describe_images('ImageId' => 'ami-5ee70037')
actual.body['requestId'].should be_a(String)
image = actual.body['imagesSet'].first
image['architecture'].should be_a(String)
image['imageId'].should be_a(String)
image['imageLocation'].should be_a(String)
image['imageOwnerId'].should be_a(String)
image['imageState'].should be_a(String)
image['imageType'].should be_a(String)
[false, true].should include(image['isPublic'])
image['kernelId'].should be_a(String) if image['kernelId']
image['platform'].should be_a(String) if image['platform']
image['ramdiskId'].should be_a(String) if image['ramdiskId']
end
end

View file

@ -1,75 +1,77 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_instances' do
describe 'success' do
before(:each) do
run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
@instance_id = run_instances['instancesSet'].first['instanceId']
@reservation_id = run_instances['reservationId']
end
after(:each) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes with no params" do
actual = ec2.describe_instances
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
reservation['groupSet'].should be_an(Array)
reservation['groupSet'].first.should be_a(String)
reservation['ownerId'].should be_a(String)
reservation['reservationId'].should be_a(String)
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['amiLaunchIndex'].should be_an(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_a(Hash)
instance['instanceState']['code'].should be_a(String)
instance['instanceState']['name'].should be_a(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[true, false].should include(instance['monitoring']['state'])
instance['placement'].should be_an(Array)
instance['placement'].first.should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['productCodes'].should be_an(Array)
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
end
it "should return proper attributes with params" do
actual = ec2.describe_instances(@instance_id)
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
reservation['groupSet'].should be_an(Array)
reservation['groupSet'].first.should be_a(String)
reservation['ownerId'].should be_a(String)
reservation['reservationId'].should be_a(String)
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['amiLaunchIndex'].should be_an(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_a(Hash)
instance['instanceState']['code'].should be_a(String)
instance['instanceState']['name'].should be_a(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[true, false].should include(instance['monitoring']['state'])
instance['placement'].should be_an(Array)
instance['placement'].first.should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['productCodes'].should be_an(Array)
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
end
before(:all) do
run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
@instance_id = run_instances['instancesSet'].first['instanceId']
@reservation_id = run_instances['reservationId']
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes with no params" do
actual = ec2.describe_instances
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
reservation['groupSet'].should be_an(Array)
reservation['groupSet'].first.should be_a(String)
reservation['ownerId'].should be_a(String)
reservation['reservationId'].should be_a(String)
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['amiLaunchIndex'].should be_an(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_a(Hash)
instance['instanceState']['code'].should be_a(String)
instance['instanceState']['name'].should be_a(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[true, false].should include(instance['monitoring']['state'])
instance['placement'].should be_an(Array)
instance['placement'].first.should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['productCodes'].should be_an(Array)
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
end
it "should return proper attributes with params" do
actual = ec2.describe_instances(@instance_id)
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
reservation['groupSet'].should be_an(Array)
reservation['groupSet'].first.should be_a(String)
reservation['ownerId'].should be_a(String)
reservation['reservationId'].should be_a(String)
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['amiLaunchIndex'].should be_an(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_a(Hash)
instance['instanceState']['code'].should be_a(String)
instance['instanceState']['name'].should be_a(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[true, false].should include(instance['monitoring']['state'])
instance['placement'].should be_an(Array)
instance['placement'].first.should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['productCodes'].should be_an(Array)
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
end
end

View file

@ -1,37 +1,42 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_key_pairs' do
describe 'success' do
before(:each) do
ec2.create_key_pair('fog_key_name')
end
after(:each) do
ec2.delete_key_pair('fog_key_name')
end
it "should return proper attributes with no params" do
actual = ec2.describe_key_pairs
actual.body['keySet'].should be_an(Array)
actual.body['requestId'].should be_a(String)
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'fog_key_name' }.first
key_pair['keyFingerprint'].should be_a(String)
key_pair['keyName'].should be_a(String)
end
it "should return proper attributes with params" do
actual = ec2.describe_key_pairs('fog_key_name')
actual.body['keySet'].should be_an(Array)
actual.body['requestId'].should be_a(String)
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'fog_key_name' }.first
key_pair['keyFingerprint'].should be_a(String)
key_pair['keyName'].should be_a(String)
end
before(:all) do
ec2.create_key_pair('key_name')
end
describe 'failure' do
it "should raise a BadRequest error if the key does not exist" do
lambda {
ec2.describe_key_pairs('fog_not_a_key_name')
}.should raise_error(Fog::Errors::BadRequest)
end
after(:all) do
ec2.delete_key_pair('key_name')
end
it "should return proper attributes with no params" do
actual = ec2.describe_key_pairs
actual.body['keySet'].should be_an(Array)
actual.body['requestId'].should be_a(String)
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
key_pair['keyFingerprint'].should be_a(String)
key_pair['keyName'].should be_a(String)
end
it "should return proper attributes with params" do
actual = ec2.describe_key_pairs('key_name')
actual.body['keySet'].should be_an(Array)
actual.body['requestId'].should be_a(String)
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
key_pair['keyFingerprint'].should be_a(String)
key_pair['keyName'].should be_a(String)
end
it "should raise a BadRequest error if the key does not exist" do
lambda {
ec2.describe_key_pairs('not_a_key_name')
}.should raise_error(Fog::Errors::BadRequest)
end
end

View file

@ -1,19 +1,21 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_availability_zones' do
describe 'success' do
it "should return proper attributes with no params" do
actual = ec2.describe_regions
zone = actual.body['regionInfo'].first
zone['regionEndpoint'].should be_a(String)
zone['regionName'].should be_a(String)
end
it "should return proper attribute with params" do
actual = ec2.describe_regions(['us-east-1'])
zone = actual.body['regionInfo'].first
zone['regionEndpoint'].should be_a(String)
zone['regionName'].should be_a(String)
end
it "should return proper attributes with no params" do
actual = ec2.describe_regions
zone = actual.body['regionInfo'].first
zone['regionEndpoint'].should be_a(String)
zone['regionName'].should be_a(String)
end
it "should return proper attribute with params" do
actual = ec2.describe_regions(['us-east-1'])
zone = actual.body['regionInfo'].first
zone['regionEndpoint'].should be_a(String)
zone['regionName'].should be_a(String)
end
end

View file

@ -1,46 +1,51 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_security_groups' do
describe 'success' do
before(:all) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
before(:each) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
after(:all) do
ec2.delete_security_group('fog_security_group')
end
after(:each) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes with no params" do
actual = ec2.describe_security_groups
actual.body['requestId'].should be_a(String)
actual.body['securityGroupInfo'].should be_an(Array)
security_group = actual.body['securityGroupInfo'].select do |security_group|
security_group['groupName'] == 'default'
end.first
security_group['groupDescription'].should be_a(String)
security_group['groupName'].should be_a(String)
security_group['ownerId'].should be_a(String)
security_group['ipPermissions'].should be_an(Array)
it "should return proper attributes with no params" do
actual = ec2.describe_security_groups
actual.body['requestId'].should be_a(String)
actual.body['securityGroupInfo'].should be_an(Array)
security_group = actual.body['securityGroupInfo'].select do |security_group|
security_group['groupName'] == 'default'
end.first
security_group['groupDescription'].should be_a(String)
security_group['groupName'].should be_a(String)
security_group['ownerId'].should be_a(String)
security_group['ipPermissions'].should be_an(Array)
end
it "should return proper attributes with params" do
actual = ec2.describe_security_groups('fog_security_group')
actual.body['requestId'].should be_a(String)
actual.body['securityGroupInfo'].should be_an(Array)
security_group = actual.body['securityGroupInfo'].select do |security_group|
security_group['groupName'] == 'fog_security_group'
end.first
security_group['groupDescription'].should be_a(String)
security_group['groupName'].should be_a(String)
security_group['ownerId'].should be_a(String)
security_group['ipPermissions'].should be_an(Array)
end
end
describe 'failure' do
it "should raise a BadRequest error if the security group does not exist" do
lambda {
ec2.describe_security_groups('not_a_security_group')
}.should raise_error(Fog::Errors::BadRequest)
end
it "should return proper attributes with params" do
actual = ec2.describe_security_groups('fog_security_group')
actual.body['requestId'].should be_a(String)
actual.body['securityGroupInfo'].should be_an(Array)
security_group = actual.body['securityGroupInfo'].select do |security_group|
security_group['groupName'] == 'fog_security_group'
end.first
security_group['groupDescription'].should be_a(String)
security_group['groupName'].should be_a(String)
security_group['ownerId'].should be_a(String)
security_group['ipPermissions'].should be_an(Array)
end
it "should raise a BadRequest error if the security group does not exist" do
lambda {
ec2.describe_security_groups('not_a_security_group')
}.should raise_error(Fog::Errors::BadRequest)
end
end

View file

@ -1,49 +1,54 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_snapshots' do
describe 'success' do
before(:all) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
end
after(:all) do
ec2.delete_volume(@volume_id)
eventually do
ec2.delete_snapshot(@snapshot_id)
before(:each) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
end
end
it "should return proper attributes with no params" do
eventually do
actual = ec2.describe_snapshots
actual.body['snapshotSet'].should be_an(Array)
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
snapshot['progress'].should be_a(String)
snapshot['snapshotId'].should be_a(String)
snapshot['startTime'].should be_a(Time)
snapshot['status'].should be_a(String)
snapshot['volumeId'].should be_a(String)
after(:each) do
ec2.delete_volume(@volume_id)
eventually do
ec2.delete_snapshot(@snapshot_id)
end
end
end
it "should return proper attributes with params" do
eventually do
actual = ec2.describe_snapshots([@snapshot_id])
actual.body['snapshotSet'].should be_an(Array)
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
snapshot['progress'].should be_a(String)
snapshot['snapshotId'].should be_a(String)
snapshot['startTime'].should be_a(Time)
snapshot['status'].should be_a(String)
snapshot['volumeId'].should be_a(String)
it "should return proper attributes with no params" do
eventually do
actual = ec2.describe_snapshots
actual.body['snapshotSet'].should be_an(Array)
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
snapshot['progress'].should be_a(String)
snapshot['snapshotId'].should be_a(String)
snapshot['startTime'].should be_a(Time)
snapshot['status'].should be_a(String)
snapshot['volumeId'].should be_a(String)
end
end
end
it "should raise a BadRequest error if the snapshot does not exist" do
lambda {
ec2.describe_snapshots('snap-00000000')
}.should raise_error(Fog::Errors::BadRequest)
end
it "should return proper attributes with params" do
eventually do
actual = ec2.describe_snapshots([@snapshot_id])
actual.body['snapshotSet'].should be_an(Array)
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
snapshot['progress'].should be_a(String)
snapshot['snapshotId'].should be_a(String)
snapshot['startTime'].should be_a(Time)
snapshot['status'].should be_a(String)
snapshot['volumeId'].should be_a(String)
end
end
end
describe 'failure' do
it "should raise a BadRequest error if the snapshot does not exist" do
lambda {
ec2.describe_snapshots('snap-00000000')
}.should raise_error(Fog::Errors::BadRequest)
end
end
end

View file

@ -1,45 +1,50 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_volumes' do
describe 'success' do
before(:each) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end
after(:each) do
ec2.delete_volume(@volume_id)
end
it "should return proper attributes with no params" do
actual = ec2.describe_volumes
actual.body['requestId'].should be_a(String)
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
volume['availabilityZone'].should be_a(String)
volume['createTime'].should be_a(Time)
volume['size'].should == 1
volume['snapshotId'].should == ''
volume['status'].should be_a(String)
volume['volumeId'].should == @volume_id
volume['attachmentSet'].should == []
end
it "should return proper attributes for specific volume" do
actual = ec2.describe_volumes(@volume_id)
actual.body['requestId'].should be_a(String)
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
volume['availabilityZone'].should be_a(String)
volume['createTime'].should be_a(Time)
volume['size'].should == 1
volume['snapshotId'].should == ''
volume['status'].should be_a(String)
volume['volumeId'].should == @volume_id
volume['attachmentSet'].should == []
end
before(:all) do
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
end
describe 'failure' do
it "should raise a BadRequest error if volume does not exist" do
lambda {
ec2.describe_volumes('vol-00000000')
}.should raise_error(Fog::Errors::BadRequest)
end
after(:all) do
ec2.delete_volume(@volume_id)
end
it "should return proper attributes with no params" do
actual = ec2.describe_volumes
actual.body['requestId'].should be_a(String)
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
volume['availabilityZone'].should be_a(String)
volume['createTime'].should be_a(Time)
volume['size'].should == 1
volume['snapshotId'].should == ''
volume['status'].should be_a(String)
volume['volumeId'].should == @volume_id
volume['attachmentSet'].should == []
end
it "should return proper attributes for specific volume" do
actual = ec2.describe_volumes(@volume_id)
actual.body['requestId'].should be_a(String)
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
volume['availabilityZone'].should be_a(String)
volume['createTime'].should be_a(Time)
volume['size'].should == 1
volume['snapshotId'].should == ''
volume['status'].should be_a(String)
volume['volumeId'].should == @volume_id
volume['attachmentSet'].should == []
end
it "should raise a BadRequest error if volume does not exist" do
lambda {
ec2.describe_volumes('vol-00000000')
}.should raise_error(Fog::Errors::BadRequest)
end
end

View file

@ -1,32 +1,34 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.detach_volume' do
describe 'success' do
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
eventually(128) do
ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
eventually(128) do
ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
end
end
end
after(:all) do
eventually do
ec2.delete_volume(@volume_id)
ec2.terminate_instances([@instance_id])
after(:each) do
eventually do
ec2.delete_volume(@volume_id)
ec2.terminate_instances([@instance_id])
end
end
end
it "should return proper attributes" do
eventually do
actual = ec2.detach_volume(@volume_id)
actual.body['attachTime'].should be_a(Time)
actual.body['device'].should be_a(String)
actual.body['instanceId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['status'].should be_a(String)
actual.body['volumeId'].should be_a(String)
it "should return proper attributes" do
eventually do
actual = ec2.detach_volume(@volume_id)
actual.body['attachTime'].should be_a(Time)
actual.body['device'].should be_a(String)
actual.body['instanceId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['status'].should be_a(String)
actual.body['volumeId'].should be_a(String)
end
end
end
end
end

View file

@ -1,22 +1,24 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.disassociate_address' do
describe 'success' do
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
@public_ip = ec2.allocate_address.body['publicIp']
ec2.associate_address(@instance_id, @public_ip)
end
after(:each) do
ec2.release_address(@public_ip)
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.disassociate_address(@public_ip)
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
@public_ip = ec2.allocate_address.body['publicIp']
ec2.associate_address(@instance_id, @public_ip)
end
after(:all) do
ec2.release_address(@public_ip)
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.disassociate_address(@public_ip)
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
end

View file

@ -1,21 +1,23 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.get_console_output' do
describe 'success' do
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
after(:each) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.get_console_output(@instance_id)
actual.body['instanceId'].should be_a(String)
actual.body['output'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['timestamp'].should be_a(Time)
end
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.get_console_output(@instance_id)
actual.body['instanceId'].should be_a(String)
actual.body['output'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['timestamp'].should be_a(Time)
end
end

View file

@ -1,19 +1,21 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.reboot_instances' do
describe 'success' do
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
after(:each) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.reboot_instances([@instance_id])
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.reboot_instances([@instance_id])
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
end

View file

@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.release_address' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
@public_ip = ec2.allocate_address.body['publicIp']
end
@ -14,7 +14,7 @@ describe 'EC2.release_address' do
end
end
describe 'failure'
describe 'failure' do
it "should raise a BadRequest error if address does not exist" do
lambda {

View file

@ -1,30 +1,32 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.revoke_security_group_ingress' do
describe 'success' do
before(:each) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
ec2.authorize_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80
})
end
after(:each) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes" do
actual = ec2.revoke_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80
})
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
before(:all) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
ec2.authorize_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80
})
end
after(:all) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes" do
actual = ec2.revoke_security_group_ingress({
'FromPort' => 80,
'GroupName' => 'fog_security_group',
'IpProtocol' => 'tcp',
'ToPort' => 80
})
actual.body['requestId'].should be_a(String)
[false, true].should include(actual.body['return'])
end
end

View file

@ -1,39 +1,41 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.run_instances' do
describe 'success' do
after(:each) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.run_instances('ami-5ee70037', 1, 1)
@instance_id = actual.body['instancesSet'].first['instanceId']
actual.body['groupSet'].should be_an(Array)
actual.body['groupSet'].first.should be_a(String)
actual.body['instancesSet'].should be_an(Array)
instance = actual.body['instancesSet'].first
instance['amiLaunchIndex'].should be_a(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_an(Hash)
instance['instanceState']['code'].should be_an(Integer)
instance['instanceState']['name'].should be_an(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[false, true].should include(instance['monitoring']['state'])
instance['placement'].should be_a(Hash)
instance['placement']['availabilityZone'].should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
actual.body['ownerId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['reservationId'].should be_a(String)
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.run_instances('ami-5ee70037', 1, 1)
@instance_id = actual.body['instancesSet'].first['instanceId']
actual.body['groupSet'].should be_an(Array)
actual.body['groupSet'].first.should be_a(String)
actual.body['instancesSet'].should be_an(Array)
instance = actual.body['instancesSet'].first
instance['amiLaunchIndex'].should be_a(Integer)
instance['dnsName'].should be_a(String)
instance['imageId'].should be_a(String)
instance['instanceId'].should be_a(String)
instance['instanceState'].should be_an(Hash)
instance['instanceState']['code'].should be_an(Integer)
instance['instanceState']['name'].should be_an(String)
instance['instanceType'].should be_a(String)
instance['kernelId'].should be_a(String)
instance['keyName'].should be_a(String) if instance['keyName']
instance['launchTime'].should be_a(Time)
instance['monitoring'].should be_a(Hash)
[false, true].should include(instance['monitoring']['state'])
instance['placement'].should be_a(Hash)
instance['placement']['availabilityZone'].should be_a(String)
instance['privateDnsName'].should be_a(String)
instance['ramdiskId'].should be_a(String)
instance['reason'].should be_a(String)
actual.body['ownerId'].should be_a(String)
actual.body['requestId'].should be_a(String)
actual.body['reservationId'].should be_a(String)
end
end

View file

@ -1,24 +1,26 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.terminate_instances' do
describe 'success' do
before(:each) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
it "should return proper attributes" do
actual = ec2.terminate_instances([@instance_id])
actual.body['requestId'].should be_a(String)
actual.body['instancesSet'].should be_an(Array)
instance = actual.body['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['previousState'].should be_a(Hash)
previous_state = instance['previousState']
previous_state['code'].should be_a(Integer)
previous_state['name'].should be_a(String)
instance['shutdownState'].should be_a(Hash)
shutdown_state = instance['shutdownState']
shutdown_state['code'].should be_a(Integer)
shutdown_state['name'].should be_a(String)
end
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
end
it "should return proper attributes" do
actual = ec2.terminate_instances([@instance_id])
actual.body['requestId'].should be_a(String)
actual.body['instancesSet'].should be_an(Array)
instance = actual.body['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
instance['previousState'].should be_a(Hash)
previous_state = instance['previousState']
previous_state['code'].should be_a(Integer)
previous_state['name'].should be_a(String)
instance['shutdownState'].should be_a(Hash)
shutdown_state = instance['shutdownState']
shutdown_state['code'].should be_a(Integer)
shutdown_state['name'].should be_a(String)
end
end

View file

@ -3,14 +3,14 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.copy_object' do
describe 'success' do
before(:all) 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_bucket('fogcopyobjectdestination')
end
after(:all) do
after(:each) do
s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
s3.delete_bucket('fogcopyobjectdestination')
s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source')

View file

@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.delete_bucket' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('fogdeletebucket')
end
@ -13,7 +13,7 @@ describe 'S3.delete_bucket' do
end
end
describe 'failure'
describe 'failure' do
it 'should raise a NotFound error if the bucket does not exist' do
lambda {

View file

@ -1,15 +1,15 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.delete_object' do
describe 'success'
describe 'success' do
before(:all) 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)
end
after(:all) do
after(:each) do
s3.delete_bucket('fogdeleteobject')
end
@ -19,16 +19,18 @@ describe 'S3.delete_object' do
end
end
describe 'failure'
describe 'failure' do
it 'should raise NotFound error if the bucket does not exist' do
it 'should raise a NotFound error if the bucket does not exist' do
lambda {
s3.delete_object('fognotabucket', 'fog_delete_object')
}.should raise_error(Fog::Errors::NotFound)
end
it 'should not raise an error if the object does not exist' do
s3.put_bucket('fogdeleteobject')
s3.delete_object('fogdeleteobject', 'fog_not_an_object')
s3.delete_bucket('fogdeleteobject')
end
end

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.get_bucket_location' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
end
after(:all) do
after(:each) do
eu_s3.delete_bucket('foggetlocation')
end
@ -18,7 +18,7 @@ describe 'S3.get_bucket_location' do
end
end
describe 'failure'
describe 'failure' do
it 'should raise NotFound error if bucket does not exist' do
lambda {

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.get_bucket' do
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('foggetbucket')
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
s3.put_object('foggetbucket', 'fog_object', file)
@ -11,7 +11,7 @@ describe 'S3.get_bucket' do
s3.put_object('foggetbucket', 'fog_other_object', file)
end
after(:all) do
after(:each) do
s3.delete_object('foggetbucket', 'fog_object')
s3.delete_object('foggetbucket', 'fog_other_object')
s3.delete_bucket('foggetbucket')

View file

@ -1,15 +1,15 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.get_object' do
describe 'success'
describe 'success' do
before(:all) 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)
end
after(:all) do
after(:each) do
s3.delete_object('foggetobject', 'fog_get_object')
s3.delete_bucket('foggetobject')
end

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.get_request_payment' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('foggetrequestpayment')
end
after(:all) do
after(:each) do
s3.delete_bucket('foggetrequestpayment')
end
@ -18,7 +18,7 @@ describe 'S3.get_request_payment' do
end
end
describe 'failure'
describe 'failure' do
it 'should raise a NotFound error if the bucket does not exist' do
lambda {

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.get_service' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('foggetservice')
end
after(:all) do
after(:each) do
s3.delete_bucket('foggetservice')
end

View file

@ -3,13 +3,13 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.head_object' do
describe 'success' do
before(:all) 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)
end
after(:all) do
after(:each) do
s3.delete_object('fogheadobject', 'fog_head_object')
s3.delete_bucket('fogheadobject')
end

View file

@ -1,15 +1,14 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.put_bucket' do
describe 'success'
describe 'success' do
after(:all) do
s3.delete_bucket('fogputbucket')
before(:each) do
@response = s3.put_bucket('fogputbucket')
end
it 'should return proper attributes' do
actual = s3.put_bucket('fogputbucket')
actual.status.should == 200
after(:each) do
s3.delete_bucket('fogputbucket')
end
it 'should not raise an error if the bucket already exists' do

View file

@ -1,28 +1,21 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.put_object' do
describe 'success'
describe 'success' do
before(:all) 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)
end
after(:all) do
after(:each) do
s3.delete_object('fogputobject', 'fog_put_object')
s3.delete_bucket('fogputobject')
end
it 'should return proper attributes' do
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
actual = s3.put_object('fogputobject', 'fog_put_object', file)
actual.status.should == 200
end
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)
@response.status.should == 200
end
it 'should not raise an error if the object already exists' do
@ -32,4 +25,14 @@ describe 'S3.put_object' do
end
end
describe 'failure' 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)
}.should raise_error(Fog::Errors::NotFound)
end
end
end

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'S3.put_request_payment' do
describe 'success'
describe 'success' do
before(:all) do
before(:each) do
s3.put_bucket('fogputrequestpayment')
end
after(:all) do
after(:each) do
s3.delete_bucket('fogputrequestpayment')
end

View file

@ -1,20 +1,22 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.batch_put_attributes' do
describe 'success' do
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
end

View file

@ -1,19 +1,21 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.create_domain' do
describe 'success' do
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
after(:each) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.create_domain(@domain_name)
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.create_domain(@domain_name)
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
end

View file

@ -1,20 +1,22 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.delete_attributes' do
describe 'success' do
before(:each) do
sdb.create_domain('delete_attributes')
sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz })
end
after(:each) do
sdb.delete_domain('delete_attributes')
end
it 'should return proper attributes from delete_attributes' do
actual = sdb.delete_attributes('delete_attributes', 'foo')
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
before(:all) do
sdb.create_domain('delete_attributes')
sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz })
end
after(:all) do
sdb.delete_domain('delete_attributes')
end
it 'should return proper attributes from delete_attributes' do
actual = sdb.delete_attributes('delete_attributes', 'foo')
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
end

View file

@ -1,19 +1,21 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.delete_domain' do
describe 'success' do
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
before(:each) do
sdb.create_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.delete_domain(@domain_name)
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
before(:all) do
sdb.create_domain(@domain_name)
end
it 'should return proper attributes' do
actual = sdb.delete_domain(@domain_name)
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
end

View file

@ -1,41 +1,43 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.domain_metadata' do
describe 'success' do
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:each) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes when there are no items' do
results = sdb.domain_metadata(@domain_name)
results.body['AttributeNameCount'].should == 0
results.body['AttributeNamesSizeBytes'].should == 0
results.body['AttributeValueCount'].should == 0
results.body['AttributeValuesSizeBytes'].should == 0
results.body['BoxUsage'].should be_a(Float)
results.body['ItemCount'].should == 0
results.body['ItemNamesSizeBytes'].should == 0
results.body['RequestId'].should be_a(String)
results.body['Timestamp'].should be_a(Time)
end
it 'should return proper attributes with items' do
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
results = sdb.domain_metadata(@domain_name)
results.body['AttributeNameCount'].should == 1
results.body['AttributeNamesSizeBytes'].should == 3
results.body['AttributeValueCount'].should == 1
results.body['AttributeValuesSizeBytes'].should == 3
results.body['BoxUsage'].should be_a(Float)
results.body['ItemCount'].should == 1
results.body['ItemNamesSizeBytes'].should == 3
results.body['RequestId'].should be_a(String)
results.body['Timestamp'].should be_a(Time)
end
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes when there are no items' do
results = sdb.domain_metadata(@domain_name)
results.body['AttributeNameCount'].should == 0
results.body['AttributeNamesSizeBytes'].should == 0
results.body['AttributeValueCount'].should == 0
results.body['AttributeValuesSizeBytes'].should == 0
results.body['BoxUsage'].should be_a(Float)
results.body['ItemCount'].should == 0
results.body['ItemNamesSizeBytes'].should == 0
results.body['RequestId'].should be_a(String)
results.body['Timestamp'].should be_a(Time)
end
it 'should return proper attributes with items' do
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
results = sdb.domain_metadata(@domain_name)
results.body['AttributeNameCount'].should == 1
results.body['AttributeNamesSizeBytes'].should == 3
results.body['AttributeValueCount'].should == 1
results.body['AttributeValuesSizeBytes'].should == 3
results.body['BoxUsage'].should be_a(Float)
results.body['ItemCount'].should == 1
results.body['ItemNamesSizeBytes'].should == 3
results.body['RequestId'].should be_a(String)
results.body['Timestamp'].should be_a(Time)
end
end

View file

@ -1,29 +1,31 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.get_attributes' do
describe 'success' do
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should have no attributes for foo before put_attributes' do
eventually do
actual = sdb.get_attributes(@domain_name, 'foo')
actual.body['Attributes'].should be_empty
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
end
it 'should have attributes for foo after put_attributes' do
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
eventually do
actual = sdb.get_attributes(@domain_name, 'foo')
actual.body['Attributes'].should == { 'bar' => ['baz'] }
after(:each) do
sdb.delete_domain(@domain_name)
end
end
it 'should have no attributes for foo before put_attributes' do
eventually do
actual = sdb.get_attributes(@domain_name, 'foo')
actual.body['Attributes'].should be_empty
end
end
it 'should have attributes for foo after put_attributes' do
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
eventually do
actual = sdb.get_attributes(@domain_name, 'foo')
actual.body['Attributes'].should == { 'bar' => ['baz'] }
end
end
end
end

View file

@ -1,28 +1,30 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.list_domains' do
describe 'success' do
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
results = sdb.list_domains
results.body['BoxUsage'].should be_a(Float)
results.body['Domains'].should be_an(Array)
results.body['RequestId'].should be_a(String)
end
it 'should include created domains' do
sdb.create_domain(@domain_name)
eventually do
actual = sdb.list_domains
actual.body['Domains'].should include(@domain_name)
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
end
end
after(:each) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes' do
results = sdb.list_domains
results.body['BoxUsage'].should be_a(Float)
results.body['Domains'].should be_an(Array)
results.body['RequestId'].should be_a(String)
end
it 'should include created domains' do
sdb.create_domain(@domain_name)
eventually do
actual = sdb.list_domains
actual.body['Domains'].should include(@domain_name)
end
end
end
end

View file

@ -1,20 +1,22 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.put_attributes' do
describe 'success' do
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:each) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes from put_attributes' do
actual = sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
before(:all) do
@domain_name = "fog_domain_#{Time.now.to_i}"
sdb.create_domain(@domain_name)
end
after(:all) do
sdb.delete_domain(@domain_name)
end
it 'should return proper attributes from put_attributes' do
actual = sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
end

View file

@ -1,7 +1,9 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.select' do
describe 'success' do
it "should have some specs"
it "should have some specs"
end
end