aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands/server_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/commands/server_test.rb')
-rw-r--r--railties/test/commands/server_test.rb55
1 files changed, 39 insertions, 16 deletions
diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb
index 0c49bd9c53..391886bf33 100644
--- a/railties/test/commands/server_test.rb
+++ b/railties/test/commands/server_test.rb
@@ -1,6 +1,7 @@
-require 'abstract_unit'
-require 'env_helpers'
-require 'rails/commands/server'
+require "abstract_unit"
+require "env_helpers"
+require "rails/command"
+require "rails/commands/server/server_command"
class Rails::ServerTest < ActiveSupport::TestCase
include EnvHelpers
@@ -8,14 +9,14 @@ class Rails::ServerTest < ActiveSupport::TestCase
def test_environment_with_server_option
args = ["thin", "-e", "production"]
options = Rails::Server::Options.new.parse!(args)
- assert_equal 'production', options[:environment]
- assert_equal 'thin', options[:server]
+ assert_equal "production", options[:environment]
+ assert_equal "thin", options[:server]
end
def test_environment_without_server_option
args = ["-e", "production"]
options = Rails::Server::Options.new.parse!(args)
- assert_equal 'production', options[:environment]
+ assert_equal "production", options[:environment]
assert_nil options[:server]
end
@@ -23,23 +24,23 @@ class Rails::ServerTest < ActiveSupport::TestCase
args = ["thin"]
options = Rails::Server::Options.new.parse!(args)
assert_nil options[:environment]
- assert_equal 'thin', options[:server]
+ assert_equal "thin", options[:server]
end
def test_environment_with_rails_env
with_rack_env nil do
- with_rails_env 'production' do
+ with_rails_env "production" do
server = Rails::Server.new
- assert_equal 'production', server.options[:environment]
+ assert_equal "production", server.options[:environment]
end
end
end
def test_environment_with_rack_env
with_rails_env nil do
- with_rack_env 'production' do
+ with_rack_env "production" do
server = Rails::Server.new
- assert_equal 'production', server.options[:environment]
+ assert_equal "production", server.options[:environment]
end
end
end
@@ -51,10 +52,18 @@ class Rails::ServerTest < ActiveSupport::TestCase
end
end
+ def test_environment_with_host
+ switch_env "HOST", "1.2.3.4" do
+ server = Rails::Server.new
+ assert_equal "1.2.3.4", server.options[:Host]
+ end
+ end
+
def test_caching_without_option
args = []
options = Rails::Server::Options.new.parse!(args)
- assert_equal nil, options[:caching]
+ merged_options = Rails::Server.new.default_options.merge(options)
+ assert_equal nil, merged_options[:caching]
end
def test_caching_with_option
@@ -82,25 +91,25 @@ class Rails::ServerTest < ActiveSupport::TestCase
options = Rails::Server::Options.new.parse!(args)
assert_equal false, options[:log_stdout]
- with_rack_env 'development' do
+ with_rack_env "development" do
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal true, options[:log_stdout]
end
- with_rack_env 'production' do
+ with_rack_env "production" do
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal false, options[:log_stdout]
end
- with_rails_env 'development' do
+ with_rails_env "development" do
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal true, options[:log_stdout]
end
- with_rails_env 'production' do
+ with_rails_env "production" do
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal false, options[:log_stdout]
@@ -117,4 +126,18 @@ class Rails::ServerTest < ActiveSupport::TestCase
assert_equal old_default_options, server.default_options
end
end
+
+ def test_restart_command_contains_customized_options
+ original_args = ARGV.dup
+ args = ["-p", "4567"]
+ ARGV.replace args
+
+ options = Rails::Server::Options.new.parse! args
+ server = Rails::Server.new options
+ expected = "bin/rails server -p 4567"
+
+ assert_equal expected, server.default_options[:restart_cmd]
+ ensure
+ ARGV.replace original_args
+ end
end