imbo / behat-api-extension

API extension for Behat, used to ease testing of JSON-based APIs
MIT License
109 stars 42 forks source link

How to check multi dimensional arrays? #13

Closed dzschille closed 8 years ago

dzschille commented 8 years ago

I have an response body like this:

{
    "customer":{
        "id":"12345",
        "name":"Behat Testing API",
        "images":[{
            "id":"5678",
            "filename_client":"tech.ai",
            "filename_preview":"testimage-converted.png",
            "filename_print":"testimage.ai",
            "url":"\/media\/testimage-converted.png",
            "created_time":"2016-10-10 07:28:42"
        },
        {
            "id":"7890",
            "filename_client":"demo.ai",
            "filename_preview":"demoimage-converted.png",
            "filename_print":"demoimage.ai",
            "url":"\/media\/demoimage-converted.png",
            "created_time":"2016-10-10 07:38:22"
        }]
    }
}

And i want to check if "filename_client" == "tech.ai", so i use

Then the response body contains:
      """
        {
          "customer": {
            "images[0]": {
              "filename_client": "tech.ai"
            }
          }
        }
      """

This doesn't work. What am i doing wrong?

christeredvartsen commented 8 years ago

Could you please try to upgrade to 1.0-dev and see if that helps? I have added a couple of test cases using your haystack and needle, and it should work as expected now.

dzschille commented 8 years ago

Works great, thanks for the quick fix! Also the message in case of a mismatch is nice.

btw: i tested with "1.0.x-dev".