spec/ami_spec.rb in roark-0.0.1 vs spec/ami_spec.rb in roark-0.1.0
- old
+ new
@@ -6,21 +6,21 @@
Roark.logger.stub :info => true
@aws_mock = mock "aws connection mock"
@aws_mock.stub :region => 'us-west-1'
init_args = { :aws => @aws_mock,
- :name => 'test-ami' }
+ :name => 'Intu_BaselineImage.1.2.3' }
@ami = Roark::Ami.new init_args
end
context "testing instance methods" do
before do
@instance_mock = mock 'instance mock'
Roark::Instance.should_receive(:new).
with(:aws => @aws_mock,
- :name => 'test-ami').
+ :name => 'intu-baselineimage-1-2-3').
and_return @instance_mock
@instance_mock.stub :instance_id => 'i-1234abcd'
end
describe "#create_instance" do
@@ -208,9 +208,24 @@
Roark::Aws::Ec2::DestroyAmi.should_receive(:new).
with(@aws_mock).
and_return ec2_destroy_ami_mock
ec2_destroy_ami_mock.should_receive(:destroy).with('ami-12345678')
expect(@ami.destroy.success?).to be_true
+ end
+ end
+
+ describe "#authorize_account_ids" do
+ it "should call authorize with the given account ids" do
+ @ami.ami_id = 'ami-12345678'
+ account_ids = ['123456789012']
+ ec2_ami_authorizations_mock = mock 'ami authorizations'
+ Roark::Aws::Ec2::AmiAuthorizations.should_receive(:new).
+ with(@aws_mock).
+ and_return ec2_ami_authorizations_mock
+ ec2_ami_authorizations_mock.should_receive(:add).
+ with :ami_id => "ami-12345678",
+ :account_ids => account_ids
+ expect(@ami.authorize_account_ids(account_ids).success?).to be_true
end
end
end
end