2015-01-31 14:39:50 +00:00
|
|
|
require "./spec_helper"
|
2014-06-11 23:41:02 +00:00
|
|
|
|
|
|
|
describe "Route" do
|
2015-10-31 07:28:25 +00:00
|
|
|
describe "match?" do
|
|
|
|
it "matches the correct route" do
|
2016-03-21 16:29:48 +00:00
|
|
|
get "/route1" do |env|
|
2015-10-31 07:28:25 +00:00
|
|
|
"Route 1"
|
|
|
|
end
|
2016-03-21 16:29:48 +00:00
|
|
|
get "/route2" do |env|
|
2015-10-31 07:28:25 +00:00
|
|
|
"Route 2"
|
|
|
|
end
|
|
|
|
request = HTTP::Request.new("GET", "/route2")
|
2016-03-21 16:29:48 +00:00
|
|
|
client_response = call_request_on_app(request)
|
2016-01-24 10:22:25 +00:00
|
|
|
client_response.body.should eq("Route 2")
|
2015-10-31 07:28:25 +00:00
|
|
|
end
|
2016-11-04 08:12:35 +00:00
|
|
|
|
|
|
|
it "doesn't allow a route declaration start without /" do
|
|
|
|
expect_raises Kemal::Exceptions::PathStartInvalidException, "Route declaration get \"route\" needs to start with '/', should be get \"/route\"" do
|
|
|
|
get "route" do |env|
|
|
|
|
"Route 1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-06-11 23:41:02 +00:00
|
|
|
end
|
|
|
|
end
|