mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
b638dd1948
* Bump minitest version. * Add basic test helper file. * Use minitest for web server tests. * Use Minitest for unix socket tests. * Use Minitest for ThreadPool tests. * Use Minitest for TCP-Rack tests * Use Minitest for TCPLogger tests. * Add missing helper to test helpers. * Use Minitest for Rack server tests. * Use Minitest for Rack handler tests. * Use Minitest for Puma::Server tests. * Use Minitest for Puma::Server with SSL tests. * Use Minitest for persisten connections tests. * Require puma in test_helper file. * Use minitest for Puma::NullIO tests. * Remove unnecessary requires on test files. * Use Minitest for MiniSSL tests. * Use Minitest for IOBuffer tests. * Require bundler/setup in Rakefile. * Use Minitest for HttpParser tests. * Use Minitest for Puma::Configuration tests. * Use Minitest for Puma::CLI tests. * Bump Minitest version for Ruby 2.1 Gemfile. * Use Minitest for integration tests. * Use Minitest for Puma::App::Status tests. * Remove test-unit from Gemfiles. * Add timeout helper to Minitest::Test. * Use Minitest for Puma::Binder tests. * Remove testhelp file. * Add missing require to Puma::Binder tests. * Prefer require instead of require_relative.
84 lines
1.8 KiB
Ruby
84 lines
1.8 KiB
Ruby
require "test_helper"
|
|
|
|
require "puma/configuration"
|
|
|
|
class TestConfigFile < Minitest::Test
|
|
def test_app_from_rackup
|
|
conf = Puma::Configuration.new do |c|
|
|
c.rackup "test/hello-bind.ru"
|
|
end
|
|
conf.load
|
|
|
|
conf.app
|
|
|
|
assert_equal ["tcp://127.0.0.1:9292"], conf.options[:binds]
|
|
end
|
|
|
|
def test_app_from_app_DSL
|
|
conf = Puma::Configuration.new do |c|
|
|
c.load "test/config/app.rb"
|
|
end
|
|
conf.load
|
|
|
|
app = conf.app
|
|
|
|
assert_equal [200, {}, ["embedded app"]], app.call({})
|
|
end
|
|
|
|
def test_double_bind_port
|
|
port = (rand(10_000) + 30_000).to_s
|
|
with_env("PORT" => port) do
|
|
conf = Puma::Configuration.new do |c|
|
|
c.bind "tcp://#{Puma::Configuration::DefaultTCPHost}:#{port}"
|
|
c.load "test/config/app.rb"
|
|
end
|
|
|
|
conf.load
|
|
|
|
assert_equal ["tcp://0.0.0.0:#{port}"], conf.options[:binds]
|
|
end
|
|
end
|
|
|
|
def test_lowleve_error_handler_DSL
|
|
conf = Puma::Configuration.new do |c|
|
|
c.load "test/config/app.rb"
|
|
end
|
|
conf.load
|
|
|
|
app = conf.options[:lowlevel_error_handler]
|
|
|
|
assert_equal [200, {}, ["error page"]], app.call({})
|
|
end
|
|
|
|
def test_allow_users_to_override_default_options
|
|
conf = Puma::Configuration.new(restart_cmd: 'bin/rails server')
|
|
|
|
assert_equal 'bin/rails server', conf.options[:restart_cmd]
|
|
end
|
|
|
|
def test_overwrite_options
|
|
conf = Puma::Configuration.new do |c|
|
|
c.workers 3
|
|
end
|
|
conf.load
|
|
|
|
assert_equal conf.options[:workers], 3
|
|
conf.options[:workers] += 1
|
|
assert_equal conf.options[:workers], 4
|
|
end
|
|
|
|
private
|
|
|
|
def with_env(env = {})
|
|
original_env = {}
|
|
env.each do |k, v|
|
|
original_env[k] = ENV[k]
|
|
ENV[k] = v
|
|
end
|
|
yield
|
|
ensure
|
|
original_env.each do |k, v|
|
|
ENV[k] = v
|
|
end
|
|
end
|
|
end
|