apiaryio/dredd — pull request #5 by ecordell (2013-10-23 22:45:21+00:00)
Title: HTTPS support, global header injection, improved reporter output

This pull request does a few things:

- Adds support for https (requests use the https module if the server url begins with https)
- Allows injecting global headers through dredd configuration, like so:

```coffee
dredd = new Dredd {
blueprintPath : './blueprint.md'
server: 'https://foo.bar/'
request:
headers:
'X-Api-Key' : '111-222-333-444-555-666'
options:
reporter: 'junit'
debug: false
}
```

- Improves error messages
- Example cli output:

```bash

fail: GET /foo/bar/?aq=test
fail: headers: Value of the ‘content-type’ must be application/json.
body: Real and expected data does not match.

request:
{
"host": "foo.bar",
"port": null,
"path": "/foo/bar/?aq=test",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"User-Agent": "Dredd/0.1.3 (Darwin 12.4.0; x64)",
"X-Api-Key": "111-222-333-444-555-666"
}
}

expected:
{
"headers": {
"Content-Type": "application/json"
},
"body": "",
"statusCode": "200"
}

actual:
{
"headers": {
"content-type": "text/html",
"date": "Wed, 23 Oct 2013 22:30:48 GMT",
"server": "nginx/1.4.1",
"vary": "Cookie",
"content-length": "7486",
"connection": "keep-alive"
},
"body": "error",
"status": 404
}
```

- XUnit output much better as well.

This might be enough to support basic auth (#3), though I haven't tried it, and you'd need to construct the Authorization header yourself and pass it in (username:password encoded in base64). I only needed https and custom headers, so that's all I added.

I'm using bamboo's [Junit Parser](https://confluence.atlassian.com/display/BAMBOO/JUnit+parsing+in+Bamboo) as the template for the junit reporter's output, and have made some changes to improve that as well.

Coverage went down just a bit :/ but it's still pretty good!

I plan to remove the cli library from everything but bin/dredd and use another logger internally. Using cli everywhere has made it so that passing in silent or debug flags when consuming dredd in another app doesn't work. Plus using something like winston means you could have custom log levels. That will be a separate pull request though!