kemal/spec/route_spec.cr
Zamith 8cf04b58ca
Move static file handler to be called after the instance handler
This way only routes that are not caught by the instance handler will go
through to the static file handler.
2015-01-31 14:39:50 +00:00

21 lines
619 B
Crystal

require "./spec_helper"
describe "Route" do
describe "match" do
it "doesn't match because of route" do
route = Route.new("GET", "/foo/bar") { "" }
route.match("GET", "/foo/baz".split("/")).should be_nil
end
it "doesn't match because of method" do
route = Route.new("GET", "/foo/bar") { "" }
route.match("POST", "/foo/bar".split("/")).should be_nil
end
it "matches" do
route = Route.new("GET", "/foo/:one/path/:two") { "" }
params = route.match("GET", "/foo/uno/path/dos".split("/"))
params.should eq({"one" => "uno", "two" => "dos"})
end
end
end