mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
9d93a0f62f
running `rake` loads all files starting with `test_` which is not supposed to also load the helper, since the helper should be loaded by each test and is not a test itself.
39 lines
949 B
Ruby
39 lines
949 B
Ruby
require_relative "helper"
|
|
|
|
require "puma/events"
|
|
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
|