Started reimplementing router

This commit is contained in:
Sdogruyol 2016-01-12 21:37:12 +02:00
parent 38089ab84e
commit 0b4a36953f
6 changed files with 40 additions and 67 deletions

View file

@ -2,24 +2,24 @@ require "./spec_helper"
describe "Route" do
describe "match?" do
it "doesn't match because of route" do
route = Route.new("GET", "/foo/bar") { "" }
request = HTTP::Request.new("GET", "/world?message=coco")
route.match?(request).should be_nil
end
it "doesn't match because of method" do
route = Route.new("GET", "/foo/bar") { "" }
request = HTTP::Request.new("POST", "/foo/bar")
route.match?(request).should be_nil
end
it "matches" do
route = Route.new("GET", "/foo/:one/path/:two") { "" }
request = HTTP::Request.new("GET", "/foo/uno/path/dos")
match = route.match?(request)
match.should eq true
end
# it "doesn't match because of route" do
# route = Route.new("GET", "/foo/bar") { "" }
# request = HTTP::Request.new("GET", "/world?message=coco")
# route.match?(request).should be_nil
# end
#
# it "doesn't match because of method" do
# route = Route.new("GET", "/foo/bar") { "" }
# request = HTTP::Request.new("POST", "/foo/bar")
# route.match?(request).should be_nil
# end
#
# it "matches" do
# route = Route.new("GET", "/foo/:one/path/:two") { "" }
# request = HTTP::Request.new("GET", "/foo/uno/path/dos")
# match = route.match?(request)
# match.should eq true
# end
it "matches the correct route" do
kemal = Kemal::Handler.new