From 8c0d4268b9ae2b8e7aadfe290006c28060bb61c8 Mon Sep 17 00:00:00 2001 From: Serdar Dogruyol Date: Mon, 18 Apr 2016 16:51:50 +0300 Subject: [PATCH] 0.2.0 --- README.md | 4 ++-- shard.yml | 2 +- spec/spec-kemal_spec.cr | 4 ++-- src/spec-kemal.cr | 8 +++++++- src/spec-kemal/version.cr | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6f6f44e..b989d1a 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ Now you can easily test your `Kemal` application in your `spec`s. describe "Your::Kemal::App" do # Be sure to start your app in test mode start - + # 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 diff --git a/shard.yml b/shard.yml index 14d5d2b..5ebdcdd 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: spec-kemal -version: 0.1.0 +version: 0.2.0 dependencies: kemal: diff --git a/spec/spec-kemal_spec.cr b/spec/spec-kemal_spec.cr index bbf3dc9..1ff9f73 100644 --- a/spec/spec-kemal_spec.cr +++ b/spec/spec-kemal_spec.cr @@ -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 diff --git a/src/spec-kemal.cr b/src/spec-kemal.cr index 49e5274..dbbba10 100644 --- a/src/spec-kemal.cr +++ b/src/spec-kemal.cr @@ -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 diff --git a/src/spec-kemal/version.cr b/src/spec-kemal/version.cr index 034c9d2..c87e680 100644 --- a/src/spec-kemal/version.cr +++ b/src/spec-kemal/version.cr @@ -1,3 +1,3 @@ module Spec::Kemal - VERSION = "0.1.0" + VERSION = "0.2.0" end