spec/cfndsl_spec.rb in cfndsl-0.4.4 vs spec/cfndsl_spec.rb in cfndsl-0.5.0.pre
- old
+ new
@@ -1,7 +1,19 @@
require 'spec_helper'
+describe CfnDsl do
+ it 'evaluates a cloud formation' do
+ filename = "#{File.dirname(__FILE__)}/fixtures/test.rb"
+ subject.eval_file_with_extras(filename)
+ end
+
+ it 'evaluates a heat' do
+ filename = "#{File.dirname(__FILE__)}/fixtures/heattest.rb"
+ subject.eval_file_with_extras(filename)
+ end
+end
+
describe CfnDsl::HeatTemplate do
it 'honors last-set value for non-array properties' do
spec = self
subject.declare do
Server('myserver') do
@@ -13,11 +25,10 @@
end
end
end
describe CfnDsl::CloudFormationTemplate do
-
it 'populates an empty template' do
expect(subject.to_json).to eq('{"AWSTemplateFormatVersion":"2010-09-09"}')
end
it 'allows the format version to be set' do
@@ -39,19 +50,19 @@
spec.expect(@Outputs.length).to spec.eq(1)
end
end
it 'validates references' do
- q = subject.Resource('q'){ DependsOn ['r'] }
- r = subject.Resource('r'){ Property('z', Ref('q')) }
- q_refs = q.references Hash.new
- r_refs = r.references Hash.new
+ q = subject.Resource('q') { DependsOn ['r'] }
+ r = subject.Resource('r') { Property('z', Ref('q')) }
+ q_refs = q.build_references({})
+ r_refs = r.build_references({})
expect(q_refs).to have_key('r')
expect(q_refs).to_not have_key('q')
expect(r_refs).to have_key('q')
expect(r_refs).to_not have_key('r')
- expect(subject.checkRefs.length).to eq(2)
+ expect(subject.check_refs.length).to eq(2)
end
it 'is a data-driven language' do
spec = self
subject.declare do
@@ -59,11 +70,11 @@
id = ImageId 'aaaaa'
SecurityGroup 'one'
SecurityGroup 'two'
groups = @Properties['SecurityGroups'].value
spec.expect(id).to spec.eq('aaaaa')
- spec.expect(groups).to spec.eq(['one', 'two'])
+ spec.expect(groups).to spec.eq(%w(one two))
end
end
end
it 'singularizes indirectly' do
@@ -74,11 +85,11 @@
result2 = user.Policy do
PolicyName 'stuff'
PolicyDocument(a: 7)
end
- expect(result2).to be_a(CfnDsl::AWSTypes::IAMEmbeddedPolicy)
+ expect(result2).to be_a(CfnDsl::AWS::Types::IAMEmbeddedPolicy)
expect(user.instance_variable_get('@Properties')['Policies'].value.length).to eq(2)
end
it 'handles pseudo parameters' do
[
@@ -89,11 +100,11 @@
'AWS::StackId',
'AWS::StackName'
].each do |param|
ref = subject.Ref param
expect(ref.to_json).to eq("{\"Ref\":\"#{param}\"}")
- refs = ref.references({})
+ refs = ref.build_references({})
expect(refs).to have_key(param)
end
end
it 'honors last-set value for non-array properties' do
@@ -113,17 +124,17 @@
func = subject.FnGetAtt('A', 'B')
expect(func.to_json).to eq('{"Fn::GetAtt":["A","B"]}')
end
it 'FnJoin' do
- func = subject.FnJoin('A', ['B', 'C'])
+ func = subject.FnJoin('A', %w(B C))
expect(func.to_json).to eq('{"Fn::Join":["A",["B","C"]]}')
end
it 'Ref' do
ref = subject.Ref 'X'
expect(ref.to_json).to eq('{"Ref":"X"}')
- refs = ref.references Hash.new
+ refs = ref.build_references({})
expect(refs).to have_key('X')
end
it 'FnBase64' do
func = subject.FnBase64 'A'