diff --git a/lib/fog/aws/ec2.rb b/lib/fog/aws/ec2.rb index 4bc7cf3c9..930b01913 100644 --- a/lib/fog/aws/ec2.rb +++ b/lib/fog/aws/ec2.rb @@ -2,6 +2,15 @@ module Fog module AWS class EC2 + if Fog.mocking? + def self.data + @data + end + def self.reset_data + @data = { :deleted_at => {}, :addresses => {}, :key_pairs => {}, :security_groups => {}, :volumes => {} } + end + end + def self.reload current_directory = File.dirname(__FILE__) load "#{current_directory}/../connection.rb" @@ -72,10 +81,11 @@ module Fog load "#{requests_directory}/run_instances.rb" load "#{requests_directory}/terminate_instances.rb" # TODO: require "#{requests_directory}/unmonitor_instances.rb" - end - if Fog.mocking? - attr_accessor :data + if Fog.mocking? + reset_data + end + end # Initialize connection to EC2 @@ -103,10 +113,6 @@ module Fog @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") - - if Fog.mocking? - @data = { :deleted_at => {}, :addresses => {}, :key_pairs => {}, :security_groups => {}, :volumes => {} } - end end private diff --git a/lib/fog/aws/requests/s3/copy_object.rb b/lib/fog/aws/requests/s3/copy_object.rb index 3f5476e2e..85fad0216 100644 --- a/lib/fog/aws/requests/s3/copy_object.rb +++ b/lib/fog/aws/requests/s3/copy_object.rb @@ -49,9 +49,9 @@ else def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {}) response = Fog::Response.new - source_bucket = @data[:buckets][source_bucket_name] + source_bucket = Fog::AWS::S3.data[:buckets][source_bucket_name] source_object = source_bucket && source_bucket[:objects][source_object_name] - target_bucket = @data[:buckets][target_bucket_name] + target_bucket = Fog::AWS::S3.data[:buckets][target_bucket_name] if source_object && target_bucket response.status = 200 diff --git a/lib/fog/aws/requests/s3/delete_bucket.rb b/lib/fog/aws/requests/s3/delete_bucket.rb index 208d2fc0b..fe2171402 100644 --- a/lib/fog/aws/requests/s3/delete_bucket.rb +++ b/lib/fog/aws/requests/s3/delete_bucket.rb @@ -33,7 +33,7 @@ else def delete_bucket(bucket_name) response = Fog::Response.new - if @data[:buckets].delete(bucket_name) + if Fog::AWS::S3.data[:buckets].delete(bucket_name) response.status = 204 else response.status = 404 diff --git a/lib/fog/aws/requests/s3/delete_object.rb b/lib/fog/aws/requests/s3/delete_object.rb index 3f2d8ffca..3aab8c81b 100644 --- a/lib/fog/aws/requests/s3/delete_object.rb +++ b/lib/fog/aws/requests/s3/delete_object.rb @@ -35,7 +35,7 @@ else def delete_object(bucket_name, object_name) response = Fog::Response.new - if bucket = @data[:buckets][bucket_name] + if bucket = Fog::AWS::S3.data[:buckets][bucket_name] response.status = 204 bucket[:objects].delete(object_name) else diff --git a/lib/fog/aws/requests/s3/get_bucket.rb b/lib/fog/aws/requests/s3/get_bucket.rb index ee773aff8..0a0f2bee7 100644 --- a/lib/fog/aws/requests/s3/get_bucket.rb +++ b/lib/fog/aws/requests/s3/get_bucket.rb @@ -61,7 +61,7 @@ else def get_bucket(bucket_name, options = {}) response = Fog::Response.new - if bucket = @data[:buckets][bucket_name] + if bucket = Fog::AWS::S3.data[:buckets][bucket_name] response.status = 200 response.body = { 'Contents' => bucket[:objects].values.map do |object| diff --git a/lib/fog/aws/requests/s3/get_bucket_location.rb b/lib/fog/aws/requests/s3/get_bucket_location.rb index 3fc348fb6..697f174fb 100644 --- a/lib/fog/aws/requests/s3/get_bucket_location.rb +++ b/lib/fog/aws/requests/s3/get_bucket_location.rb @@ -36,7 +36,7 @@ else def get_bucket_location(bucket_name) response = Fog::Response.new - if bucket = @data[:buckets][bucket_name] + if bucket = Fog::AWS::S3.data[:buckets][bucket_name] response.status = 200 response.body = {'LocationConstraint' => bucket['LocationConstraint'] } else diff --git a/lib/fog/aws/requests/s3/get_object.rb b/lib/fog/aws/requests/s3/get_object.rb index b4f382e09..1d3d172dc 100644 --- a/lib/fog/aws/requests/s3/get_object.rb +++ b/lib/fog/aws/requests/s3/get_object.rb @@ -49,7 +49,7 @@ else def get_object(bucket_name, object_name, options = {}) response = Fog::Response.new - if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) + if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) if options['If-Match'] && options['If-Match'] != object['ETag'] response.status = 412 elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified']) diff --git a/lib/fog/aws/requests/s3/get_request_payment.rb b/lib/fog/aws/requests/s3/get_request_payment.rb index 7733d13d3..5797ac81d 100644 --- a/lib/fog/aws/requests/s3/get_request_payment.rb +++ b/lib/fog/aws/requests/s3/get_request_payment.rb @@ -36,7 +36,7 @@ else def get_request_payment(bucket_name) response = Fog::Response.new - if bucket = @data[:buckets][bucket_name] + if bucket = Fog::AWS::S3.data[:buckets][bucket_name] response.status = 200 response.body = { 'Payer' => bucket['Payer'] } else diff --git a/lib/fog/aws/requests/s3/get_service.rb b/lib/fog/aws/requests/s3/get_service.rb index 90c222041..3d3cdd692 100644 --- a/lib/fog/aws/requests/s3/get_service.rb +++ b/lib/fog/aws/requests/s3/get_service.rb @@ -39,7 +39,7 @@ else def get_service response = Fog::Response.new response.headers['Status'] = 200 - buckets = @data[:buckets].values.map do |bucket| + buckets = Fog::AWS::S3.data[:buckets].values.map do |bucket| bucket.reject do |key, value| !['CreationDate', 'Name'].include?(key) end diff --git a/lib/fog/aws/requests/s3/put_bucket.rb b/lib/fog/aws/requests/s3/put_bucket.rb index 56a343bc9..061d95bc2 100644 --- a/lib/fog/aws/requests/s3/put_bucket.rb +++ b/lib/fog/aws/requests/s3/put_bucket.rb @@ -58,7 +58,7 @@ else else bucket['LocationConstraint'] = '' end - @data[:buckets][bucket_name] = bucket + Fog::AWS::S3.data[:buckets][bucket_name] = bucket response end diff --git a/lib/fog/aws/requests/s3/put_object.rb b/lib/fog/aws/requests/s3/put_object.rb index f3ff2dfaa..d7b05cb6c 100644 --- a/lib/fog/aws/requests/s3/put_object.rb +++ b/lib/fog/aws/requests/s3/put_object.rb @@ -50,7 +50,7 @@ else def put_object(bucket_name, object_name, object, options = {}) file = parse_file(object) response = Fog::Response.new - if (bucket = @data[:buckets][bucket_name]) + if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) response.status = 200 bucket[:objects][object_name] = { :body => file[:body], diff --git a/lib/fog/aws/requests/s3/put_request_payment.rb b/lib/fog/aws/requests/s3/put_request_payment.rb index 759df4d10..939dbb0af 100644 --- a/lib/fog/aws/requests/s3/put_request_payment.rb +++ b/lib/fog/aws/requests/s3/put_request_payment.rb @@ -38,7 +38,7 @@ else def put_request_payment(bucket_name, payer) response = Fog::Response.new - if bucket = @data[:buckets][bucket_name] + if bucket = Fog::AWS::S3.data[:buckets][bucket_name] response.status = 200 bucket['Payer'] = payer else diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index 57e4c56b0..5781c796d 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -2,6 +2,15 @@ module Fog module AWS class S3 + if Fog.mocking? + def self.reset_data + @data = { :buckets => {} } + end + def self.data + @data + end + end + def self.reload current_directory = File.dirname(__FILE__) load "#{current_directory}/../collection.rb" @@ -37,10 +46,10 @@ module Fog load "#{requests_directory}/put_bucket.rb" load "#{requests_directory}/put_object.rb" load "#{requests_directory}/put_request_payment.rb" - end - if Fog.mocking? - attr_accessor :data + if Fog.mocking? + reset_data + end end # Initialize connection to S3 @@ -68,10 +77,6 @@ module Fog @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") - - if Fog.mocking? - @data = { :buckets => {} } - end end private diff --git a/spec/aws/requests/ec2/allocate_address_spec.rb b/spec/aws/requests/ec2/allocate_address_spec.rb index f6b7d1034..3916e94fc 100644 --- a/spec/aws/requests/ec2/allocate_address_spec.rb +++ b/spec/aws/requests/ec2/allocate_address_spec.rb @@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.allocate_address' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - after(:all) do - @ec2.release_address(@public_ip) + ec2.release_address(@public_ip) end it "should return proper attributes" do - actual = @ec2.allocate_address + actual = ec2.allocate_address actual.body['requestId'].should be_a(String) @public_ip = actual.body['publicIp'] actual.body['publicIp'].should be_a(String) diff --git a/spec/aws/requests/ec2/associate_address_spec.rb b/spec/aws/requests/ec2/associate_address_spec.rb index 82bad0c67..2fd7ef3a9 100644 --- a/spec/aws/requests/ec2/associate_address_spec.rb +++ b/spec/aws/requests/ec2/associate_address_spec.rb @@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.associate_address' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] - @public_ip = @ec2.allocate_address.body['publicIp'] + @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]) + 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 = ec2.associate_address(@instance_id, @public_ip) actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) end diff --git a/spec/aws/requests/ec2/attach_volume_spec.rb b/spec/aws/requests/ec2/attach_volume_spec.rb index 9101d7ec0..aa0afee7b 100644 --- a/spec/aws/requests/ec2/attach_volume_spec.rb +++ b/spec/aws/requests/ec2/attach_volume_spec.rb @@ -3,24 +3,23 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.attach_volume' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @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'] + @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) + ec2.detach_volume(@volume_id) end eventually do - @ec2.delete_volume(@volume_id) - @ec2.terminate_instances([@instance_id]) + 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 = 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) diff --git a/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb b/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb index e421ea86d..e9b2fa6ea 100644 --- a/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +++ b/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.authorize_security_group_ingress' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_security_group('fog_security_group', 'a security group for testing fog') + ec2.create_security_group('fog_security_group', 'a security group for testing fog') end after(:all) do - @ec2.delete_security_group('fog_security_group') + ec2.delete_security_group('fog_security_group') end it "should return proper attributes" do - actual = @ec2.authorize_security_group_ingress({ + actual = ec2.authorize_security_group_ingress({ 'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', diff --git a/spec/aws/requests/ec2/create_key_pair_spec.rb b/spec/aws/requests/ec2/create_key_pair_spec.rb index 97783ec63..6684cc353 100644 --- a/spec/aws/requests/ec2/create_key_pair_spec.rb +++ b/spec/aws/requests/ec2/create_key_pair_spec.rb @@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.create_key_pair' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - after(:all) do - @ec2.delete_key_pair('fog_key_pair') + ec2.delete_key_pair('fog_key_pair') end it "should return proper attributes" do - actual = @ec2.create_key_pair('fog_key_pair') + actual = ec2.create_key_pair('fog_key_pair') actual.body['keyFingerprint'].should be_a(String) actual.body['keyMaterial'].should be_a(String) actual.body['keyName'].should be_a(String) @@ -20,7 +16,7 @@ describe 'EC2.create_key_pair' do it "should raise a BadRequest when the key pair already exists" do lambda { - @ec2.create_key_pair('fog_key_pair') + ec2.create_key_pair('fog_key_pair') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/create_security_group_spec.rb b/spec/aws/requests/ec2/create_security_group_spec.rb index ed1b43856..7bc49894e 100644 --- a/spec/aws/requests/ec2/create_security_group_spec.rb +++ b/spec/aws/requests/ec2/create_security_group_spec.rb @@ -2,23 +2,19 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.create_security_group' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - after(:all) do - @ec2.delete_security_group('fog_security_group') + ec2.delete_security_group('fog_security_group') end it "should return proper attributes" do - actual = @ec2.create_security_group('fog_security_group', 'a security group for testing fog') + actual = ec2.create_security_group('fog_security_group', 'a security group for testing fog') actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) 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') + ec2.create_security_group('fog_security_group', 'a security group for testing fog') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/create_snapshot_spec.rb b/spec/aws/requests/ec2/create_snapshot_spec.rb index 695f60ea5..3e78e34d1 100644 --- a/spec/aws/requests/ec2/create_snapshot_spec.rb +++ b/spec/aws/requests/ec2/create_snapshot_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.create_snapshot' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId'] + @volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId'] end after(:all) do - @ec2.delete_volume(@volume_id) + ec2.delete_volume(@volume_id) eventually do - @ec2.delete_snapshot(@snapshot_id) + ec2.delete_snapshot(@snapshot_id) end end it "should return proper attributes" do - actual = @ec2.create_snapshot(@volume_id) + actual = ec2.create_snapshot(@volume_id) actual.body['progress'].should be_a(String) @snapshot_id = actual.body['snapshotId'] actual.body['snapshotId'].should be_a(String) diff --git a/spec/aws/requests/ec2/create_volume_spec.rb b/spec/aws/requests/ec2/create_volume_spec.rb index e4b2cb7ad..f543bbad9 100644 --- a/spec/aws/requests/ec2/create_volume_spec.rb +++ b/spec/aws/requests/ec2/create_volume_spec.rb @@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.create_volume' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - after(:all) do - @ec2.delete_volume(@volume_id) + ec2.delete_volume(@volume_id) end it "should return proper attributes" do - actual = @ec2.create_volume('us-east-1a', 1) + actual = ec2.create_volume('us-east-1a', 1) actual.body['availabilityZone'].should be_a(String) actual.body['createTime'].should be_a(Time) actual.body['requestId'].should be_a(String) diff --git a/spec/aws/requests/ec2/delete_key_pair_spec.rb b/spec/aws/requests/ec2/delete_key_pair_spec.rb index f4b91d8ae..461c96888 100644 --- a/spec/aws/requests/ec2/delete_key_pair_spec.rb +++ b/spec/aws/requests/ec2/delete_key_pair_spec.rb @@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.delete_key_pair' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_key_pair('fog_key_pair') + ec2.create_key_pair('fog_key_pair') end it "should return proper attributes" do - actual = @ec2.delete_key_pair('fog_key_pair') + actual = ec2.delete_key_pair('fog_key_pair') actual.body['requestId'].should be_a(String) [false, true].should include(actual.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_pair') end end diff --git a/spec/aws/requests/ec2/delete_security_group_spec.rb b/spec/aws/requests/ec2/delete_security_group_spec.rb index 5563d1fe4..e1da15417 100644 --- a/spec/aws/requests/ec2/delete_security_group_spec.rb +++ b/spec/aws/requests/ec2/delete_security_group_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.delete_security_group' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_security_group('fog_security_group', 'a security group for testing fog') + ec2.create_security_group('fog_security_group', 'a security group for testing fog') end it "should return proper attributes" do - actual = @ec2.delete_security_group('fog_security_group') + actual = ec2.delete_security_group('fog_security_group') actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) end it "should raise a BadRequest error if the security group does not exist" do lambda { - @ec2.delete_security_group('fog_not_a_security_group') + ec2.delete_security_group('fog_not_a_security_group') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/delete_snapshot_spec.rb b/spec/aws/requests/ec2/delete_snapshot_spec.rb index a46b7637b..2cddfff20 100644 --- a/spec/aws/requests/ec2/delete_snapshot_spec.rb +++ b/spec/aws/requests/ec2/delete_snapshot_spec.rb @@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.delete_snapshot' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId'] - @snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId'] + @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) + ec2.delete_volume(@volume_id) end it "should return proper attributes" do eventually do - actual = @ec2.delete_snapshot(@snapshot_id) + actual = ec2.delete_snapshot(@snapshot_id) unless actual.body.empty? actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) diff --git a/spec/aws/requests/ec2/delete_volume_spec.rb b/spec/aws/requests/ec2/delete_volume_spec.rb index 6b299ef57..690a73921 100644 --- a/spec/aws/requests/ec2/delete_volume_spec.rb +++ b/spec/aws/requests/ec2/delete_volume_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.create_volume' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId'] + @volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId'] end it "should return proper attributes" do - actual = @ec2.delete_volume(@volume_id) + actual = ec2.delete_volume(@volume_id) actual.body['requestId'].should be_a(String) actual.body['return'].should == true end it "should raise a BadRequest error if volume does not exist" do lambda { - @ec2.release_address('vol-00000000') + ec2.release_address('vol-00000000') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/describe_addresses_spec.rb b/spec/aws/requests/ec2/describe_addresses_spec.rb index 6d5ab1360..a9d46292b 100644 --- a/spec/aws/requests/ec2/describe_addresses_spec.rb +++ b/spec/aws/requests/ec2/describe_addresses_spec.rb @@ -3,23 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_addresses' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @public_ip = @ec2.allocate_address.body['publicIp'] + @public_ip = ec2.allocate_address.body['publicIp'] end after(:all) do - @ec2.release_address(@public_ip) + ec2.release_address(@public_ip) end it "should return proper attributes with no params" do - actual = @ec2.describe_addresses + 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 = 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 @@ -27,7 +26,7 @@ describe 'EC2.describe_addresses' do it "should raise a BadRequest error if ip does not exist" do lambda { - @ec2.describe_addresses('127.0.0.1') + ec2.describe_addresses('127.0.0.1') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/describe_availability_zones_spec.rb b/spec/aws/requests/ec2/describe_availability_zones_spec.rb index 1634d7ce9..a928af848 100644 --- a/spec/aws/requests/ec2/describe_availability_zones_spec.rb +++ b/spec/aws/requests/ec2/describe_availability_zones_spec.rb @@ -2,12 +2,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_availability_zones' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - it "should return proper attributes with no params" do - actual = @ec2.describe_availability_zones + actual = ec2.describe_availability_zones zone = actual.body['availabilityZoneInfo'].first zone['regionName'].should be_a(String) zone['zoneName'].should be_a(String) @@ -15,7 +11,7 @@ describe 'EC2.describe_availability_zones' do end it "should return proper attribute with params" do - actual = @ec2.describe_availability_zones(['us-east-1a']) + 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) diff --git a/spec/aws/requests/ec2/describe_images_spec.rb b/spec/aws/requests/ec2/describe_images_spec.rb index 6ef48ede0..a7b3638db 100644 --- a/spec/aws/requests/ec2/describe_images_spec.rb +++ b/spec/aws/requests/ec2/describe_images_spec.rb @@ -2,12 +2,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_images' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - it "should return proper attributes with no params" do - actual = @ec2.describe_images + actual = ec2.describe_images actual.body['requestId'].should be_a(String) image = actual.body['imagesSet'].first image['architecture'].should be_a(String) @@ -23,7 +19,7 @@ describe 'EC2.describe_images' do end it "should return proper attributes with params" do - actual = @ec2.describe_images('ImageId' => 'ami-5ee70037') + 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) diff --git a/spec/aws/requests/ec2/describe_instances_spec.rb b/spec/aws/requests/ec2/describe_instances_spec.rb index 06a6df98d..012043375 100644 --- a/spec/aws/requests/ec2/describe_instances_spec.rb +++ b/spec/aws/requests/ec2/describe_instances_spec.rb @@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_instances' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - run_instances = @ec2.run_instances('ami-5ee70037', 1, 1).body + 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]) + ec2.terminate_instances([@instance_id]) end it "should return proper attributes with no params" do - actual = @ec2.describe_instances + 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) @@ -44,7 +43,7 @@ describe 'EC2.describe_instances' do end it "should return proper attributes with params" do - actual = @ec2.describe_instances(@instance_id) + 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) diff --git a/spec/aws/requests/ec2/describe_key_pairs_spec.rb b/spec/aws/requests/ec2/describe_key_pairs_spec.rb index 84c4613ee..83df2bed1 100644 --- a/spec/aws/requests/ec2/describe_key_pairs_spec.rb +++ b/spec/aws/requests/ec2/describe_key_pairs_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_key_pairs' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_key_pair('key_name') + ec2.create_key_pair('key_name') end after(:all) do - @ec2.delete_key_pair('key_name') + ec2.delete_key_pair('key_name') end it "should return proper attributes with no params" do - actual = @ec2.describe_key_pairs + 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 @@ -21,7 +20,7 @@ describe 'EC2.describe_key_pairs' do end it "should return proper attributes with params" do - actual = @ec2.describe_key_pairs('key_name') + 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 @@ -31,7 +30,7 @@ describe 'EC2.describe_key_pairs' do it "should raise a BadRequest error if the key does not exist" do lambda { - @ec2.describe_key_pairs('not_a_key_name') + ec2.describe_key_pairs('not_a_key_name') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/describe_regions_spec.rb b/spec/aws/requests/ec2/describe_regions_spec.rb index d33a880de..2f13c3bca 100644 --- a/spec/aws/requests/ec2/describe_regions_spec.rb +++ b/spec/aws/requests/ec2/describe_regions_spec.rb @@ -2,19 +2,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_availability_zones' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - it "should return proper attributes with no params" do - actual = @ec2.describe_regions + 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']) + actual = ec2.describe_regions(['us-east-1']) zone = actual.body['regionInfo'].first zone['regionEndpoint'].should be_a(String) zone['regionName'].should be_a(String) diff --git a/spec/aws/requests/ec2/describe_security_groups_spec.rb b/spec/aws/requests/ec2/describe_security_groups_spec.rb index 7a63a9b56..cf3d1f312 100644 --- a/spec/aws/requests/ec2/describe_security_groups_spec.rb +++ b/spec/aws/requests/ec2/describe_security_groups_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_security_groups' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_security_group('fog_security_group', 'a security group for testing fog') + ec2.create_security_group('fog_security_group', 'a security group for testing fog') end after(:all) do - @ec2.delete_security_group('fog_security_group') + ec2.delete_security_group('fog_security_group') end it "should return proper attributes with no params" do - actual = @ec2.describe_security_groups + 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| @@ -26,7 +25,7 @@ describe 'EC2.describe_security_groups' do end it "should return proper attributes with params" do - actual = @ec2.describe_security_groups('fog_security_group') + 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| @@ -40,7 +39,7 @@ describe 'EC2.describe_security_groups' do it "should raise a BadRequest error if the security group does not exist" do lambda { - @ec2.describe_security_groups('not_a_security_group') + ec2.describe_security_groups('not_a_security_group') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/describe_snapshot_spec.rb b/spec/aws/requests/ec2/describe_snapshot_spec.rb index 5671e9b98..7bf5ea623 100644 --- a/spec/aws/requests/ec2/describe_snapshot_spec.rb +++ b/spec/aws/requests/ec2/describe_snapshot_spec.rb @@ -3,21 +3,20 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_snapshots' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId'] - @snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId'] + @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) + ec2.delete_volume(@volume_id) eventually do - @ec2.delete_snapshot(@snapshot_id) + ec2.delete_snapshot(@snapshot_id) end end it "should return proper attributes with no params" do eventually do - actual = @ec2.describe_snapshots + 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) @@ -30,7 +29,7 @@ describe 'EC2.describe_snapshots' do it "should return proper attributes with params" do eventually do - actual = @ec2.describe_snapshots([@snapshot_id]) + 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) diff --git a/spec/aws/requests/ec2/describe_volumes_spec.rb b/spec/aws/requests/ec2/describe_volumes_spec.rb index 85bbef4a5..afbcdddd0 100644 --- a/spec/aws/requests/ec2/describe_volumes_spec.rb +++ b/spec/aws/requests/ec2/describe_volumes_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.describe_volumes' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId'] + @volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId'] end after(:all) do - @ec2.delete_volume(@volume_id) + ec2.delete_volume(@volume_id) end it "should return proper attributes with no params" do - actual = @ec2.describe_volumes + 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) @@ -25,7 +24,7 @@ describe 'EC2.describe_volumes' do end it "should return proper attributes for specific volume" do - actual = @ec2.describe_volumes(@volume_id) + 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) @@ -39,7 +38,7 @@ describe 'EC2.describe_volumes' do it "should raise a BadRequest error if volume does not exist" do lambda { - @ec2.describe_volumes('vol-00000000') + ec2.describe_volumes('vol-00000000') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/detach_volume_spec.rb b/spec/aws/requests/ec2/detach_volume_spec.rb index 30c878e0b..6a3eabefc 100644 --- a/spec/aws/requests/ec2/detach_volume_spec.rb +++ b/spec/aws/requests/ec2/detach_volume_spec.rb @@ -3,24 +3,23 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.detach_volume' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @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'] + @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') + ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh') end end after(:all) do eventually do - @ec2.delete_volume(@volume_id) - @ec2.terminate_instances([@instance_id]) + ec2.delete_volume(@volume_id) + ec2.terminate_instances([@instance_id]) end end it "should return proper attributes" do eventually do - actual = @ec2.detach_volume(@volume_id) + 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) diff --git a/spec/aws/requests/ec2/disassociate_address_spec.rb b/spec/aws/requests/ec2/disassociate_address_spec.rb index c21786243..a950f1cd4 100644 --- a/spec/aws/requests/ec2/disassociate_address_spec.rb +++ b/spec/aws/requests/ec2/disassociate_address_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.disassociate_address' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @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) + @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]) + ec2.release_address(@public_ip) + ec2.terminate_instances([@instance_id]) end it "should return proper attributes" do - actual = @ec2.disassociate_address(@public_ip) + actual = ec2.disassociate_address(@public_ip) actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) end diff --git a/spec/aws/requests/ec2/get_console_output_spec.rb b/spec/aws/requests/ec2/get_console_output_spec.rb index 99652f12d..fba46d456 100644 --- a/spec/aws/requests/ec2/get_console_output_spec.rb +++ b/spec/aws/requests/ec2/get_console_output_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.get_console_output' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] + @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] end after(:all) do - @ec2.terminate_instances([@instance_id]) + ec2.terminate_instances([@instance_id]) end it "should return proper attributes" do - actual = @ec2.get_console_output(@instance_id) + 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) diff --git a/spec/aws/requests/ec2/reboot_instances_spec.rb b/spec/aws/requests/ec2/reboot_instances_spec.rb index 2a1fc7d5c..100cbdc9d 100644 --- a/spec/aws/requests/ec2/reboot_instances_spec.rb +++ b/spec/aws/requests/ec2/reboot_instances_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.reboot_instances' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] + @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] end after(:all) do - @ec2.terminate_instances([@instance_id]) + ec2.terminate_instances([@instance_id]) end it "should return proper attributes" do - actual = @ec2.reboot_instances([@instance_id]) + actual = ec2.reboot_instances([@instance_id]) actual.body['requestId'].should be_a(String) [false, true].should include(actual.body['return']) end diff --git a/spec/aws/requests/ec2/release_address_spec.rb b/spec/aws/requests/ec2/release_address_spec.rb index 9f0ce3468..0fef88b08 100644 --- a/spec/aws/requests/ec2/release_address_spec.rb +++ b/spec/aws/requests/ec2/release_address_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.release_address' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @public_ip = @ec2.allocate_address.body['publicIp'] + @public_ip = ec2.allocate_address.body['publicIp'] end it "should return proper attributes" do - actual = @ec2.release_address(@public_ip) + actual = ec2.release_address(@public_ip) actual.body['requestId'].should be_a(String) actual.body['return'].should == true end it "should raise a BadRequest error if address does not exist" do lambda { - @ec2.release_address('127.0.0.1') + ec2.release_address('127.0.0.1') }.should raise_error(Fog::Errors::BadRequest) end diff --git a/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb b/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb index 5176ad700..a19064040 100644 --- a/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +++ b/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb @@ -3,9 +3,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.revoke_security_group_ingress' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @ec2.create_security_group('fog_security_group', 'a security group for testing fog') - @ec2.authorize_security_group_ingress({ + 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', @@ -14,11 +13,11 @@ describe 'EC2.revoke_security_group_ingress' do end after(:all) do - @ec2.delete_security_group('fog_security_group') + ec2.delete_security_group('fog_security_group') end it "should return proper attributes" do - actual = @ec2.revoke_security_group_ingress({ + actual = ec2.revoke_security_group_ingress({ 'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', diff --git a/spec/aws/requests/ec2/run_instances_spec.rb b/spec/aws/requests/ec2/run_instances_spec.rb index 29e594c1a..900286af6 100644 --- a/spec/aws/requests/ec2/run_instances_spec.rb +++ b/spec/aws/requests/ec2/run_instances_spec.rb @@ -2,16 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.run_instances' do - before(:all) do - @ec2 = Fog::AWS::EC2.gen - end - after(:all) do - @ec2.terminate_instances([@instance_id]) + ec2.terminate_instances([@instance_id]) end it "should return proper attributes" do - actual = @ec2.run_instances('ami-5ee70037', 1, 1) + 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) diff --git a/spec/aws/requests/ec2/terminate_instances_spec.rb b/spec/aws/requests/ec2/terminate_instances_spec.rb index 32cc25682..87efae36f 100644 --- a/spec/aws/requests/ec2/terminate_instances_spec.rb +++ b/spec/aws/requests/ec2/terminate_instances_spec.rb @@ -3,12 +3,11 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'EC2.terminate_instances' do before(:all) do - @ec2 = Fog::AWS::EC2.gen - @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId'] + @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 = 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 diff --git a/spec/aws/requests/s3/copy_object_spec.rb b/spec/aws/requests/s3/copy_object_spec.rb index 556cbf632..9475c7e97 100644 --- a/spec/aws/requests/s3/copy_object_spec.rb +++ b/spec/aws/requests/s3/copy_object_spec.rb @@ -3,22 +3,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.copy_object' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogcopyobjectsource') + 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') + s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file) + s3.put_bucket('fogcopyobjectdestination') end after(:all) do - @s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination') - @s3.delete_bucket('fogcopyobjectdestination') - @s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source') - @s3.delete_bucket('fogcopyobjectsource') + s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination') + s3.delete_bucket('fogcopyobjectdestination') + s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source') + s3.delete_bucket('fogcopyobjectsource') end it 'should return proper attributes' do - actual = @s3.copy_object( + actual = s3.copy_object( 'fogcopyobjectsource', 'fog_copy_object_source', 'fogcopyobjectdestination', 'fog_copy_object_destination' ) @@ -29,7 +28,7 @@ describe 'S3.copy_object' do it 'should raise a NotFound error if the source_bucket does not exist' do lambda { - @s3.copy_object( + s3.copy_object( 'fognotabucket', 'fog_copy_object_source', 'fogcopyobjectdestination', 'fog_copy_object_destination' ) @@ -38,7 +37,7 @@ describe 'S3.copy_object' do it 'should raise a NotFound error if the source_object does not exist' do lambda { - @s3.copy_object( + s3.copy_object( 'fogcopyobjectsource', 'fog_not_an_object', 'fogcopyobjectdestination', 'fog_copy_object_destination' ) @@ -47,7 +46,7 @@ describe 'S3.copy_object' do it 'should raise a NotFound error if the target_bucket does not exist' do lambda { - @s3.copy_object( + s3.copy_object( 'fogcopyobjectsource', 'fog_copy_object_source', 'fognotabucket', 'fog_copy_object_destination' ) diff --git a/spec/aws/requests/s3/delete_bucket_spec.rb b/spec/aws/requests/s3/delete_bucket_spec.rb index c4dd647e5..676d9db79 100644 --- a/spec/aws/requests/s3/delete_bucket_spec.rb +++ b/spec/aws/requests/s3/delete_bucket_spec.rb @@ -3,18 +3,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.delete_bucket' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogdeletebucket') + s3.put_bucket('fogdeletebucket') end it 'should return proper attributes' do - actual = @s3.delete_bucket('fogdeletebucket') + actual = s3.delete_bucket('fogdeletebucket') actual.status.should == 204 end it 'should raise a NotFound error if the bucket does not exist' do lambda { - @s3.delete_bucket('fognotabucket') + s3.delete_bucket('fognotabucket') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/s3/delete_object_spec.rb b/spec/aws/requests/s3/delete_object_spec.rb index ecf8064aa..e749997bb 100644 --- a/spec/aws/requests/s3/delete_object_spec.rb +++ b/spec/aws/requests/s3/delete_object_spec.rb @@ -3,29 +3,28 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.delete_object' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogdeleteobject') + 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', file) end after(:all) do - @s3.delete_bucket('fogdeleteobject') + s3.delete_bucket('fogdeleteobject') end it 'should return proper attributes' do - actual = @s3.delete_object('fogdeleteobject', 'fog_delete_object') + actual = s3.delete_object('fogdeleteobject', 'fog_delete_object') actual.status.should == 204 end it 'should raise NotFound error if the bucket does not exist' do lambda { - @s3.delete_object('fognotabucket', 'fog_delete_object') + 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.delete_object('fogdeleteobject', 'fog_not_an_object') + s3.delete_object('fogdeleteobject', 'fog_not_an_object') end end \ No newline at end of file diff --git a/spec/aws/requests/s3/get_bucket_location_spec.rb b/spec/aws/requests/s3/get_bucket_location_spec.rb index a48958153..c8c6e8578 100644 --- a/spec/aws/requests/s3/get_bucket_location_spec.rb +++ b/spec/aws/requests/s3/get_bucket_location_spec.rb @@ -3,27 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.get_bucket_location' do before(:all) do - @s3 = Fog::AWS::S3.gen - @eu_s3 = Fog::AWS::S3.gen(:eu) - @s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU') + s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU') end after(:all) do - if Fog.mocking? - @eu_s3.data = @s3.data - end - @eu_s3.delete_bucket('foggetlocation') + eu_s3.delete_bucket('foggetlocation') end it 'should return proper attributes' do - actual = @s3.get_bucket_location('foggetlocation') + actual = s3.get_bucket_location('foggetlocation') actual.status.should == 200 actual.body['LocationConstraint'].should == 'EU' end it 'should raise NotFound error if bucket does not exist' do lambda { - @s3.get_bucket_location('fognotabucket') + s3.get_bucket_location('fognotabucket') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/s3/get_bucket_spec.rb b/spec/aws/requests/s3/get_bucket_spec.rb index a30a0ab59..386e3e78b 100644 --- a/spec/aws/requests/s3/get_bucket_spec.rb +++ b/spec/aws/requests/s3/get_bucket_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.get_bucket' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('foggetbucket') + s3.put_bucket('foggetbucket') file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r') - @s3.put_object('foggetbucket', 'fog_get_bucket', file) + s3.put_object('foggetbucket', 'fog_get_bucket', file) end after(:all) do - @s3.delete_object('foggetbucket', 'fog_get_bucket') - @s3.delete_bucket('foggetbucket') + s3.delete_object('foggetbucket', 'fog_get_bucket') + s3.delete_bucket('foggetbucket') end it 'should return proper attributes' do - actual = @s3.get_bucket('foggetbucket') + actual = s3.get_bucket('foggetbucket') actual.body['IsTruncated'].should == false actual.body['Marker'].should be_a(String) actual.body['MaxKeys'].should be_an(Integer) @@ -34,7 +33,7 @@ describe 'S3.get_bucket' do end it 'should accept options' do - actual = @s3.get_bucket('foggetbucket', 'prefix' => 'fog_') + actual = s3.get_bucket('foggetbucket', 'prefix' => 'fog_') actual.body['IsTruncated'].should == false actual.body['Marker'].should be_a(String) actual.body['MaxKeys'].should be_an(Integer) @@ -54,7 +53,7 @@ describe 'S3.get_bucket' do it 'should raise a NotFound error if the bucket does not exist' do lambda { - @s3.get_bucket('fognotabucket') + s3.get_bucket('fognotabucket') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/s3/get_object_spec.rb b/spec/aws/requests/s3/get_object_spec.rb index cdfb6d119..a8da53636 100644 --- a/spec/aws/requests/s3/get_object_spec.rb +++ b/spec/aws/requests/s3/get_object_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.get_object' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('foggetobject') + 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', file) end after(:all) do - @s3.delete_object('foggetobject', 'fog_get_object') - @s3.delete_bucket('foggetobject') + s3.delete_object('foggetobject', 'fog_get_object') + s3.delete_bucket('foggetobject') end it 'should return proper attributes' do - actual = @s3.get_object('foggetobject', 'fog_get_object') + actual = s3.get_object('foggetobject', 'fog_get_object') actual.status.should == 200 file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r') data = file.read @@ -27,13 +26,13 @@ describe 'S3.get_object' do it 'should raise a NotFound error if the bucket does not exist' do lambda { - @s3.get_object('fognotabucket', 'fog_get_object') + 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') + s3.get_object('foggetobject', 'fog_not_an_object') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/s3/get_request_payment_spec.rb b/spec/aws/requests/s3/get_request_payment_spec.rb index 5f4866ea2..dff1dcd32 100644 --- a/spec/aws/requests/s3/get_request_payment_spec.rb +++ b/spec/aws/requests/s3/get_request_payment_spec.rb @@ -3,23 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.get_request_payment' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('foggetrequestpayment') + s3.put_bucket('foggetrequestpayment') end after(:all) do - @s3.delete_bucket('foggetrequestpayment') + s3.delete_bucket('foggetrequestpayment') end it 'should return proper attributes' do - actual = @s3.get_request_payment('foggetrequestpayment') + actual = s3.get_request_payment('foggetrequestpayment') actual.status.should == 200 actual.body['Payer'].should == 'BucketOwner' end it 'should raise a NotFound error if the bucket does not exist' do lambda { - @s3.get_request_payment('fognotabucket') + s3.get_request_payment('fognotabucket') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/s3/get_service_spec.rb b/spec/aws/requests/s3/get_service_spec.rb index 136f78948..caadea29e 100644 --- a/spec/aws/requests/s3/get_service_spec.rb +++ b/spec/aws/requests/s3/get_service_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.get_service' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('foggetservice') + s3.put_bucket('foggetservice') end after(:all) do - @s3.delete_bucket('foggetservice') + s3.delete_bucket('foggetservice') end it 'should return proper_attributes' do - actual = @s3.get_service + actual = s3.get_service actual.body['Buckets'].should be_an(Array) bucket = actual.body['Buckets'].select {|bucket| bucket['Name'] == 'foggetservice'}.first bucket['CreationDate'].should be_a(Time) @@ -24,7 +23,7 @@ describe 'S3.get_service' do it 'should include foggetservice in get_service' do eventually do - actual = @s3.get_service + actual = s3.get_service actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice') end end diff --git a/spec/aws/requests/s3/head_object_spec.rb b/spec/aws/requests/s3/head_object_spec.rb index 86a4672f6..4bfaa7f5f 100644 --- a/spec/aws/requests/s3/head_object_spec.rb +++ b/spec/aws/requests/s3/head_object_spec.rb @@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.head_object' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogheadobject') + 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', file) end after(:all) do - @s3.delete_object('fogheadobject', 'fog_head_object') - @s3.delete_bucket('fogheadobject') + s3.delete_object('fogheadobject', 'fog_head_object') + s3.delete_bucket('fogheadobject') end it 'should return proper attributes' do - actual = @s3.head_object('fogheadobject', 'fog_head_object') + actual = s3.head_object('fogheadobject', 'fog_head_object') actual.status.should == 200 file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r') data = file.read diff --git a/spec/aws/requests/s3/put_bucket_spec.rb b/spec/aws/requests/s3/put_bucket_spec.rb index 8e79e1bc0..a0cd2b3b1 100644 --- a/spec/aws/requests/s3/put_bucket_spec.rb +++ b/spec/aws/requests/s3/put_bucket_spec.rb @@ -2,21 +2,17 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.put_bucket' do - before(:all) do - @s3 = Fog::AWS::S3.gen - end - after(:all) do - @s3.delete_bucket('fogputbucket') + s3.delete_bucket('fogputbucket') end it 'should return proper attributes' do - actual = @s3.put_bucket('fogputbucket') + actual = s3.put_bucket('fogputbucket') actual.status.should == 200 end it 'should not raise an error if the bucket already exists' do - @s3.put_bucket('fogputbucket') + s3.put_bucket('fogputbucket') end end diff --git a/spec/aws/requests/s3/put_object_spec.rb b/spec/aws/requests/s3/put_object_spec.rb index 06d2d70a8..5af85d97c 100644 --- a/spec/aws/requests/s3/put_object_spec.rb +++ b/spec/aws/requests/s3/put_object_spec.rb @@ -3,31 +3,30 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.put_object' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogputobject') + s3.put_bucket('fogputobject') end after(:all) do - @s3.delete_object('fogputobject', 'fog_put_object') - @s3.delete_bucket('fogputobject') + 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 = 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) + s3.put_object('fognotabucket', 'fog_put_object', file) }.should raise_error(Fog::Errors::NotFound) 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', file) actual.status.should == 200 end diff --git a/spec/aws/requests/s3/put_request_payment_spec.rb b/spec/aws/requests/s3/put_request_payment_spec.rb index 5e9e8286f..4eef705eb 100644 --- a/spec/aws/requests/s3/put_request_payment_spec.rb +++ b/spec/aws/requests/s3/put_request_payment_spec.rb @@ -3,22 +3,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'S3.put_request_payment' do before(:all) do - @s3 = Fog::AWS::S3.gen - @s3.put_bucket('fogputrequestpayment') + s3.put_bucket('fogputrequestpayment') end after(:all) do - @s3.delete_bucket('fogputrequestpayment') + s3.delete_bucket('fogputrequestpayment') end it 'should return proper attributes' do - actual = @s3.put_request_payment('fogputrequestpayment', 'Requester') + actual = s3.put_request_payment('fogputrequestpayment', 'Requester') actual.status.should == 200 end it 'should raise a NotFound error if bucket does not exist' do lambda { - @s3.put_request_payment('fognotabucket', 'Requester') + s3.put_request_payment('fognotabucket', 'Requester') }.should raise_error(Fog::Errors::NotFound) end diff --git a/spec/aws/requests/simpledb/batch_put_attributes_spec.rb b/spec/aws/requests/simpledb/batch_put_attributes_spec.rb index f712a3a97..8a290fd3d 100644 --- a/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +++ b/spec/aws/requests/simpledb/batch_put_attributes_spec.rb @@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.batch_put_attributes' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" - @sdb.create_domain(@domain_name) + sdb.create_domain(@domain_name) end after(:all) do - @sdb.delete_domain(@domain_name) + 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 = 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 diff --git a/spec/aws/requests/simpledb/create_domain_spec.rb b/spec/aws/requests/simpledb/create_domain_spec.rb index 2b2424cb3..775a91c0a 100644 --- a/spec/aws/requests/simpledb/create_domain_spec.rb +++ b/spec/aws/requests/simpledb/create_domain_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.create_domain' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" end after(:all) do - @sdb.delete_domain(@domain_name) + sdb.delete_domain(@domain_name) end it 'should return proper attributes' do - actual = @sdb.create_domain(@domain_name) + actual = sdb.create_domain(@domain_name) actual.body['RequestId'].should be_a(String) actual.body['BoxUsage'].should be_a(Float) end diff --git a/spec/aws/requests/simpledb/delete_attributes_spec.rb b/spec/aws/requests/simpledb/delete_attributes_spec.rb index 857fb8087..45ee5f828 100644 --- a/spec/aws/requests/simpledb/delete_attributes_spec.rb +++ b/spec/aws/requests/simpledb/delete_attributes_spec.rb @@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.delete_attributes' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen - @sdb.create_domain('delete_attributes') - @sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz }) + sdb.create_domain('delete_attributes') + sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz }) end after(:all) do - @sdb.delete_domain('delete_attributes') + sdb.delete_domain('delete_attributes') end it 'should return proper attributes from delete_attributes' do - actual = @sdb.delete_attributes('delete_attributes', 'foo') + actual = sdb.delete_attributes('delete_attributes', 'foo') actual.body['RequestId'].should be_a(String) actual.body['BoxUsage'].should be_a(Float) end diff --git a/spec/aws/requests/simpledb/delete_domain_spec.rb b/spec/aws/requests/simpledb/delete_domain_spec.rb index 61aa3e89b..f599856fa 100644 --- a/spec/aws/requests/simpledb/delete_domain_spec.rb +++ b/spec/aws/requests/simpledb/delete_domain_spec.rb @@ -3,16 +3,15 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.delete_domain' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" end before(:all) do - @sdb.create_domain(@domain_name) + sdb.create_domain(@domain_name) end it 'should return proper attributes' do - actual = @sdb.delete_domain(@domain_name) + actual = sdb.delete_domain(@domain_name) actual.body['RequestId'].should be_a(String) actual.body['BoxUsage'].should be_a(Float) end diff --git a/spec/aws/requests/simpledb/domain_metadata_spec.rb b/spec/aws/requests/simpledb/domain_metadata_spec.rb index f9015ff5a..12d01524b 100644 --- a/spec/aws/requests/simpledb/domain_metadata_spec.rb +++ b/spec/aws/requests/simpledb/domain_metadata_spec.rb @@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.domain_metadata' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" - @sdb.create_domain(@domain_name) + sdb.create_domain(@domain_name) end after(:all) do - @sdb.delete_domain(@domain_name) + sdb.delete_domain(@domain_name) end it 'should return proper attributes when there are no items' do - results = @sdb.domain_metadata(@domain_name) + results = sdb.domain_metadata(@domain_name) results.body['AttributeNameCount'].should == 0 results.body['AttributeNamesSizeBytes'].should == 0 results.body['AttributeValueCount'].should == 0 @@ -26,8 +25,8 @@ describe 'SimpleDB.domain_metadata' do end it 'should return proper attributes with items' do - @sdb.put_attributes(@domain_name, 'foo', { :bar => :baz }) - results = @sdb.domain_metadata(@domain_name) + 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 diff --git a/spec/aws/requests/simpledb/get_attributes_spec.rb b/spec/aws/requests/simpledb/get_attributes_spec.rb index 22eac6d56..3ab3a3673 100644 --- a/spec/aws/requests/simpledb/get_attributes_spec.rb +++ b/spec/aws/requests/simpledb/get_attributes_spec.rb @@ -3,26 +3,25 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.get_attributes' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" - @sdb.create_domain(@domain_name) + sdb.create_domain(@domain_name) end after(:all) do - @sdb.delete_domain(@domain_name) + 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 = 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 }) + sdb.put_attributes(@domain_name, 'foo', { :bar => :baz }) eventually do - actual = @sdb.get_attributes(@domain_name, 'foo') + actual = sdb.get_attributes(@domain_name, 'foo') actual.body['Attributes'].should == { 'bar' => ['baz'] } end end diff --git a/spec/aws/requests/simpledb/list_domains_spec.rb b/spec/aws/requests/simpledb/list_domains_spec.rb index bca7cc7f1..d903bf026 100644 --- a/spec/aws/requests/simpledb/list_domains_spec.rb +++ b/spec/aws/requests/simpledb/list_domains_spec.rb @@ -3,25 +3,24 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.list_domains' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" end after(:all) do - @sdb.delete_domain(@domain_name) + sdb.delete_domain(@domain_name) end it 'should return proper attributes' do - results = @sdb.list_domains + 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) + sdb.create_domain(@domain_name) eventually do - actual = @sdb.list_domains + actual = sdb.list_domains actual.body['Domains'].should include(@domain_name) end end diff --git a/spec/aws/requests/simpledb/put_attributes_spec.rb b/spec/aws/requests/simpledb/put_attributes_spec.rb index 9510026ca..d8d10a4d2 100644 --- a/spec/aws/requests/simpledb/put_attributes_spec.rb +++ b/spec/aws/requests/simpledb/put_attributes_spec.rb @@ -3,17 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe 'SimpleDB.put_attributes' do before(:all) do - @sdb = Fog::AWS::SimpleDB.gen @domain_name = "fog_domain_#{Time.now.to_i}" - @sdb.create_domain(@domain_name) + sdb.create_domain(@domain_name) end after(:all) do - @sdb.delete_domain(@domain_name) + 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 = sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' }) actual.body['RequestId'].should be_a(String) actual.body['BoxUsage'].should be_a(Float) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ca56bccbe..6e17c3bb8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,41 +12,33 @@ def credentials end end -module Fog - module AWS +def ec2 + Fog::AWS::EC2.new( + :aws_access_key_id => credentials['aws_access_key_id'], + :aws_secret_access_key => credentials['aws_secret_access_key'] + ) +end - class EC2 - def self.gen - new( - :aws_access_key_id => credentials['aws_access_key_id'], - :aws_secret_access_key => credentials['aws_secret_access_key'] - ) - end - end +def eu_s3 + Fog::AWS::S3.new( + :aws_access_key_id => credentials['aws_access_key_id'], + :aws_secret_access_key => credentials['aws_secret_access_key'], + :host => 's3-external-3.amazonaws.com' + ) +end - class S3 - def self.gen(location = nil) - if location == :eu - host = 's3-external-3.amazonaws.com' - end - new( - :aws_access_key_id => credentials['aws_access_key_id'], - :aws_secret_access_key => credentials['aws_secret_access_key'], - :host => host - ) - end - end +def sdb + Fog::AWS::SimpleDB.new( + :aws_access_key_id => credentials['aws_access_key_id'], + :aws_secret_access_key => credentials['aws_secret_access_key'] + ) +end - class SimpleDB - def self.gen - new( - :aws_access_key_id => credentials['aws_access_key_id'], - :aws_secret_access_key => credentials['aws_secret_access_key'] - ) - end - end - - end +def s3 + Fog::AWS::S3.new( + :aws_access_key_id => credentials['aws_access_key_id'], + :aws_secret_access_key => credentials['aws_secret_access_key'] + ) end def eventually(max_delay = 16, &block)