sahaya / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Add hamcrest matcher for path expressions #288

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example

{
   "id" : "id", 
    "_links": {
        "self": {
            "href": "http://localhost:8080/"
        }
    }
}

Add support for:

get("/x").then().assertThat().body("_links.self.href", 
equalTo("http://localhost:8080/"+path("id")));

Original issue reported on code.google.com by johan.ha...@gmail.com on 5 Dec 2013 at 12:42

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
We probably need to add something more generic, e.g.

get("/x").then().assertThat().body("_links.self.href", new 
ResponseAwareMatcher() {
      public Matcher<String> matcher(Response r) {
           return equalTo("http://localhost:8080/"+r.path("id"));
      }                      
});

Original comment by johan.ha...@gmail.com on 15 Jan 2014 at 4:09

GoogleCodeExporter commented 9 years ago
Static methods can also be added, e.g.

.body("_links.self.href", ResponseAwareMatcher .equalToPath("id"))
.body("_links.self.href", ResponseAwareMatcher .endsWithPath("id"))
.body("_links.self.href", ResponseAwareMatcher .containsPath("id"))
..

Would be nice if it could be combined with formatter (String.format) somehow.

Also the returned Matcher must be of type Object

Original comment by johan.ha...@gmail.com on 16 Jan 2014 at 6:18

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 22 Jan 2014 at 1:57