hmpatel / rest-assured

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

Add JSONP support #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
E.g. 

expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");

But perhaps it's better/easier to do something like:

expect().jsonp("callback", "y").body("root.child", 
equalTo("x")).when().get("/jsonp");

or:

expect().jsonp("callback").body("root.child", 
equalTo("x")).when().get("/jsonp"); 

which should generate a random method-name.

It should also be possible to set it as default:

RestAssured.expectedParser = jsonp("callback", "y");
RestAssured.expectedParser = jsonp("callback");
RestAssured.expectedParser = auto(); // Default

There should also be a JsonpPath that simply extends JsonPath and removes 
method call.

Original issue reported on code.google.com by johan.ha...@gmail.com on 10 Mar 2011 at 2:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If using:

expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");

we can try to detect whether or not the response is JSONP or plain JSON by e.g. 
using reg exp.

Original comment by johan.ha...@gmail.com on 10 Mar 2011 at 2:03

GoogleCodeExporter commented 9 years ago
We could also try to identify jsonp in JsonPath using the reg exp

Original comment by johan.ha...@gmail.com on 10 Mar 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Perhaps jsonp spec should be in the request spec instead? E.g.

given().
         jsonp("callback").
expect().
         body("root.child", equalTo("x")).
when().
         get("/jsonp"); 

Original comment by johan.ha...@gmail.com on 22 Mar 2011 at 6:15

GoogleCodeExporter commented 9 years ago
Perhaps it should be a filter?

Original comment by johan.ha...@gmail.com on 22 May 2011 at 8:46