From 51dd8259ff1409a89b98f50b6640b5d3d73d873e Mon Sep 17 00:00:00 2001 From: Wesley Beary Date: Fri, 9 Oct 2009 22:54:17 -0700 Subject: [PATCH] filling in more specs --- lib/fog/aws/models/ec2/volumes.rb | 6 ++-- spec/aws/models/ec2/instance_spec.rb | 47 ++++++++++++++++++++++------ spec/aws/models/ec2/volume_spec.rb | 4 +-- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/lib/fog/aws/models/ec2/volumes.rb b/lib/fog/aws/models/ec2/volumes.rb index 041863298..bdedd9bce 100644 --- a/lib/fog/aws/models/ec2/volumes.rb +++ b/lib/fog/aws/models/ec2/volumes.rb @@ -2,8 +2,10 @@ module Fog module AWS class EC2 - def volumes - Fog::AWS::EC2::Volumes.new(:connection => self) + def volumes(attributes = {}) + Fog::AWS::EC2::Volumes.new({ + :connection => self + }.merge!(attributes)) end class Volumes < Fog::Collection diff --git a/spec/aws/models/ec2/instance_spec.rb b/spec/aws/models/ec2/instance_spec.rb index 86f78188c..c41e623ac 100644 --- a/spec/aws/models/ec2/instance_spec.rb +++ b/spec/aws/models/ec2/instance_spec.rb @@ -4,14 +4,38 @@ describe 'Fog::AWS::EC2::Instance' do describe "#initialize" do - it "should remap attributes from parser" # do - # instance = Fog::AWS::EC2::Instance.new( - # 'instanceId' => 'i-00000000', - # 'publicIp' => '0.0.0.0' - # ) - # instance.instance_id.should == 'i-00000000' - # instance.public_ip.should == '0.0.0.0' - # end + it "should remap attributes from parser" do + instance = Fog::AWS::EC2::Instance.new({ + 'amiLaunchIndex' => 'ami_launch_index', + 'availabilityZone' => 'availability_zone', + 'dnsName' => 'dns_name', + 'groupId' => 'group_id', + 'imageId' => 'image_id', + 'instanceId' => 'instance_id', + 'instanceState' => { 'name' => 'instance_state' }, + 'instanceType' => 'instance_type', + 'kernelId' => 'kernel_id', + 'keyName' => 'key_name', + 'launchTime' => 'launch_time', + 'productCodes' => 'product_codes', + 'privateDnsName' => 'private_dns_name', + 'ramdiskId' => 'ramdisk_id' + }) + instance.ami_launch_index.should == 'ami_launch_index' + instance.availability_zone.should == 'availability_zone' + instance.dns_name.should == 'dns_name' + instance.group_id.should == 'group_id' + instance.image_id.should == 'image_id' + instance.instance_id.should == 'instance_id' + instance.instance_state.should == 'instance_state' + instance.instance_type.should == 'instance_type' + instance.kernel_id.should == 'kernel_id' + instance.key_name.should == 'key_name' + instance.launch_time.should == 'launch_time' + instance.product_codes.should == 'product_codes' + instance.private_dns_name.should == 'private_dns_name' + instance.ramdisk_id.should == 'ramdisk_id' + end end @@ -102,7 +126,12 @@ describe 'Fog::AWS::EC2::Instance' do end describe "#volumes" do - it "should have tests" + + it "should return a Fog::AWS::EC2::Volumes" do + instance = ec2.instances.new + instance.volumes.should be_a(Fog::AWS::EC2::Volumes) + end + end end diff --git a/spec/aws/models/ec2/volume_spec.rb b/spec/aws/models/ec2/volume_spec.rb index 55e667001..8cf962e2a 100644 --- a/spec/aws/models/ec2/volume_spec.rb +++ b/spec/aws/models/ec2/volume_spec.rb @@ -6,14 +6,14 @@ describe 'Fog::AWS::EC2::Volume' do it "should remap attributes from parser" do volume = Fog::AWS::EC2::Volume.new( - 'attachmentTime' => 'now', + 'attachTime' => 'now', 'availabilityZone' => 'us-east-1a', 'createTime' => 'recently', 'instanceId' => 'i-00000000', 'snapshotId' => 'snap-00000000', 'volumeId' => 'vol-00000000' ) - volume.attachment_time.should == 'now' + volume.attach_time.should == 'now' volume.availability_zone.should == 'us-east-1a' volume.create_time.should == 'recently' volume.instance_id.should == 'i-00000000'