Same as
#body(String,java.util.List,org.hamcrest.Matcher,Object...) expect that you can pass arguments to the path. This
is useful in situations where you have e.g. pre-defined variables that constitutes the path:
String someSubPath = "else";
int index = 1;
expect().body("something.%s[%d]", withArgs(someSubPath, index), equalTo("some value")). ..
or if you have complex root paths and don't wish to duplicate the path for small variations:
expect().
root("filters.filterConfig[%d].filterConfigGroups.find { it.name == 'Gold' }.includes").
body(withArgs(0), hasItem("first")).
body(withArgs(1), hasItem("second")).
..
The path and arguments follows the standard formatting syntax of Java.
Note that withArgs
can be statically imported from the com.jayway.restassured.RestAssured
class.