0.2.0
This commit is contained in:
parent
4abdf39037
commit
8c0d4268b9
5 changed files with 13 additions and 7 deletions
|
@ -53,7 +53,7 @@ describe "Your::Kemal::App" do
|
|||
|
||||
# You can use get,post,put,patch,delete to call the corresponding route.
|
||||
it "renders /" do
|
||||
response = get "/"
|
||||
get "/"
|
||||
response.body.should eq "Hello World!"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: spec-kemal
|
||||
version: 0.1.0
|
||||
version: 0.2.0
|
||||
|
||||
dependencies:
|
||||
kemal:
|
||||
|
|
|
@ -4,13 +4,13 @@ describe "SpecKemalApp" do
|
|||
start
|
||||
|
||||
it "handles get" do
|
||||
response = get "/"
|
||||
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)
|
||||
post("/user", headers: HTTP::Headers{"Content-Type": "application/json"}, body: json_body.to_json)
|
||||
response.body.should eq(json_body.to_json)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ Kemal.config.host_binding = APP_HOST_BINDING
|
|||
Kemal.config.port = APP_PORT
|
||||
Kemal.config.logging = false
|
||||
|
||||
$response : HTTP::Client::Response?
|
||||
|
||||
def start
|
||||
spawn do
|
||||
Kemal.run
|
||||
|
@ -27,6 +29,10 @@ end
|
|||
|
||||
{% for method in %w(get post put head delete patch) %}
|
||||
def {{method.id}}(path, headers : HTTP::Headers? = nil, body : String? = nil)
|
||||
HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
||||
$response = HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
||||
end
|
||||
{% end %}
|
||||
|
||||
def response
|
||||
$response.not_nil!
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Spec::Kemal
|
||||
VERSION = "0.1.0"
|
||||
VERSION = "0.2.0"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue