diff --git a/src/test/java/com/hubspot/jinjava/ExpectedNodeInterpreter.java b/src/test/java/com/hubspot/jinjava/ExpectedNodeInterpreter.java index 404bbf41f..ca438fed1 100644 --- a/src/test/java/com/hubspot/jinjava/ExpectedNodeInterpreter.java +++ b/src/test/java/com/hubspot/jinjava/ExpectedNodeInterpreter.java @@ -26,7 +26,8 @@ public ExpectedNodeInterpreter(JinjavaInterpreter interpreter, Tag tag, String p public String assertExpectedOutput(String name) { TagNode tagNode = (TagNode) fixture(name); String output = tag.interpret(tagNode, interpreter); - assertThat(output.trim()).isEqualTo(expected(name).trim()); + assertThat(ExpectedTemplateInterpreter.prettify(output.trim())) + .isEqualTo(ExpectedTemplateInterpreter.prettify(expected(name).trim())); return output; } @@ -34,9 +35,11 @@ public Node fixture(String name) { try { return new TreeParser( interpreter, - Resources.toString( - Resources.getResource(String.format("%s/%s.jinja", path, name)), - StandardCharsets.UTF_8 + ExpectedTemplateInterpreter.simplify( + Resources.toString( + Resources.getResource(String.format("%s/%s.jinja", path, name)), + StandardCharsets.UTF_8 + ) ) ) .buildTree() @@ -49,9 +52,11 @@ public Node fixture(String name) { public String expected(String name) { try { - return Resources.toString( - Resources.getResource(String.format("%s/%s.expected.jinja", path, name)), - StandardCharsets.UTF_8 + return ExpectedTemplateInterpreter.simplify( + Resources.toString( + Resources.getResource(String.format("%s/%s.expected.jinja", path, name)), + StandardCharsets.UTF_8 + ) ); } catch (IOException e) { throw new RuntimeException(e); diff --git a/src/test/java/com/hubspot/jinjava/ExpectedTemplateInterpreter.java b/src/test/java/com/hubspot/jinjava/ExpectedTemplateInterpreter.java index 916ad9fb6..2d60db617 100644 --- a/src/test/java/com/hubspot/jinjava/ExpectedTemplateInterpreter.java +++ b/src/test/java/com/hubspot/jinjava/ExpectedTemplateInterpreter.java @@ -114,7 +114,7 @@ public String assertExpectedNonEagerOutput(String name) { return output; } - private String prettify(String string) { + static String prettify(String string) { return string.replaceAll("([}%]})([^\\s])", "$1\\\\\n$2"); } @@ -144,7 +144,7 @@ private String expected(String name) { } } - private String simplify(String prettified) { + static String simplify(String prettified) { return prettified.replaceAll("\\\\\n\\s*", ""); }