kemal/spec/route_spec.cr

22 lines
619 B
Crystal
Raw Normal View History

require "./spec_helper"
2014-06-11 23:41:02 +00:00
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
2014-06-11 23:41:02 +00:00
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"})
2014-06-11 23:41:02 +00:00
end
end
end