Fixes for Crystal 0.19
This commit is contained in:
parent
8c0d4268b9
commit
f2659b06fd
|
@ -10,7 +10,7 @@ describe "SpecKemalApp" do
|
||||||
|
|
||||||
it "handles post" do
|
it "handles post" do
|
||||||
json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
|
json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
|
||||||
post("/user", headers: HTTP::Headers{"Content-Type": "application/json"}, body: json_body.to_json)
|
post("/user", headers: HTTP::Headers{"Content-Type" => "application/json"}, body: json_body.to_json)
|
||||||
response.body.should eq(json_body.to_json)
|
response.body.should eq(json_body.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ end
|
||||||
post "/user" do |env|
|
post "/user" do |env|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
name = env.params.json["name"]
|
name = env.params.json["name"]
|
||||||
age = env.params.json["age"] as Int
|
age = env.params.json["age"]
|
||||||
skills = env.params.json["skills"] as Array
|
skills = env.params.json["skills"]
|
||||||
{"name": name, "age": age, "skills": skills}.to_json
|
{"name": name, "age": age, "skills": skills}.to_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,17 @@ Kemal.config.host_binding = APP_HOST_BINDING
|
||||||
Kemal.config.port = APP_PORT
|
Kemal.config.port = APP_PORT
|
||||||
Kemal.config.logging = false
|
Kemal.config.logging = false
|
||||||
|
|
||||||
$response : HTTP::Client::Response?
|
class Global
|
||||||
|
@@response : HTTP::Client::Response?
|
||||||
|
|
||||||
|
def self.response=(@@response)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.response
|
||||||
|
@@response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
spawn do
|
spawn do
|
||||||
|
@ -29,10 +39,10 @@ end
|
||||||
|
|
||||||
{% for method in %w(get post put head delete patch) %}
|
{% for method in %w(get post put head delete patch) %}
|
||||||
def {{method.id}}(path, headers : HTTP::Headers? = nil, body : String? = nil)
|
def {{method.id}}(path, headers : HTTP::Headers? = nil, body : String? = nil)
|
||||||
$response = HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
Global.response = HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
def response
|
def response
|
||||||
$response.not_nil!
|
Global.response.not_nil!
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue