1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/spec/aws/requests/ec2/describe_security_groups_spec.rb
2009-08-19 20:32:57 -07:00

51 lines
1.8 KiB
Ruby

require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'EC2.describe_security_groups' 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 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
end
end