spec/kumogata_convert_spec.rb in kumogata-0.5.4 vs spec/kumogata_convert_spec.rb in kumogata-0.5.5
- old
+ new
@@ -975,9 +975,65 @@
}
}
EOS
end
+ it 'convert splitted Ruby template to JSON template with args' do
+ json_template = nil
+
+ part_of_template = <<-EOS
+myEC2Instance do
+ Type "AWS::EC2::Instance"
+ Properties do
+ ImageId args[:ami_id]
+ InstanceType "t1.micro"
+ end
+end
+ EOS
+
+ tempfile(part_of_template, '.rb') do |f|
+ template = <<-EOS
+Resources do
+ _include #{f.path.inspect}, {:ami_id => "ami-XXXXXXXX"}
+end
+
+Outputs do
+ AZ do
+ Value do
+ Fn__GetAtt "myEC2Instance", "AvailabilityZone"
+ end
+ end
+end
+ EOS
+
+ json_template = run_client(:convert, :template => template)
+ end
+
+ expect(json_template).to eq((<<-EOS).chomp)
+{
+ "Resources": {
+ "myEC2Instance": {
+ "Type": "AWS::EC2::Instance",
+ "Properties": {
+ "ImageId": "ami-XXXXXXXX",
+ "InstanceType": "t1.micro"
+ }
+ }
+ },
+ "Outputs": {
+ "AZ": {
+ "Value": {
+ "Fn::GetAtt": [
+ "myEC2Instance",
+ "AvailabilityZone"
+ ]
+ }
+ }
+ }
+}
+ EOS
+ end
+
it 'convert Ruby template to JSON template with require' do
template = <<-EOS
require 'fileutils'
Resources do