@@ -230,9 +230,9 @@ no_default: default_value`
230230 })
231231
232232 It ("executes block when property exists" , func () {
233- erbTemplateContent = `<% if_p('feature_config.host') do |host| %>
233+ erbTemplateContent = `<% if_p('feature_config.host') do |host| - %>
234234host_configured: <%= host %>
235- <% end %>`
235+ <% end - %>`
236236 expectedTemplateContents = `
237237host_configured: example.com
238238`
@@ -249,9 +249,9 @@ host_configured: example.com
249249 })
250250
251251 It ("supports multiple properties in if_p" , func () {
252- erbTemplateContent = `<% if_p('feature_config.host', 'feature_config.port') do |host, port| %>
252+ erbTemplateContent = `<% if_p('feature_config.host', 'feature_config.port') do |host, port| - %>
253253config: <%= host %>:<%= port %>
254- <% end %>`
254+ <% end - %>`
255255 expectedTemplateContents = `
256256config: example.com:8080
257257`
@@ -269,9 +269,9 @@ config: example.com:8080
269269
270270 It ("skips block when property is missing" , func () {
271271 erbTemplateContent = `before
272- <% if_p('completely_missing_prop') do |host| %>
272+ <% if_p('completely_missing_prop') do |host| - %>
273273should_not_appear: <%= host %>
274- <% end %>
274+ <% end - %>
275275after`
276276 expectedTemplateContents = `before
277277
@@ -315,9 +315,9 @@ after`
315315 })
316316
317317 It ("iterates over array and accesses hash elements" , func () {
318- erbTemplateContent = `<% p('users').each do |user| %>
318+ erbTemplateContent = `<% p('users').each do |user| - %>
319319user: <%= user['name'] %> pass: <%= user['password'] %>
320- <% end %>`
320+ <% end - %>`
321321 expectedTemplateContents = `
322322user: alice pass: secret1
323323
@@ -525,9 +525,9 @@ debug is disabled
525525 })
526526
527527 It ("transforms array elements using map with block" , func () {
528- erbTemplateContent = `<% p('servers').map { |s| s['host'] }.each do |host| %>
528+ erbTemplateContent = `<% p('servers').map { |s| s['host'] }.each do |host| - %>
529529host: <%= host %>
530- <% end %>`
530+ <% end - %>`
531531 expectedTemplateContents = `
532532host: 10.0.0.1
533533
@@ -693,9 +693,9 @@ host: 10.0.0.2
693693 })
694694
695695 It ("iterates with index access" , func () {
696- erbTemplateContent = `<% p('routes').each_with_index do |route, index| %>
696+ erbTemplateContent = `<% p('routes').each_with_index do |route, index| - %>
697697route_<%= index %>: <%= route['uri'] %>
698- <% end %>`
698+ <% end - %>`
699699 expectedTemplateContents = `
700700route_0: api.example.com
701701
@@ -754,9 +754,9 @@ route_1: www.example.com
754754 })
755755
756756 It ("checks for hash key membership" , func () {
757- erbTemplateContent = `<% if p('config').key?('optional_key') %>
757+ erbTemplateContent = `<% if p('config').key?('optional_key') - %>
758758has_key: true
759- <% end %>`
759+ <% end - %>`
760760 expectedTemplateContents = `
761761has_key: true
762762`
@@ -794,9 +794,9 @@ has_key: true
794794 })
795795
796796 It ("checks string prefix with start_with?" , func () {
797- erbTemplateContent = `<% if p('api_url').start_with?('https') %>
797+ erbTemplateContent = `<% if p('api_url').start_with?('https') - %>
798798secure: true
799- <% end %>`
799+ <% end - %>`
800800 expectedTemplateContents = `
801801secure: true
802802`
@@ -813,9 +813,9 @@ secure: true
813813 })
814814
815815 It ("checks for empty strings" , func () {
816- erbTemplateContent = `<% if p('cert') == "" %>
816+ erbTemplateContent = `<% if p('cert') == "" - %>
817817no_cert: true
818- <% end %>`
818+ <% end - %>`
819819 expectedTemplateContents = `
820820no_cert: true
821821`
@@ -955,12 +955,12 @@ provider_name: thales`
955955 })
956956
957957 It ("checks if any element matches condition" , func () {
958- erbTemplateContent = `<% if p('providers').any? { |p| p['type'] == 'hsm' } %>
958+ erbTemplateContent = `<% if p('providers').any? { |p| p['type'] == 'hsm' } - %>
959959using_hsm: true
960- <% end %>
961- <% if !p('empty_list').any? %>
960+ <% end - %>
961+ <% if !p('empty_list').any? - %>
962962list_empty: true
963- <% end %>`
963+ <% end - %>`
964964 expectedTemplateContents = `
965965using_hsm: true
966966list_empty: true
@@ -1001,18 +1001,18 @@ list_empty: true
10011001 })
10021002
10031003 It ("checks for empty strings and arrays" , func () {
1004- erbTemplateContent = `<% if p('optional_cert').empty? %>
1004+ erbTemplateContent = `<% if p('optional_cert').empty? - %>
10051005no_cert: true
1006- <% end %>
1007- <% if !p('required_key').empty? %>
1006+ <% end - %>
1007+ <% if !p('required_key').empty? - %>
10081008has_key: true
1009- <% end %>
1010- <% if p('empty_array').empty? %>
1009+ <% end - %>
1010+ <% if p('empty_array').empty? - %>
10111011array_empty: true
1012- <% end %>
1013- <% if !p('filled_array').empty? %>
1012+ <% end - %>
1013+ <% if !p('filled_array').empty? - %>
10141014array_filled: true
1015- <% end %>`
1015+ <% end - %>`
10161016 expectedTemplateContents = `
10171017no_cert: true
10181018has_key: true
@@ -1053,12 +1053,12 @@ array_filled: true
10531053 })
10541054
10551055 It ("checks array membership" , func () {
1056- erbTemplateContent = `<% if p('valid_modes').include?(p('selected_mode')) %>
1056+ erbTemplateContent = `<% if p('valid_modes').include?(p('selected_mode')) - %>
10571057valid_selection: true
1058- <% end %>
1059- <% if p('tls_modes').include?('enabled') %>
1058+ <% end - %>
1059+ <% if p('tls_modes').include?('enabled') - %>
10601060supports_tls: true
1061- <% end %>`
1061+ <% end - %>`
10621062 expectedTemplateContents = `
10631063valid_selection: true
10641064supports_tls: true
@@ -1212,14 +1212,14 @@ retries: 3`
12121212 })
12131213
12141214 It ("finds substring positions with index" , func () {
1215- erbTemplateContent = `<% if p('cert_with_newlines').index("\n").nil? %>
1215+ erbTemplateContent = `<% if p('cert_with_newlines').index("\n").nil? - %>
12161216no_real_newline: true
12171217<% else %>
12181218has_real_newline: true
1219- <% end %>
1220- <% if p('cert_without_newlines').index("\n").nil? %>
1219+ <% end - %>
1220+ <% if p('cert_without_newlines').index("\n").nil? - %>
12211221no_escaped_newline: true
1222- <% end %>`
1222+ <% end - %>`
12231223 expectedTemplateContents = `
12241224has_real_newline: true
12251225
0 commit comments