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/models/ec2/address_spec.rb

116 lines
2.6 KiB
Ruby
Raw Normal View History

2009-09-20 09:21:21 -07:00
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Fog::AWS::EC2::Address' do
describe "#initialize" do
it "should remap attributes from parser" do
address = Fog::AWS::EC2::Address.new(
'instanceId' => 'i-00000000',
'publicIp' => '0.0.0.0'
)
address.instance_id.should == 'i-00000000'
address.public_ip.should == '0.0.0.0'
end
end
describe "#addresses" do
it "should return a Fog::AWS::EC2::Addresses" do
ec2.addresses.new.addresses.should be_a(Fog::AWS::EC2::Addresses)
end
it "should be the addresses the address is related to" do
addresses = ec2.addresses
addresses.new.addresses.should == addresses
end
end
describe "#destroy" do
it "should return true if the address is deleted" do
address = ec2.addresses.create
address.destroy.should be_true
end
end
describe "#instance=" do
before(:each) do
@address = ec2.addresses.new
@instance = ec2.instances.create(:image_id => GENTOO_AMI)
end
after(:each) do
if @address.public_ip
@address.destroy
end
@instance.destroy
end
it "should not associate with instance if the address has not been saved" do
@address.instance = @instance
@address.instance_id.should_not == @instance.instance_id
end
it "should associate with instance when the address is saved" do
@address.instance = @instance
@address.save.should be_true
@address.instance_id.should == @instance.instance_id
end
it "should associate with instance to an already saved address" do
@address.save.should be_true
@address.instance = @instance
@address.instance_id.should == @instance.instance_id
end
end
2009-09-20 09:21:21 -07:00
describe "#reload" do
before(:each) do
@address = ec2.addresses.create
@reloaded = @address.reload
end
after(:each) do
@address.destroy
end
it "should return a Fog::AWS::EC2::Address" do
@reloaded.should be_a(Fog::AWS::EC2::Address)
end
it "should reset attributes to remote state" do
@address.attributes.should == @reloaded.attributes
end
end
describe "#save" do
before(:each) do
@address = ec2.addresses.new
end
it "should return true when it succeeds" do
@address.save.should be_true
@address.destroy
end
it "should not exist in addresses before save" do
@address.addresses.get(@address.public_ip).should be_nil
2009-09-20 09:21:21 -07:00
end
it "should exist in buckets after save" do
@address.save
@address.addresses.get(@address.public_ip).should_not be_nil
2009-09-20 09:21:21 -07:00
@address.destroy
end
end
end