This commit is contained in:
Sdogruyol 2016-12-10 19:55:26 +03:00
parent 37925cf90c
commit 555804d29a
7 changed files with 35 additions and 19 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
/doc/ /doc/
/libs/ /lib/
/.crystal/ /.crystal/
/.shards/ /.shards/

View file

@ -10,9 +10,9 @@ shards:
multipart: multipart:
github: RX14/multipart.cr github: RX14/multipart.cr
version: 0.1.0 version: 0.1.1
radix: radix:
github: luislavena/radix github: luislavena/radix
version: 0.3.1 version: 0.3.5

View file

@ -1,10 +1,10 @@
name: spec-kemal name: spec-kemal
version: 0.2.0 version: 0.3.0
development_dependencies: development_dependencies:
kemal: kemal:
github: sdogruyol/kemal github: sdogruyol/kemal
branch: v0.16.1 branch: v0.17.3
authors: authors:
- Sdogruyol <dogruyolserdar@gmail.com> - Sdogruyol <dogruyolserdar@gmail.com>

View file

@ -1,14 +1,20 @@
# require "./spec_helper" require "./spec_helper"
# describe "SpecKemalApp" do describe "SpecKemalApp" do
# it "handles get" do it "handles get" do
# get "/" Kemal::RouteHandler::INSTANCE.add_route "GET", "/" do
# response.body.should eq "Hello world" "Hello world"
# end end
get "/"
response.body.should eq "Hello world"
end
# it "handles post" do it "handles post" do
# json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]} Kemal::RouteHandler::INSTANCE.add_route "POST", "/user" do |env|
# post("/user", headers: HTTP::Headers{"Content-Type" => "application/json"}, body: json_body.to_json) env.params.json.to_json
# response.body.should eq(json_body.to_json) end
# end json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
# end post("/user", headers: HTTP::Headers{"Content-Type" => "application/json"}, body: json_body.to_json)
response.body.should eq(json_body.to_json)
end
end

View file

@ -1,3 +1,13 @@
require "spec" require "spec"
require "kemal" require "kemal"
require "../src/spec-kemal" require "../src/spec-kemal"
Spec.before_each do
config = Kemal.config
config.env = "test"
config.setup
end
Spec.after_each do
Kemal.config.clear
end

View file

@ -22,7 +22,7 @@ end
{% end %} {% end %}
def process_request(request) def process_request(request)
io = MemoryIO.new io = IO::Memory.new
response = HTTP::Server::Response.new(io) response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response) context = HTTP::Server::Context.new(request, response)
main_handler = build_main_handler main_handler = build_main_handler

View file

@ -1,3 +1,3 @@
module Spec::Kemal module Spec::Kemal
VERSION = "0.2.0" VERSION = "0.3.0"
end end