Enable more tests, we pass many of them. Woo!

This also improves failure reporting for specs tests.
This commit is contained in:
Michael Bayne
2014-12-16 09:45:06 -08:00
parent 79c7fd2cb0
commit 6e53f924ba
2 changed files with 16 additions and 9 deletions
@@ -52,10 +52,10 @@ public class SpecRunner extends BlockJUnit4ClassRunner
private List<FrameworkMethod> computeTests () throws InitializationError {
String[] groups = new String[] {
// "comments",
// "delimiters",
"delimiters",
"interpolation",
// "inverted",
// "sections",
"inverted",
"sections",
// "partials"
};
Method m = getTestClassMethod("test", Spec.class);
@@ -29,11 +29,18 @@ public class SpecTest
public void test (Spec spec) {
loader.setSpec(spec);
String tmpl = spec.getTemplate();
Template t = compiler.compile(spec.getTemplate());
String out = t.execute(spec.getData());
Assert.assertEquals(String.format("When rendering '''%s''' with '%s'",
tmpl.replaceAll("\n", "\\\\n"),
spec.getData().toString().replaceAll("\n", "\\\\n")),
spec.getExpectedOutput(), out);
String desc = String.format("Template: '''%s'''\nData: '%s'\n",
uncrlf(tmpl), uncrlf(spec.getData().toString()));
try {
Template t = compiler.compile(spec.getTemplate());
String out = t.execute(spec.getData());
Assert.assertEquals(desc, uncrlf(spec.getExpectedOutput()), uncrlf(out));
} catch (Exception e) {
Assert.fail(desc + ": " + e);
}
}
private static String uncrlf (String text) {
return (text == null) ? null : text.replace("\r", "\\r").replace("\n", "\\n");
}
}