forked from postrank-labs/goliath
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added spec for rack routes. The 'uses API middleware' spec is failing…
… because middleware for a routed API is not being used.
- Loading branch information
1 parent
9be3c62
commit 2aa199a
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# encoding: utf-8 | ||
require 'spec_helper' | ||
require File.join(File.dirname(__FILE__), '../../', 'examples/rack_routes') | ||
|
||
describe RackRoutes do | ||
let(:err) { Proc.new { fail "API request failed" } } | ||
|
||
it 'routes to the correct API' do | ||
with_api(RackRoutes) do | ||
get_request({:path => '/bonjour'}, err) do |c| | ||
c.response_header.status.should == 200 | ||
c.response.should == 'bonjour!' | ||
end | ||
end | ||
end | ||
|
||
it 'routes to the default' do | ||
with_api(RackRoutes) do | ||
get_request({:path => '/donkey'}, err) do |c| | ||
c.response_header.status.should == 404 | ||
c.response.should == 'Try /version /hello_world, /bonjour, or /hola' | ||
end | ||
end | ||
end | ||
|
||
it 'uses API middleware' do | ||
with_api(RackRoutes) do | ||
post_request({:path => '/hola'}, err) do |c| | ||
# the /hola route only supports GET requests | ||
c.response_header.status.should == 400 | ||
c.response.should == '[:error, "Invalid request method"]' | ||
end | ||
end | ||
end | ||
end |