Enable more tests, we pass many of them. Woo!
This also improves failure reporting for specs tests.
This commit is contained in:
@@ -52,10 +52,10 @@ public class SpecRunner extends BlockJUnit4ClassRunner
|
|||||||
private List<FrameworkMethod> computeTests () throws InitializationError {
|
private List<FrameworkMethod> computeTests () throws InitializationError {
|
||||||
String[] groups = new String[] {
|
String[] groups = new String[] {
|
||||||
// "comments",
|
// "comments",
|
||||||
// "delimiters",
|
"delimiters",
|
||||||
"interpolation",
|
"interpolation",
|
||||||
// "inverted",
|
"inverted",
|
||||||
// "sections",
|
"sections",
|
||||||
// "partials"
|
// "partials"
|
||||||
};
|
};
|
||||||
Method m = getTestClassMethod("test", Spec.class);
|
Method m = getTestClassMethod("test", Spec.class);
|
||||||
|
|||||||
@@ -29,11 +29,18 @@ public class SpecTest
|
|||||||
public void test (Spec spec) {
|
public void test (Spec spec) {
|
||||||
loader.setSpec(spec);
|
loader.setSpec(spec);
|
||||||
String tmpl = spec.getTemplate();
|
String tmpl = spec.getTemplate();
|
||||||
Template t = compiler.compile(spec.getTemplate());
|
String desc = String.format("Template: '''%s'''\nData: '%s'\n",
|
||||||
String out = t.execute(spec.getData());
|
uncrlf(tmpl), uncrlf(spec.getData().toString()));
|
||||||
Assert.assertEquals(String.format("When rendering '''%s''' with '%s'",
|
try {
|
||||||
tmpl.replaceAll("\n", "\\\\n"),
|
Template t = compiler.compile(spec.getTemplate());
|
||||||
spec.getData().toString().replaceAll("\n", "\\\\n")),
|
String out = t.execute(spec.getData());
|
||||||
spec.getExpectedOutput(), out);
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user