WebApiExtension icon indicating copy to clipboard operation
WebApiExtension copied to clipboard

Check only one value in jsonArray

Open Jerome1337 opened this issue 9 years ago • 0 comments

I'm using the And the response should contain json: step, this is working when I check a json body with { "foo": "bar" } But when my body is a jsonArray like this[{ "foo": "bar", "bar": "foo" }] I must send all the correct datas of the first element of the jsonArray to have this step valid. This is problematic when you have a DataTime that change at every data fixtures loading...

I tried to made a custom step in my FeatureContext who will check if there is a jsonArray or not and make the good value check but I need to get the returned response of the request who's not accessible the response in WebApiExtension

Is it possible to check only one value in the first element of a jsonArray with WebApiContext or I must make a custom step ? If I must made a custom step how can I have access to the request response in my FeatureContext ?

This the type of scenario I'm trying to test and making work :

 Scenario: I find all my DNS zones as customer
   Given I am authenticated as customer
   And I send a GET request to "/api/dns"
   Then the response code should be 200
   And the response should contain json:
   """
   [{
     "name":"club-internet.fr"
   }]
   """

Jerome1337 avatar Mar 02 '16 13:03 Jerome1337