Skip to content

Commit

Permalink
Tweak the test
Browse files Browse the repository at this point in the history
  • Loading branch information
dentarg committed Oct 29, 2021
1 parent 1efbb6e commit 388141a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/test_puma_server.rb
Expand Up @@ -363,6 +363,17 @@ def test_lowlevel_error_message
assert (data.size > 0), "Expected response message to be not empty"
end

def test_lowlevel_error_handler_custom_response
options = { lowlevel_error_handler: ->(_err) { [200, {}, ["error page"]] } }
# setting the headers argument to nil will trigger exception inside Puma
broken_app = ->(_env) { [200, nil, []] }
server_run(**options, &broken_app)

data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"

assert_match %r{HTTP/1.0 200 OK\r\nContent-Length: 10\r\n\r\nerror page}, data
end

def test_force_shutdown_error_default
server_run(force_shutdown_after: 2) do
@server.stop
Expand Down Expand Up @@ -1362,15 +1373,4 @@ def test_rack_url_scheme_user
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"
assert_equal "user", data.split("\r\n").last
end

# The server should send lowlevel_error handlers response to the client
def test_lowlevel_error_handler
options = { lowlevel_error_handler: ->(err) { [200, {}, ["error page"]] } }
app = ->(env) { [200, nil, []] }
server_run(**options, &app)

data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"

assert_match /error page/, data
end
end

0 comments on commit 388141a

Please sign in to comment.