shard-kemal/spec/param_parser_spec.cr

17 lines
470 B
Crystal
Raw Normal View History

2015-10-28 18:30:27 +00:00
require "./spec_helper"
describe "ParamParser" do
it "parses params" do
kemal = Kemal::Handler.new
kemal.add_route "POST", "/" do |env|
name = env.params["name"]
age = env.params["age"]
hasan = env.params["hasan"]
"Hello #{name} #{hasan} #{age}"
end
request = HTTP::Request.new("POST", "/?hasan=cemal", body: "name=kemal&age=99")
response = kemal.call(request)
response.body.should eq("Hello kemal cemal 99")
end
end