on init, connect to AWS and check for the AS group

This commit is contained in:
Anuj Biyani
2013-05-31 13:08:23 -07:00
parent 2bdaca25bb
commit 4f466e1a19
5 changed files with 59 additions and 3 deletions

View File

@@ -10,13 +10,25 @@ describe 'aws-ha-release' do
}
end
let(:as) { AWS::FakeAutoScaling.new }
before do
AWS.stub(:config)
AWS::AutoScaling.stub(:new).and_return(AWS::FakeAutoScaling.new)
AWS::AutoScaling.stub(:new).and_return(as)
end
describe '#initialize' do
it 'initializes the AWS connection'
it 'ensures the as group exists'
it 'initializes the AWS connection' do
as.groups.create 'test_group'
AWS.should_receive(:config).with(access_key_id: 'testaccesskey', secret_access_key: 'testsecretkey', region: 'test-region')
AwsHaRelease.new(opts)
end
it 'ensures the as group exists' do
lambda {
AwsHaRelease.new(opts.merge!(as_group_name: 'fake_group'))
}.should raise_error
end
end
end

View File

@@ -2,5 +2,31 @@ module AWS
class FakeAutoScaling
def initialize
end
def groups
@groups ||= GroupCollection.new
end
class GroupCollection
def initialize
@groups = {}
end
def [](name)
@groups[name]
end
def create(name, options = {})
@groups[name] = Group.new name
end
end
class Group
attr_reader :name
def initialize(name)
@name = name
end
end
end
end