Skip to content

Commit 2fa5493

Browse files
authored
Merge pull request rails#48949 from skipkayhil/hm-fix-suggesting-missing-gems
Do not suggest adding non-existent gems to Gemfile
2 parents 5cf742e + 92b7162 commit 2fa5493

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

railties/lib/rails/commands/server/server_command.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ module Command
9494
class ServerCommand < Base # :nodoc:
9595
include EnvironmentArgument
9696

97+
RACK_HANDLER_GEMS = %w(cgi webrick scgi thin puma unicorn falcon)
9798
# Hard-coding a bunch of handlers here as we don't have a public way of
9899
# querying them from the Rack::Handler registry.
99-
RACK_SERVERS = %w(cgi fastcgi webrick lsws scgi thin puma unicorn falcon)
100+
RACK_HANDLERS = RACK_HANDLER_GEMS + %w(fastcgi lsws)
100101
RECOMMENDED_SERVER = "puma"
101102

102103
DEFAULT_PORT = 3000
@@ -259,7 +260,7 @@ def rack_server_suggestion(server)
259260
260261
Run `#{executable} --help` for more options.
261262
MSG
262-
elsif server.in?(RACK_SERVERS)
263+
elsif server.in?(RACK_HANDLER_GEMS)
263264
<<~MSG
264265
Could not load server "#{server}". Maybe you need to the add it to the Gemfile?
265266
@@ -268,7 +269,7 @@ def rack_server_suggestion(server)
268269
Run `#{executable} --help` for more options.
269270
MSG
270271
else
271-
error = CorrectableNameError.new("Could not find server '#{server}'.", server, RACK_SERVERS)
272+
error = CorrectableNameError.new("Could not find server '#{server}'.", server, RACK_HANDLERS)
272273
<<~MSG
273274
#{error.detailed_message}
274275
Run `#{executable} --help` for more options.

railties/test/commands/server_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ def test_using_known_server_that_isnt_in_the_gemfile
5050
assert_match(/Could not load server "unicorn". Maybe you need to the add it to the Gemfile/, run_command("-u", "unicorn"))
5151
end
5252

53+
def test_gem_not_suggested_when_name_not_same_as_handler
54+
build_app
55+
56+
["fastcgi", "lsws"].each do |server|
57+
output = rails "server", "-u", server
58+
assert_match(/Could not find server '#{server}'./, output)
59+
assert_no_match("Gemfile", output)
60+
end
61+
ensure
62+
teardown_app
63+
end
64+
5365
def test_daemon_with_option
5466
args = ["-d"]
5567
options = parse_arguments(args)

0 commit comments

Comments
 (0)