shard-kemal/spec/route_spec.cr

26 lines
686 B
Crystal
Raw Normal View History

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
it "doesn't allow a route declaration start without /" do
expect_raises Kemal::Exceptions::InvalidPathStartException, "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