spec/kumogata_convert_spec.rb in kumogata-0.2.6 vs spec/kumogata_convert_spec.rb in kumogata-0.2.7

- old
+ new

@@ -619,6 +619,81 @@ } } } EOS end + + + it 'convert splitted Ruby template to JSON template' do + json_template = nil + + part_of_template = <<-EOS +myEC2Instance do + Type "AWS::EC2::Instance" + Properties do + ImageId "ami-XXXXXXXX" + InstanceType "t1.micro" + end +end + EOS + + tempfile(part_of_template, '.rb') do |f| + template = <<-EOS +Resources do + _include #{f.path.inspect} +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 + + let(:drupal_single_instance_template) do + path = File.expand_path('../Drupal_Single_Instance.template', __FILE__) + open(path) {|f| f.read } + end + + let(:drupal_single_instance_template_rb) do + path = File.expand_path('../Drupal_Single_Instance.template.rb', __FILE__) + open(path) {|f| f.read } + end + + it 'Ruby templates and JSON template should be same' do + json_template = JSON.parse(drupal_single_instance_template) + ruby_template = run_client(:convert, :template => drupal_single_instance_template_rb) + ruby_template = JSON.parse(ruby_template) + + expect(ruby_template).to eq(json_template) + end end