Domanda

I'm trying to check my api implementation with my documentation written in blueprint. I've expected that dredd will fail when json returned from server will be different than specified in documentation. To check this I've copied dredd-example. First I've run dredd with original apib file to make sure that all is green. Then I've modified response in documentation and expected dredd to show me some red... But it doesn't.... it looks like tool is only checking response headers but not the response body. Here is output from console:

pass: GET /machines duration: 18ms
request:
host: localhost
port: 3000
path: /machines
method: GET
headers:
    User-Agent: Dredd/0.2.1 (Darwin 13.0.0; x64)



    expected:
    headers:
        Content-Type: application/json

    body:
    [
      {
        "_id": "52341870ed55224b15ff07ef",
        "type": "bulldozer",
        "name": "willyxxxxxx"  #HERE IS WHERE I CHANGED RESPONSE IN DOCUMENTATION
      }
    ]
    status: 200


    actual:
    headers:
        x-powered-by: Express
        content-type: application/json
        content-length: 95
        date: Thu, 20 Mar 2014 08:22:40 GMT
        connection: keep-alive

    body:
    [
      {
        "_id": "532aa5507dcdfff362931799",
        "type": "bulldozer",
        "name": "willy"
      }
    ]
    status: 200

Can I check response body using dredd? And how can I do this?

È stato utile?

Soluzione

In JSON bodies Dredd is checking only for keys not for values. When you change key in the expected JSON body document, it will definitely fails.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top