Skip to content
Browse files

check for one of :image_location or :root_device_name in register_image

  • Loading branch information...
1 parent 6b369a8 commit 18acfc765ce21d3dafecc7d5bf6270b8e677b8c8 @jamespharaoh jamespharaoh committed Mar 26, 2010
Showing with 9 additions and 0 deletions.
  1. +3 −0 lib/AWS/EC2/images.rb
  2. +6 −0 test/test_EC2_images.rb
View
3 lib/AWS/EC2/images.rb
@@ -66,6 +66,9 @@ def deregister_image( options = {} )
#
def register_image( options = {} )
params = {}
+ if options.does_not_have?(:image_location) && options.does_not_have?(:root_device_name)
+ raise ArgumentError, "No :image_location or :root_device_name"
+ end
params["ImageLocation"] = options[:image_location].to_s unless options[:image_location].nil?
params["Name"] = options[:name].to_s unless options[:name].nil?
params["Description"] = options[:description].to_s unless options[:description].nil?
View
6 test/test_EC2_images.rb
@@ -124,6 +124,12 @@
end
+ specify "method register_image should raise an exception when called without :name or :root_device_name" do
+ lambda { @ec2.register_image() }.should.raise(AWS::ArgumentError)
+ lambda { @ec2.register_image(:image_location => "", :root_device_name => "") }.should.raise(AWS::ArgumentError)
+ end
+
+
specify "should be able to be described and return the correct Ruby response class for parent and members" do
@ec2.stubs(:make_request).with('DescribeImages', {}).
returns stub(:body => @describe_image_response_body, :is_a? => true)

0 comments on commit 18acfc7

Please sign in to comment.
Something went wrong with that request. Please try again.