2012-03-20 19:28:30 -04:00
|
|
|
require 'abstract_unit'
|
2012-12-06 07:05:45 -05:00
|
|
|
require 'env_helpers'
|
2012-03-20 19:28:30 -04:00
|
|
|
require 'rails/commands/server'
|
|
|
|
|
|
|
|
class Rails::ServerTest < ActiveSupport::TestCase
|
2012-12-06 07:05:45 -05:00
|
|
|
include EnvHelpers
|
2012-03-20 19:28:30 -04:00
|
|
|
|
|
|
|
def test_environment_with_server_option
|
2012-05-15 05:37:54 -04:00
|
|
|
args = ["thin", "-e", "production"]
|
2012-03-20 19:28:30 -04:00
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal 'production', options[:environment]
|
|
|
|
assert_equal 'thin', options[:server]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_environment_without_server_option
|
2012-05-15 05:37:54 -04:00
|
|
|
args = ["-e", "production"]
|
2012-03-20 19:28:30 -04:00
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal 'production', options[:environment]
|
|
|
|
assert_nil options[:server]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_server_option_without_environment
|
|
|
|
args = ["thin"]
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_nil options[:environment]
|
|
|
|
assert_equal 'thin', options[:server]
|
|
|
|
end
|
2012-12-05 12:05:33 -05:00
|
|
|
|
|
|
|
def test_environment_with_rails_env
|
2013-10-12 14:27:13 -04:00
|
|
|
with_rack_env nil do
|
|
|
|
with_rails_env 'production' do
|
|
|
|
server = Rails::Server.new
|
|
|
|
assert_equal 'production', server.options[:environment]
|
|
|
|
end
|
2012-12-06 07:05:45 -05:00
|
|
|
end
|
2012-12-05 12:05:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_environment_with_rack_env
|
2013-10-12 14:27:13 -04:00
|
|
|
with_rails_env nil do
|
|
|
|
with_rack_env 'production' do
|
|
|
|
server = Rails::Server.new
|
|
|
|
assert_equal 'production', server.options[:environment]
|
|
|
|
end
|
2012-12-06 07:05:45 -05:00
|
|
|
end
|
2012-12-05 12:05:33 -05:00
|
|
|
end
|
2013-06-18 16:24:00 -04:00
|
|
|
|
|
|
|
def test_log_stdout
|
2013-10-12 14:27:13 -04:00
|
|
|
with_rack_env nil do
|
|
|
|
with_rails_env nil do
|
|
|
|
args = []
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal true, options[:log_stdout]
|
2013-06-18 16:24:00 -04:00
|
|
|
|
2013-10-12 14:27:13 -04:00
|
|
|
args = ["-e", "development"]
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal true, options[:log_stdout]
|
|
|
|
|
|
|
|
args = ["-e", "production"]
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal false, options[:log_stdout]
|
|
|
|
|
|
|
|
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
|
|
|
|
args = []
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal false, options[:log_stdout]
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
args = []
|
|
|
|
options = Rails::Server::Options.new.parse!(args)
|
|
|
|
assert_equal false, options[:log_stdout]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-06-18 16:24:00 -04:00
|
|
|
end
|
2012-03-20 19:28:30 -04:00
|
|
|
end
|