Commit 488dfd99 authored by Theodor Tonum's avatar Theodor Tonum

Merge pull request #1 from apiaryio/master

Working example with latest Dredd and single blueprint 
parents 6d28206b a4cc782c
# Dredd + Rails test
# Dredd + Rails example
1. Run `bundle install`
1. Run `bundle install && rake db:migrate`
2. Install dredd `npm install dredd -g`
3. Start rails server with `rails s`
4. Run `dredd fails.md http://localhost:3000`
5. You'll see a 400 bad request in the Rails logs.
4. Run `$ dredd apiary.apib http://localhost:3000`
5. You'll see a 201 created in the Rails logs.
This happens most likely due to [how Rails parses json][ref1].
6. Tests will pas and exit status will be `0` :
```
$ echo $?
0
```
Rails [seems to rely][ref2] on the `Content-Length` http header being set.
[ref1]: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/params_parser.rb#L44
[ref2]: https://github.com/rails/rails/blob/5f3b40e824cce3f6dcdfac63fa47bcd80d67dd5a/actionpack/lib/action_dispatch/http/request.rb#L185
Maybe Dredd should add the `Content-Length` header?
## Successful example
1. Run `dredd success.md http://localhost:3000`
2. You'll see a 201 created in the Rails logs.
......@@ -22,3 +22,12 @@ FORMAT: 1A
}
+ Response 201
```
{
"title": "My post title",
"content": "Some content",
"created_at": "2013-11-01T16:18:08.275Z",
"updated_at":"2013-11-01T16:18:08.275Z"
}
```
FORMAT: 1A
# Rails + Dredd proof of concept
# Posts [/posts]
## Creating a POST [POST]
+ Request (application/json)
+ Headers
Accept: application/json
+ Body
{
"post": {
"title": "My post title",
"content": "Some content"
}
}
+ Response 201
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment