Skip to content

Commit

Permalink
Update example app's specs
Browse files Browse the repository at this point in the history
  • Loading branch information
oestrich committed Mar 28, 2012
1 parent 3325263 commit 1796088
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 90 deletions.
4 changes: 1 addition & 3 deletions example/Gemfile.lock
@@ -1,7 +1,7 @@
PATH PATH
remote: ../ remote: ../
specs: specs:
rspec_api_documentation (0.4.2) rspec_api_documentation (0.4.3)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
i18n (>= 0.1.0) i18n (>= 0.1.0)
json (>= 1.4.0) json (>= 1.4.0)
Expand Down Expand Up @@ -140,8 +140,6 @@ GEM
multi_json (>= 1.0.2) multi_json (>= 1.0.2)
webmock (1.8.4) webmock (1.8.4)
addressable (>= 2.2.7) addressable (>= 2.2.7)
addressable (>= 2.2.7)
crack (>= 0.1.7)
crack (>= 0.1.7) crack (>= 0.1.7)


PLATFORMS PLATFORMS
Expand Down
8 changes: 4 additions & 4 deletions example/docs/orders/creating_an_order.html
Expand Up @@ -66,7 +66,7 @@ <h4>Headers</h4>
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">POST /orders</pre> <pre class="request route highlight">post /orders</pre>
<h4>Body</h4> <h4>Body</h4>
<pre class="request highlight">order[name]=Order 1 <pre class="request highlight">order[name]=Order 1
order[paid]=true order[paid]=true
Expand All @@ -80,7 +80,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot; E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.028510 X-Runtime: 0.012375
Content-Length: 58</pre> Content-Length: 58</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">201 Created</pre> <pre class="response status">201 Created</pre>
Expand All @@ -92,7 +92,7 @@ <h4>Headers</h4>
Host: example.org Host: example.org
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">GET /orders/1</pre> <pre class="request route highlight">post /orders/1</pre>




<h3>Response</h3> <h3>Response</h3>
Expand All @@ -101,7 +101,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot; E-Tag: &quot;5fffd66f61cdd4ab8881584dbf5e72cf&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.004082 X-Runtime: 0.003699
Content-Length: 58</pre> Content-Length: 58</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">200 OK</pre> <pre class="response status">200 OK</pre>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/creating_an_order.json
@@ -1 +1 @@
{"resource":"Orders","description":"Creating an order","explanation":null,"parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"method":"POST","route":"/orders","request_body":"order[name]=Order 1\norder[paid]=true\norder[email]=email@example.com","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":201,"response_status_text":"Created","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.028510\nContent-Length: 58","curl":null},{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.004082\nContent-Length: 58","curl":null}]} {"resource":"Orders","description":"Creating an order","explanation":null,"parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"method":"POST","route":"/orders","request_body":"order[name]=Order 1\norder[paid]=true\norder[email]=email@example.com","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":201,"response_status_text":"Created","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.012375\nContent-Length: 58","curl":null},{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"5fffd66f61cdd4ab8881584dbf5e72cf\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.003699\nContent-Length: 58","curl":null}]}
23 changes: 2 additions & 21 deletions example/docs/orders/deleting_an_order.html
Expand Up @@ -23,25 +23,6 @@ <h1>Orders API</h1>
<div class="article"> <div class="article">
<h2>Deleting an order</h2> <h2>Deleting an order</h2>


<h3>Parameters</h3>
<table class="parameters">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="name">id</span>
</td>
<td>
<span class="description">ID of order</span>
</td>
</tr>
</tbody>
</table>


<h3>Request</h3> <h3>Request</h3>
<h4>Headers</h4> <h4>Headers</h4>
Expand All @@ -50,7 +31,7 @@ <h4>Headers</h4>
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">DELETE /orders/1</pre> <pre class="request route highlight">delete /orders/1</pre>




<h3>Response</h3> <h3>Response</h3>
Expand All @@ -60,7 +41,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot; E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.003509 X-Runtime: 0.004524
Content-Length: 2</pre> Content-Length: 2</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">200 OK</pre> <pre class="response status">200 OK</pre>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/deleting_an_order.json
@@ -1 +1 @@
{"resource":"Orders","description":"Deleting an order","explanation":null,"parameters":[{"name":"id","description":"ID of order"}],"requests":[{"method":"DELETE","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.003509\nContent-Length: 2","curl":null}]} {"resource":"Orders","description":"Deleting an order","explanation":null,"parameters":[],"requests":[{"method":"DELETE","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.004524\nContent-Length: 2","curl":null}]}
4 changes: 2 additions & 2 deletions example/docs/orders/getting_a_list_of_orders.html
Expand Up @@ -49,7 +49,7 @@ <h4>Headers</h4>
Host: example.org Host: example.org
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">GET /orders?page=1</pre> <pre class="request route highlight">get /orders?page=1</pre>
<h4>Query Parameters</h4> <h4>Query Parameters</h4>
<pre class="request query_parameters highlight">page: 1</pre> <pre class="request query_parameters highlight">page: 1</pre>


Expand All @@ -60,7 +60,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;6cd5831e98b0090b64672b5604d9eb2a&quot; E-Tag: &quot;6cd5831e98b0090b64672b5604d9eb2a&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.061150 X-Runtime: 0.088717
Content-Length: 121</pre> Content-Length: 121</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">200 OK</pre> <pre class="response status">200 OK</pre>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/getting_a_list_of_orders.json
@@ -1 +1 @@
{"resource":"Orders","description":"Getting a list of orders","explanation":null,"parameters":[{"name":"page","description":"Current page of orders"}],"requests":[{"method":"GET","route":"/orders?page=1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":"page: 1","response_status":200,"response_status_text":"OK","response_body":"[{\"email\":\"email0@example.com\",\"name\":\"Order 0\",\"paid\":true},{\"email\":\"email1@example.com\",\"name\":\"Order 1\",\"paid\":true}]","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"6cd5831e98b0090b64672b5604d9eb2a\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.061150\nContent-Length: 121","curl":null}]} {"resource":"Orders","description":"Getting a list of orders","explanation":null,"parameters":[{"name":"page","description":"Current page of orders"}],"requests":[{"method":"GET","route":"/orders?page=1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":"page: 1","response_status":200,"response_status_text":"OK","response_body":"[{\"email\":\"email0@example.com\",\"name\":\"Order 0\",\"paid\":true},{\"email\":\"email1@example.com\",\"name\":\"Order 1\",\"paid\":true}]","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"6cd5831e98b0090b64672b5604d9eb2a\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.088717\nContent-Length: 121","curl":null}]}
23 changes: 2 additions & 21 deletions example/docs/orders/getting_a_specific_order.html
Expand Up @@ -23,33 +23,14 @@ <h1>Orders API</h1>
<div class="article"> <div class="article">
<h2>Getting a specific order</h2> <h2>Getting a specific order</h2>


<h3>Parameters</h3>
<table class="parameters">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="name">id</span>
</td>
<td>
<span class="description">ID of order</span>
</td>
</tr>
</tbody>
</table>


<h3>Request</h3> <h3>Request</h3>
<h4>Headers</h4> <h4>Headers</h4>
<pre class="request headers">Accept: application/json <pre class="request headers">Accept: application/json
Host: example.org Host: example.org
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">GET /orders/1</pre> <pre class="request route highlight">get /orders/1</pre>




<h3>Response</h3> <h3>Response</h3>
Expand All @@ -58,7 +39,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;d9eaba14696a65b9dfc66bf203d25a13&quot; E-Tag: &quot;d9eaba14696a65b9dfc66bf203d25a13&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.002416 X-Runtime: 0.002701
Content-Length: 59</pre> Content-Length: 59</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">200 OK</pre> <pre class="response status">200 OK</pre>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/getting_a_specific_order.json
@@ -1 +1 @@
{"resource":"Orders","description":"Getting a specific order","explanation":null,"parameters":[{"name":"id","description":"ID of order"}],"requests":[{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{\"email\":\"email@example.com\",\"name\":\"Old Name\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"d9eaba14696a65b9dfc66bf203d25a13\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.002416\nContent-Length: 59","curl":null}]} {"resource":"Orders","description":"Getting a specific order","explanation":null,"parameters":[],"requests":[{"method":"GET","route":"/orders/1","request_body":null,"request_headers":"Accept: application/json\nHost: example.org\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{\"email\":\"email@example.com\",\"name\":\"Old Name\",\"paid\":true}","response_headers":"Content-Type: application/json; charset=utf-8\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"d9eaba14696a65b9dfc66bf203d25a13\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.002701\nContent-Length: 59","curl":null}]}
12 changes: 2 additions & 10 deletions example/docs/orders/updating_an_order.html
Expand Up @@ -32,14 +32,6 @@ <h3>Parameters</h3>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td>
<span class="name">id</span>
</td>
<td>
<span class="description">ID of order</span>
</td>
</tr>
<tr> <tr>
<td> <td>
<span class="name">name</span> <span class="name">name</span>
Expand Down Expand Up @@ -74,7 +66,7 @@ <h4>Headers</h4>
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
Cookie: </pre> Cookie: </pre>
<h4>Route</h4> <h4>Route</h4>
<pre class="request route highlight">PUT /orders/1</pre> <pre class="request route highlight">put /orders/1</pre>
<h4>Body</h4> <h4>Body</h4>
<pre class="request highlight">order[name]=Updated Name</pre> <pre class="request highlight">order[name]=Updated Name</pre>


Expand All @@ -86,7 +78,7 @@ <h4>Headers</h4>
X-Ua-Compatible: IE=Edge,chrome=1 X-Ua-Compatible: IE=Edge,chrome=1
E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot; E-Tag: &quot;99914b932bd37a50b983c5e7c90ae93b&quot;
Cache-Control: max-age=0, private, must-revalidate Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.003837 X-Runtime: 0.005005
Content-Length: 2</pre> Content-Length: 2</pre>
<h4>Status</h4> <h4>Status</h4>
<pre class="response status">200 OK</pre> <pre class="response status">200 OK</pre>
Expand Down
2 changes: 1 addition & 1 deletion example/docs/orders/updating_an_order.json
@@ -1 +1 @@
{"resource":"Orders","description":"Updating an order","explanation":null,"parameters":[{"name":"id","description":"ID of order"},{"name":"name","description":"Name of order","scope":"order"},{"name":"paid","description":"If the order has been paid for"},{"name":"email","description":"Email of user that placed the order"}],"requests":[{"method":"PUT","route":"/orders/1","request_body":"order[name]=Updated Name","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.003837\nContent-Length: 2","curl":null}]} {"resource":"Orders","description":"Updating an order","explanation":null,"parameters":[{"name":"name","description":"Name of order","scope":"order"},{"name":"paid","description":"If the order has been paid for","scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"method":"PUT","route":"/orders/1","request_body":"order[name]=Updated Name","request_headers":"Accept: application/json\nHost: example.org\nContent-Type: application/x-www-form-urlencoded\nCookie: ","request_query_parameters":null,"response_status":200,"response_status_text":"OK","response_body":"{}","response_headers":"Content-Type: application/json; charset=utf-8\nLocation: http://example.org/orders/1\nX-Ua-Compatible: IE=Edge,chrome=1\nE-Tag: \"99914b932bd37a50b983c5e7c90ae93b\"\nCache-Control: max-age=0, private, must-revalidate\nX-Runtime: 0.005005\nContent-Length: 2","curl":null}]}
35 changes: 11 additions & 24 deletions example/spec/acceptance/orders_spec.rb
Expand Up @@ -34,17 +34,15 @@
let(:paid) { true } let(:paid) { true }
let(:email) { "email@example.com" } let(:email) { "email@example.com" }


scope_parameters :order, [:name, :paid, :email] scope_parameters :order, :all


example "Creating an order" do example_request "Creating an order" do
do_request

last_response.status.should == 201
response_body.should be_json_eql({ response_body.should be_json_eql({
"name" => name, "name" => name,
"paid" => paid, "paid" => paid,
"email" => email, "email" => email,
}.to_json) }.to_json)
status.should == 201


order = JSON.parse(response_body) order = JSON.parse(response_body)


Expand All @@ -54,20 +52,15 @@
end end


get "/orders/:id" do get "/orders/:id" do
parameter :id, "ID of order"

let(:id) { order.id } let(:id) { order.id }


example "Getting a specific order" do example_request "Getting a specific order" do
do_request response_body.should == order.to_json

status.should == 200
last_response.body.should == order.to_json
last_response.should be_ok
end end
end end


put "/orders/:id" do put "/orders/:id" do
parameter :id, "ID of order"
parameter :name, "Name of order" parameter :name, "Name of order"
parameter :paid, "If the order has been paid for" parameter :paid, "If the order has been paid for"
parameter :email, "Email of user that placed the order" parameter :email, "Email of user that placed the order"
Expand All @@ -76,24 +69,18 @@


let(:name) { "Updated Name" } let(:name) { "Updated Name" }


scope_parameters :order, [:name] scope_parameters :order, :all

example "Updating an order" do
do_request


last_response.should be_ok example_request "Updating an order" do
status.should == 200
end end
end end


delete "/orders/:id" do delete "/orders/:id" do
parameter :id, "ID of order"

let(:id) { order.id } let(:id) { order.id }


example "Deleting an order" do example_request "Deleting an order" do
do_request status.should == 200

last_response.should be_ok
end end
end end
end end

0 comments on commit 1796088

Please sign in to comment.