blob: f3a7e00a4db2988d95978de8c295be4c2c5a0e8e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# frozen_string_literal: true
require "isolation/abstract_unit"
require "console_helpers"
require "rails/command"
require "rails/commands/server/server_command"
module ApplicationTests
class ServerTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
include ConsoleHelpers
def setup
build_app
end
def teardown
teardown_app
end
test "deprecate support of older `config.ru`" do
remove_file "config.ru"
app_file "config.ru", <<-RUBY
require_relative 'config/environment'
run AppTemplate::Application
RUBY
server = Rails::Server.new(config: "#{app_path}/config.ru")
server.app
log = File.read(Rails.application.config.paths["log"].first)
assert_match(/DEPRECATION WARNING: Using `Rails::Application` subclass to start the server is deprecated/, log)
end
test "restart rails server with custom pid file path" do
skip "PTY unavailable" unless available_pty?
File.open("#{app_path}/config/boot.rb", "w") do |f|
f.puts "ENV['BUNDLE_GEMFILE'] = '#{Bundler.default_gemfile.to_s}'"
f.puts "require 'bundler/setup'"
end
master, slave = PTY.open
pid = nil
begin
pid = Process.spawn("#{app_path}/bin/rails server -P tmp/dummy.pid", in: slave, out: slave, err: slave)
assert_output("Listening", master)
rails("restart")
assert_output("Restarting", master)
assert_output("Inherited", master)
ensure
kill(pid) if pid
end
end
private
def kill(pid)
Process.kill("TERM", pid)
Process.wait(pid)
rescue Errno::ESRCH
end
end
end
|