resolve merge conflict by trusting sdogruyol/master RE property listings

This commit is contained in:
Ben Jolitz 2016-05-07 17:22:08 -07:00
commit b73802df0e
25 changed files with 197 additions and 207 deletions

View file

@ -1,11 +1,28 @@
require "./spec_helper"
describe "Kemal::CommonExceptionHandler" do
it "renders 404 on route not found" do
common_exception_handler = Kemal::CommonExceptionHandler::INSTANCE
request = HTTP::Request.new("GET", "/?message=world")
io_with_context = create_request_and_return_io(common_exception_handler, request)
client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false)
client_response.status_code.should eq 404
end
# it "renders 404 on route not found" do
# get "/" do |env|
# "Hello"
# end
#
# request = HTTP::Request.new("GET", "/asd")
# client_response = call_request_on_app(request)
# client_response.status_code.should eq 404
# end
#
# it "renders custom error" do
# error 403 do
# "403 error"
# end
#
# get "/" do |env|
# env.response.status_code = 403
# end
#
# request = HTTP::Request.new("GET", "/")
# client_response = call_request_on_app(request)
# client_response.status_code.should eq 403
# client_response.body.should eq "403 error"
# end
end

View file

@ -34,4 +34,37 @@ describe "Macros" do
config.logger.should be_a(CustomLogHandler)
end
end
describe "#return_with" do
it "can break block with return_with macro" do
get "/non-breaking" do |env|
"hello"
"world"
end
request = HTTP::Request.new("GET", "/non-breaking")
client_response = call_request_on_app(request)
client_response.status_code.should eq(200)
client_response.body.should eq("world")
get "/breaking" do |env|
return_with env, 404, "hello"
"world"
end
request = HTTP::Request.new("GET", "/breaking")
client_response = call_request_on_app(request)
client_response.status_code.should eq(404)
client_response.body.should eq("hello")
end
it "can break block with return_with macro using default values" do
get "/" do |env|
return_with env
"world"
end
request = HTTP::Request.new("GET", "/")
client_response = call_request_on_app(request)
client_response.status_code.should eq(200)
client_response.body.should eq("")
end
end
end

View file

@ -186,5 +186,5 @@ describe "Kemal::Middleware::Filters" do
end
class FilterTest
property modified
property modified : String?
end

View file

@ -20,7 +20,7 @@ describe "Kemal::RouteHandler" do
end
it "routes request with multiple query strings" do
get "/" do |env|
get "/" do |env|
"hello #{env.params.query["message"]} time #{env.params.query["time"]}"
end
request = HTTP::Request.new("GET", "/?message=world&time=now")

View file

@ -53,5 +53,5 @@ end
Spec.after_each do
Kemal.config.handlers.clear
Kemal::RouteHandler::INSTANCE.tree = Radix::Tree.new
Kemal::RouteHandler::INSTANCE.tree = Radix::Tree(Route).new
end