mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
starting to add specs for ec2 models
This commit is contained in:
parent
46c6d0b914
commit
26b556975c
3 changed files with 89 additions and 1 deletions
|
@ -20,10 +20,15 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reload
|
def self.reload
|
||||||
|
load "fog/collection.rb"
|
||||||
load "fog/connection.rb"
|
load "fog/connection.rb"
|
||||||
|
load "fog/model.rb"
|
||||||
load "fog/parser.rb"
|
load "fog/parser.rb"
|
||||||
load "fog/response.rb"
|
load "fog/response.rb"
|
||||||
|
|
||||||
|
load "fog/aws/models/ec2/address.rb"
|
||||||
|
load "fog/aws/models/ec2/addresses.rb"
|
||||||
|
|
||||||
load "fog/aws/parsers/ec2/allocate_address.rb"
|
load "fog/aws/parsers/ec2/allocate_address.rb"
|
||||||
load "fog/aws/parsers/ec2/attach_volume.rb"
|
load "fog/aws/parsers/ec2/attach_volume.rb"
|
||||||
load "fog/aws/parsers/ec2/basic.rb"
|
load "fog/aws/parsers/ec2/basic.rb"
|
||||||
|
|
84
spec/aws/models/ec2/address_spec.rb
Normal file
84
spec/aws/models/ec2/address_spec.rb
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
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 "#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.all.map {|address| address.public_ip}.include?(@address.public_ip).should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should exist in buckets after save" do
|
||||||
|
@address.save
|
||||||
|
@address.addresses.all.map {|address| address.public_ip}.include?(@address.public_ip).should be_true
|
||||||
|
@address.destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -98,7 +98,6 @@ describe 'Fog::AWS::S3::Bucket' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reset attributes to remote state" do
|
it "should reset attributes to remote state" do
|
||||||
@bucket.creation_date = Time.now
|
|
||||||
@bucket.attributes.should == @reloaded.attributes
|
@bucket.attributes.should == @reloaded.attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue