spec-kemal/spec/spec-kemal_spec.cr

21 lines
589 B
Crystal
Raw Normal View History

2016-12-10 16:55:26 +00:00
require "./spec_helper"
2016-04-09 14:37:46 +00:00
2016-12-10 16:55:26 +00:00
describe "SpecKemalApp" do
it "handles get" do
Kemal::RouteHandler::INSTANCE.add_route "GET", "/" do
"Hello world"
end
get "/"
response.body.should eq "Hello world"
end
2016-04-09 14:37:46 +00:00
2016-12-10 16:55:26 +00:00
it "handles post" do
Kemal::RouteHandler::INSTANCE.add_route "POST", "/user" do |env|
env.params.json.to_json
end
json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
post("/user", headers: HTTP::Headers{"Content-Type" => "application/json"}, body: json_body.to_json)
response.body.should eq(json_body.to_json)
end
end