0.2.0
This commit is contained in:
parent
4abdf39037
commit
8c0d4268b9
5 changed files with 13 additions and 7 deletions
|
@ -50,10 +50,10 @@ Now you can easily test your `Kemal` application in your `spec`s.
|
||||||
describe "Your::Kemal::App" do
|
describe "Your::Kemal::App" do
|
||||||
# Be sure to start your app in test mode
|
# Be sure to start your app in test mode
|
||||||
start
|
start
|
||||||
|
|
||||||
# You can use get,post,put,patch,delete to call the corresponding route.
|
# You can use get,post,put,patch,delete to call the corresponding route.
|
||||||
it "renders /" do
|
it "renders /" do
|
||||||
response = get "/"
|
get "/"
|
||||||
response.body.should eq "Hello World!"
|
response.body.should eq "Hello World!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: spec-kemal
|
name: spec-kemal
|
||||||
version: 0.1.0
|
version: 0.2.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
kemal:
|
kemal:
|
||||||
|
|
|
@ -4,13 +4,13 @@ describe "SpecKemalApp" do
|
||||||
start
|
start
|
||||||
|
|
||||||
it "handles get" do
|
it "handles get" do
|
||||||
response = get "/"
|
get "/"
|
||||||
response.body.should eq "Hello world"
|
response.body.should eq "Hello world"
|
||||||
end
|
end
|
||||||
|
|
||||||
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"]}
|
||||||
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)
|
response.body.should eq(json_body.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,8 @@ 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?
|
||||||
|
|
||||||
def start
|
def start
|
||||||
spawn do
|
spawn do
|
||||||
Kemal.run
|
Kemal.run
|
||||||
|
@ -27,6 +29,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)
|
||||||
HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
$response = HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
|
def response
|
||||||
|
$response.not_nil!
|
||||||
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Spec::Kemal
|
module Spec::Kemal
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.2.0"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue