Add specs
This commit is contained in:
parent
a318920bcc
commit
f3b6bdadf0
2 changed files with 25 additions and 4 deletions
|
@ -1,9 +1,16 @@
|
||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
describe Spec::Kemal do
|
describe "SpecKemalApp" do
|
||||||
# TODO: Write tests
|
start
|
||||||
|
|
||||||
it "works" do
|
it "handles get" do
|
||||||
false.should eq(true)
|
response = get "/"
|
||||||
|
response.body.should eq "Hello world"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "handles post" do
|
||||||
|
json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
|
||||||
|
response = post("/user", headers: HTTP::Headers{"Content-Type": "application/json"}, body: json_body.to_json)
|
||||||
|
response.body.should eq(json_body.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,16 @@
|
||||||
require "spec"
|
require "spec"
|
||||||
|
require "kemal"
|
||||||
require "../src/spec-kemal"
|
require "../src/spec-kemal"
|
||||||
|
|
||||||
|
# Create a dummy app
|
||||||
|
get "/" do
|
||||||
|
"Hello world"
|
||||||
|
end
|
||||||
|
|
||||||
|
post "/user" do |env|
|
||||||
|
env.response.content_type = "application/json"
|
||||||
|
name = env.params.json["name"]
|
||||||
|
age = env.params.json["age"] as Int
|
||||||
|
skills = env.params.json["skills"] as Array
|
||||||
|
{"name": name, "age": age, "skills": skills}.to_json
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue