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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
require 'abstract_unit'
require 'env_helpers'
require 'rails/commands/server'
class Rails::ServerTest < ActiveSupport::TestCase
include EnvHelpers
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]
end
def test_environment_without_server_option
args = ["-e", "production"]
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
def test_environment_with_rails_env
with_rack_env nil do
with_rails_env 'production' do
server = Rails::Server.new
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
server = Rails::Server.new
assert_equal 'production', server.options[:environment]
end
end
end
def test_environment_with_port
switch_env "PORT", "1234" do
server = Rails::Server.new
assert_equal 1234, server.options[:Port]
end
end
def test_caching_without_option
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal nil, options[:caching]
end
def test_caching_with_option
args = ["--dev-caching"]
options = Rails::Server::Options.new.parse!(args)
assert_equal true, options[:caching]
args = ["--no-dev-caching"]
options = Rails::Server::Options.new.parse!(args)
assert_equal false, options[:caching]
end
def test_log_stdout
with_rack_env nil do
with_rails_env nil do
args = []
options = Rails::Server::Options.new.parse!(args)
assert_equal true, options[:log_stdout]
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
end
def test_default_options
server = Rails::Server.new
old_default_options = server.default_options
Dir.chdir("..") do
assert_equal old_default_options, server.default_options
end
end
end
|