0.4.0
This commit is contained in:
parent
37925cf90c
commit
555804d29a
7 changed files with 35 additions and 19 deletions
|
@ -1,14 +1,20 @@
|
|||
# require "./spec_helper"
|
||||
require "./spec_helper"
|
||||
|
||||
# describe "SpecKemalApp" do
|
||||
# it "handles get" do
|
||||
# get "/"
|
||||
# response.body.should eq "Hello world"
|
||||
# end
|
||||
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
|
||||
|
||||
# it "handles post" do
|
||||
# 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
|
||||
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
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
require "spec"
|
||||
require "kemal"
|
||||
require "../src/spec-kemal"
|
||||
|
||||
Spec.before_each do
|
||||
config = Kemal.config
|
||||
config.env = "test"
|
||||
config.setup
|
||||
end
|
||||
|
||||
Spec.after_each do
|
||||
Kemal.config.clear
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue