1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/test_tcp_logger.rb
Eileen M. Uchitelle 6714214d57 Require puma/events in test helper (#1418)
Moves the require for puma/events from the individual test files and
into the main test helper.

The reason for this was while I was debugging the `test_puma_server.rb`
tests I was getting an error for an uninitialized constant for
`Puma::Event`.

Moving the require from the individual files to the test help means the
`puma/events` will always be included instead of having to remember to
do that. It makes debugging individual tests locally easier.
2017-09-23 05:44:21 +09:00

38 lines
927 B
Ruby

require_relative "helper"
require "puma/tcp_logger"
class TestTCPLogger < Minitest::Test
def setup
@events = Puma::Events.new STDOUT, STDERR
@server = Puma::Server.new nil, @events
@server.app = proc { |env, socket|}
@server.tcp_mode!
@socket = nil
end
def test_events
# in lib/puma/launcher.rb:85
# Puma::Events is default tcp_logger for cluster mode
logger = Puma::Events.new(STDOUT, STDERR)
out, err = capture_subprocess_io do
Puma::TCPLogger.new(logger, @server.app).call({}, @socket)
end
assert_match(/connected/, out)
assert_equal('', err)
end
def test_io
# in lib/puma/configuration.rb:184
# STDOUT is default tcp_logger for single mode
logger = STDOUT
out, err = capture_subprocess_io do
Puma::TCPLogger.new(logger, @server.app).call({}, @socket)
end
assert_match(/connected/, out)
assert_equal('', err)
end
end