Skip to content

Commit

Permalink
feat: noIndent helper (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier authored Dec 22, 2022
1 parent 3d16399 commit be92f2e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tzatziki-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Then resultArray is equal to:
"""
```

Other custom helpers are foreach (loop through array), split (split a String by symbol), math (compute some value) and conditional helpers (to compare values and output conditionally)
Other custom helpers are foreach (loop through array), split (split a String by symbol), math (compute some value), noIndent (remove indent right before processing to improve visibility) and conditional helpers (to compare values and output conditionally)

## Time management

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public class ObjectSteps {
}).toList();

return options.fn(collectionsToConcat.stream().flatMap(Collection::stream).collect(Collectors.toList()));
});
})
.registerHelper("noIndent", (str, options) -> options.handlebars.compileInline(str.toString().replaceAll("(?m)(?:^\\s+|\\s+$)", "").replaceAll("\\n", "")).apply(options.context));

static {
register(Type.class, TypeParser::parse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,24 @@ Feature: to interact with objects in the context
value: value2
"""

Scenario: noIndent helper can be used to help increase readability in scenario while allowing handlebars to properly interpret the String
Given that helloWorld is "Hello World"
Given that chainedMethodCalls is:
"""
{{noIndent '{{[
helloWorld
.replaceAll(e, 3)
.replaceAll(l, 1)
.replaceAll(o, 0)
]}}'}}
"""
Then chainedMethodCalls is equal to:
"""
H3110 W0r1d
"""

Scenario Template: else guard allows to run a step only if the latest-evaluated condition was false
Given that condition is "<ifCondition>"
When if <ifCondition> == true => ran is "if"
Expand Down Expand Up @@ -945,7 +963,7 @@ Feature: to interact with objects in the context
current_time:
timestamp: '2021-08-01T10:30:00Z'
"""

Scenario: contains should work even if an expected with a map is matched against a non-map (empty string for eg.)
Given that aList is a List<Map>:
"""
Expand Down

0 comments on commit be92f2e

Please sign in to comment.