From 132b1f1e482d19205a221da857b6949cccf0aa76 Mon Sep 17 00:00:00 2001 From: drrb Date: Thu, 30 Mar 2017 20:31:40 +1100 Subject: [PATCH] More tests for !Split --- features/yamly_shortcuts.feature | 16 ++++++++++++++++ spec/cfoo/parser_spec.rb | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/features/yamly_shortcuts.feature b/features/yamly_shortcuts.feature index 59df4ed..c65a561 100644 --- a/features/yamly_shortcuts.feature +++ b/features/yamly_shortcuts.feature @@ -60,6 +60,22 @@ Feature: YAMLy shortcuts } """ + Scenario: Split function call + Given I have a file "split.yml" containing + """ + Split: !Split + - "|" + - "a|b|c" + """ + When I process "split.yml" + Then the output should match JSON + """ + { + "AWSTemplateFormatVersion" : "2010-09-09", + "Split" : { "Fn::Split" : [ "|", "a|b|c" ] } + } + """ + Scenario: Join function call with empty strings Given I have a file "join.yml" containing """ diff --git a/spec/cfoo/parser_spec.rb b/spec/cfoo/parser_spec.rb index f8bc008..16c09f1 100644 --- a/spec/cfoo/parser_spec.rb +++ b/spec/cfoo/parser_spec.rb @@ -108,6 +108,11 @@ module Cfoo parser.parse_file("join.yml").should == {"Fn::Join" => [ "" , [ "a", "b", "c" ] ] } end + it "wraps splits in AWS Split function-calls" do + file_system.should_receive(:parse_file).with("split.yml").and_return(YAML::DomainType.create("Split", ["|", "a|b|c"])) + + parser.parse_file("split.yml").should == {"Fn::Split" => [ "|" , "a|b|c" ] } + end it "wraps map lookups in AWS FindInMap function-calls" do file_system.should_receive(:parse_file).with("findinmap.yml").and_return(YAML::DomainType.create("FindInMap", ["Map", "Key", "Value"]))