Rename MemoryIO to IO::Memory since it's deprecated on Crystal 0.20.0

This commit is contained in:
sdogruyol 2016-11-22 23:29:10 +03:00
parent 733582f724
commit 6b034c3b2f
8 changed files with 18 additions and 18 deletions

View file

@ -7,7 +7,7 @@ describe "Kemal::CommonExceptionHandler" do
end end
request = HTTP::Request.new("GET", "/asd") request = HTTP::Request.new("GET", "/asd")
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)
Kemal::CommonExceptionHandler::INSTANCE.call(context) Kemal::CommonExceptionHandler::INSTANCE.call(context)
@ -25,7 +25,7 @@ describe "Kemal::CommonExceptionHandler" do
env.response.status_code = 403 env.response.status_code = 403
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE
@ -46,7 +46,7 @@ describe "Kemal::CommonExceptionHandler" do
env.response.status_code = 500 env.response.status_code = 500
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE
@ -68,7 +68,7 @@ describe "Kemal::CommonExceptionHandler" do
env.response.status_code = 500 env.response.status_code = 500
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE
@ -90,7 +90,7 @@ describe "Kemal::CommonExceptionHandler" do
env.response.status_code = 500 env.response.status_code = 500
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE Kemal::CommonExceptionHandler::INSTANCE.next = Kemal::RouteHandler::INSTANCE

View file

@ -3,7 +3,7 @@ require "./spec_helper"
describe "Kemal::CommonLogHandler" do describe "Kemal::CommonLogHandler" do
it "logs to the given IO" do it "logs to the given IO" do
config = Kemal.config config = Kemal.config
io = MemoryIO.new io = IO::Memory.new
logger = Kemal::CommonLogHandler.new io logger = Kemal::CommonLogHandler.new io
logger.write "Something" logger.write "Something"
io.to_s.should eq "Something" io.to_s.should eq "Something"
@ -11,8 +11,8 @@ describe "Kemal::CommonLogHandler" do
it "creates log message for each request" do it "creates log message for each request" do
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
io = MemoryIO.new io = IO::Memory.new
context_io = MemoryIO.new context_io = IO::Memory.new
response = HTTP::Server::Response.new(context_io) response = HTTP::Server::Response.new(context_io)
context = HTTP::Server::Context.new(request, response) context = HTTP::Server::Context.new(request, response)
logger = Kemal::CommonLogHandler.new io logger = Kemal::CommonLogHandler.new io

View file

@ -49,7 +49,7 @@ describe "Context" do
} }
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::Middleware::Filter::INSTANCE.call(context) Kemal::Middleware::Filter::INSTANCE.call(context)

View file

@ -3,7 +3,7 @@ require "./spec_helper"
describe "Kemal::InitHandler" do describe "Kemal::InitHandler" do
it "initializes context with Content-Type: text/html" do it "initializes context with Content-Type: text/html" do
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::InitHandler::INSTANCE.next = ->(context : HTTP::Server::Context) {} Kemal::InitHandler::INSTANCE.next = ->(context : HTTP::Server::Context) {}
@ -13,7 +13,7 @@ describe "Kemal::InitHandler" do
it "initializes context with X-Powered-By: Kemal" do it "initializes context with X-Powered-By: Kemal" do
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
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)
Kemal::InitHandler::INSTANCE.call(context) Kemal::InitHandler::INSTANCE.call(context)

View file

@ -62,7 +62,7 @@ describe "Kemal::Middleware::CSRF" do
end end
def process_request(handler, request) def process_request(handler, 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)
handler.call(context) handler.call(context)

View file

@ -13,7 +13,7 @@ class CustomLogHandler < Kemal::BaseLogHandler
end end
def create_request_and_return_io(handler, request) def create_request_and_return_io(handler, 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)
handler.call(context) handler.call(context)
@ -23,20 +23,20 @@ def create_request_and_return_io(handler, request)
end end
def create_ws_request_and_return_io(handler, request) def create_ws_request_and_return_io(handler, 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)
begin begin
handler.call context handler.call context
rescue IO::Error rescue IO::Error
# Raises because the MemoryIO is empty # Raises because the IO::Memory is empty
end end
response.close response.close
io io
end end
def call_request_on_app(request) def call_request_on_app(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,7 +1,7 @@
require "./spec_helper" require "./spec_helper"
private def handle(request, fallthrough = true) private def handle(request, fallthrough = true)
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)
handler = Kemal::StaticFileHandler.new "#{__DIR__}/static", fallthrough handler = Kemal::StaticFileHandler.new "#{__DIR__}/static", fallthrough

View file

@ -33,7 +33,7 @@ CONTENT_FOR_BLOCKS = Hash(String, Tuple(String, Proc(String))).new
# setting the appropriate set of tags that should be added to the layout. # setting the appropriate set of tags that should be added to the layout.
macro content_for(key, file = __FILE__) macro content_for(key, file = __FILE__)
%proc = ->() { %proc = ->() {
__kilt_io__ = MemoryIO.new __kilt_io__ = IO::Memory.new
{{ yield }} {{ yield }}
__kilt_io__.to_s __kilt_io__.to_s
} }