From ee61ecfdf1c3f1432cf11036474f57326d8456de Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Sun, 10 Apr 2016 14:36:06 +0300 Subject: [PATCH] Add get,post,put,head,delete,patch to easily perform requests --- src/spec-kemal.cr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/spec-kemal.cr b/src/spec-kemal.cr index 96f5475..851cafd 100644 --- a/src/spec-kemal.cr +++ b/src/spec-kemal.cr @@ -4,6 +4,7 @@ require "kemal" TIME_TO_SLEEP = 0.00001 APP_PORT = 1989 APP_ENV = "test" +APP_URL = "http://localhost:#{APP_PORT}" Kemal.config.env = APP_ENV Kemal.config.port = APP_PORT @@ -21,3 +22,9 @@ Spec.after_each do Kemal.config.server.close end 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) + end +{% end %}