sinatra-sinatra 0.9.1.2 → 0.9.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,155 +6,158 @@ end
6
6
  class FooNotFound < Sinatra::NotFound
7
7
  end
8
8
 
9
- describe 'Exception Mappings' do
10
- it 'invokes handlers registered with ::error when raised' do
11
- mock_app {
12
- set :raise_errors, false
13
- error(FooError) { 'Foo!' }
14
- get '/' do
15
- raise FooError
16
- end
17
- }
18
- get '/'
19
- assert_equal 500, status
20
- assert_equal 'Foo!', body
21
- end
22
-
23
- it 'uses the Exception handler if no matching handler found' do
24
- mock_app {
25
- set :raise_errors, false
26
- error(Exception) { 'Exception!' }
27
- get '/' do
28
- raise FooError
29
- end
30
- }
31
- get '/'
32
- assert_equal 500, status
33
- assert_equal 'Exception!', body
34
- end
35
-
36
- it "sets env['sinatra.error'] to the rescued exception" do
37
- mock_app {
38
- set :raise_errors, false
39
- error(FooError) {
40
- assert env.include?('sinatra.error')
41
- assert env['sinatra.error'].kind_of?(FooError)
42
- 'looks good'
9
+ class MappedErrorTest < Test::Unit::TestCase
10
+ describe 'Exception Mappings' do
11
+ it 'invokes handlers registered with ::error when raised' do
12
+ mock_app {
13
+ set :raise_errors, false
14
+ error(FooError) { 'Foo!' }
15
+ get '/' do
16
+ raise FooError
17
+ end
18
+ }
19
+ get '/'
20
+ assert_equal 500, status
21
+ assert_equal 'Foo!', body
22
+ end
23
+
24
+ it 'uses the Exception handler if no matching handler found' do
25
+ mock_app {
26
+ set :raise_errors, false
27
+ error(Exception) { 'Exception!' }
28
+ get '/' do
29
+ raise FooError
30
+ end
43
31
  }
44
- get '/' do
45
- raise FooError
46
- end
47
- }
48
- get '/'
49
- assert_equal 'looks good', body
50
- end
51
-
52
- it 'dumps errors to rack.errors when dump_errors is enabled' do
53
- mock_app {
54
- set :raise_errors, false
55
- set :dump_errors, true
56
- get('/') { raise FooError, 'BOOM!' }
57
- }
58
-
59
- get '/'
60
- assert_equal 500, status
61
- assert @response.errors =~ /FooError - BOOM!:/
62
- end
63
-
64
- it "raises without calling the handler when the raise_errors options is set" do
65
- mock_app {
66
- set :raise_errors, true
67
- error(FooError) { "she's not there." }
68
- get '/' do
69
- raise FooError
70
- end
71
- }
72
- assert_raise(FooError) { get '/' }
73
- end
74
-
75
- it "never raises Sinatra::NotFound beyond the application" do
76
- mock_app {
77
- set :raise_errors, true
78
- get '/' do
79
- raise Sinatra::NotFound
80
- end
81
- }
82
- assert_nothing_raised { get '/' }
83
- assert_equal 404, status
84
- end
85
-
86
- it "cascades for subclasses of Sinatra::NotFound" do
87
- mock_app {
88
- set :raise_errors, true
89
- error(FooNotFound) { "foo! not found." }
90
- get '/' do
91
- raise FooNotFound
92
- end
93
- }
94
- assert_nothing_raised { get '/' }
95
- assert_equal 404, status
96
- assert_equal 'foo! not found.', body
97
- end
98
-
99
- it 'has a not_found method for backwards compatibility' do
100
- mock_app {
101
- not_found do
102
- "Lost, are we?"
103
- end
104
- }
105
-
106
- get '/test'
107
- assert_equal 404, status
108
- assert_equal "Lost, are we?", body
109
- end
110
- end
111
32
 
112
- describe 'Custom Error Pages' do
113
- it 'allows numeric status code mappings to be registered with ::error' do
114
- mock_app {
115
- set :raise_errors, false
116
- error(500) { 'Foo!' }
117
- get '/' do
118
- [500, {}, 'Internal Foo Error']
119
- end
120
- }
121
- get '/'
122
- assert_equal 500, status
123
- assert_equal 'Foo!', body
124
- end
33
+ get '/'
34
+ assert_equal 500, status
35
+ assert_equal 'Exception!', body
36
+ end
37
+
38
+ it "sets env['sinatra.error'] to the rescued exception" do
39
+ mock_app {
40
+ set :raise_errors, false
41
+ error(FooError) {
42
+ assert env.include?('sinatra.error')
43
+ assert env['sinatra.error'].kind_of?(FooError)
44
+ 'looks good'
45
+ }
46
+ get '/' do
47
+ raise FooError
48
+ end
49
+ }
50
+ get '/'
51
+ assert_equal 'looks good', body
52
+ end
53
+
54
+ it 'dumps errors to rack.errors when dump_errors is enabled' do
55
+ mock_app {
56
+ set :raise_errors, false
57
+ set :dump_errors, true
58
+ get('/') { raise FooError, 'BOOM!' }
59
+ }
125
60
 
126
- it 'allows ranges of status code mappings to be registered with :error' do
127
- mock_app {
128
- set :raise_errors, false
129
- error(500..550) { "Error: #{response.status}" }
130
- get '/' do
131
- [507, {}, 'A very special error']
132
- end
133
- }
134
- get '/'
135
- assert_equal 507, status
136
- assert_equal 'Error: 507', body
137
- end
61
+ get '/'
62
+ assert_equal 500, status
63
+ assert @response.errors =~ /FooError - BOOM!:/
64
+ end
65
+
66
+ it "raises without calling the handler when the raise_errors options is set" do
67
+ mock_app {
68
+ set :raise_errors, true
69
+ error(FooError) { "she's not there." }
70
+ get '/' do
71
+ raise FooError
72
+ end
73
+ }
74
+ assert_raise(FooError) { get '/' }
75
+ end
76
+
77
+ it "never raises Sinatra::NotFound beyond the application" do
78
+ mock_app {
79
+ set :raise_errors, true
80
+ get '/' do
81
+ raise Sinatra::NotFound
82
+ end
83
+ }
84
+ assert_nothing_raised { get '/' }
85
+ assert_equal 404, status
86
+ end
87
+
88
+ it "cascades for subclasses of Sinatra::NotFound" do
89
+ mock_app {
90
+ set :raise_errors, true
91
+ error(FooNotFound) { "foo! not found." }
92
+ get '/' do
93
+ raise FooNotFound
94
+ end
95
+ }
96
+ assert_nothing_raised { get '/' }
97
+ assert_equal 404, status
98
+ assert_equal 'foo! not found.', body
99
+ end
100
+
101
+ it 'has a not_found method for backwards compatibility' do
102
+ mock_app {
103
+ not_found do
104
+ "Lost, are we?"
105
+ end
106
+ }
138
107
 
139
- class FooError < RuntimeError
108
+ get '/test'
109
+ assert_equal 404, status
110
+ assert_equal "Lost, are we?", body
111
+ end
140
112
  end
141
113
 
142
- it 'runs after exception mappings and overwrites body' do
143
- mock_app {
144
- set :raise_errors, false
145
- error FooError do
146
- response.status = 502
147
- 'from exception mapping'
148
- end
149
- error(500) { 'from 500 handler' }
150
- error(502) { 'from custom error page' }
151
-
152
- get '/' do
153
- raise FooError
154
- end
155
- }
156
- get '/'
157
- assert_equal 502, status
158
- assert_equal 'from custom error page', body
114
+ describe 'Custom Error Pages' do
115
+ it 'allows numeric status code mappings to be registered with ::error' do
116
+ mock_app {
117
+ set :raise_errors, false
118
+ error(500) { 'Foo!' }
119
+ get '/' do
120
+ [500, {}, 'Internal Foo Error']
121
+ end
122
+ }
123
+ get '/'
124
+ assert_equal 500, status
125
+ assert_equal 'Foo!', body
126
+ end
127
+
128
+ it 'allows ranges of status code mappings to be registered with :error' do
129
+ mock_app {
130
+ set :raise_errors, false
131
+ error(500..550) { "Error: #{response.status}" }
132
+ get '/' do
133
+ [507, {}, 'A very special error']
134
+ end
135
+ }
136
+ get '/'
137
+ assert_equal 507, status
138
+ assert_equal 'Error: 507', body
139
+ end
140
+
141
+ class FooError < RuntimeError
142
+ end
143
+
144
+ it 'runs after exception mappings and overwrites body' do
145
+ mock_app {
146
+ set :raise_errors, false
147
+ error FooError do
148
+ response.status = 502
149
+ 'from exception mapping'
150
+ end
151
+ error(500) { 'from 500 handler' }
152
+ error(502) { 'from custom error page' }
153
+
154
+ get '/' do
155
+ raise FooError
156
+ end
157
+ }
158
+ get '/'
159
+ assert_equal 502, status
160
+ assert_equal 'from custom error page', body
161
+ end
159
162
  end
160
163
  end
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- describe "Middleware" do
4
- before do
3
+ class MiddlewareTest < Test::Unit::TestCase
4
+ setup do
5
5
  @app = mock_app(Sinatra::Default) {
6
6
  get '/*' do
7
7
  response.headers['X-Tests'] = env['test.ran'].
@@ -1,37 +1,39 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- describe 'Options' do
4
- before do
5
- restore_default_options
6
- @app = Sinatra.new
3
+ class OptionsTest < Test::Unit::TestCase
4
+ setup do
5
+ @base = Sinatra.new(Sinatra::Base)
6
+ @default = Sinatra.new(Sinatra::Default)
7
+ @base.set :environment, :development
8
+ @default.set :environment, :development
7
9
  end
8
10
 
9
11
  it 'sets options to literal values' do
10
- @app.set(:foo, 'bar')
11
- assert @app.respond_to?(:foo)
12
- assert_equal 'bar', @app.foo
12
+ @base.set(:foo, 'bar')
13
+ assert @base.respond_to?(:foo)
14
+ assert_equal 'bar', @base.foo
13
15
  end
14
16
 
15
17
  it 'sets options to Procs' do
16
- @app.set(:foo, Proc.new { 'baz' })
17
- assert @app.respond_to?(:foo)
18
- assert_equal 'baz', @app.foo
18
+ @base.set(:foo, Proc.new { 'baz' })
19
+ assert @base.respond_to?(:foo)
20
+ assert_equal 'baz', @base.foo
19
21
  end
20
22
 
21
23
  it "sets multiple options with a Hash" do
22
- @app.set :foo => 1234,
24
+ @base.set :foo => 1234,
23
25
  :bar => 'Hello World',
24
26
  :baz => Proc.new { 'bizzle' }
25
- assert_equal 1234, @app.foo
26
- assert_equal 'Hello World', @app.bar
27
- assert_equal 'bizzle', @app.baz
27
+ assert_equal 1234, @base.foo
28
+ assert_equal 'Hello World', @base.bar
29
+ assert_equal 'bizzle', @base.baz
28
30
  end
29
31
 
30
32
  it 'inherits option methods when subclassed' do
31
- @app.set :foo, 'bar'
32
- @app.set :biz, Proc.new { 'baz' }
33
+ @base.set :foo, 'bar'
34
+ @base.set :biz, Proc.new { 'baz' }
33
35
 
34
- sub = Class.new(@app)
36
+ sub = Class.new(@base)
35
37
  assert sub.respond_to?(:foo)
36
38
  assert_equal 'bar', sub.foo
37
39
  assert sub.respond_to?(:biz)
@@ -39,31 +41,31 @@ describe 'Options' do
39
41
  end
40
42
 
41
43
  it 'overrides options in subclass' do
42
- @app.set :foo, 'bar'
43
- @app.set :biz, Proc.new { 'baz' }
44
- sub = Class.new(@app)
44
+ @base.set :foo, 'bar'
45
+ @base.set :biz, Proc.new { 'baz' }
46
+ sub = Class.new(@base)
45
47
  sub.set :foo, 'bling'
46
48
  assert_equal 'bling', sub.foo
47
- assert_equal 'bar', @app.foo
49
+ assert_equal 'bar', @base.foo
48
50
  end
49
51
 
50
52
  it 'creates setter methods when first defined' do
51
- @app.set :foo, 'bar'
52
- assert @app.respond_to?('foo=')
53
- @app.foo = 'biz'
54
- assert_equal 'biz', @app.foo
53
+ @base.set :foo, 'bar'
54
+ assert @base.respond_to?('foo=')
55
+ @base.foo = 'biz'
56
+ assert_equal 'biz', @base.foo
55
57
  end
56
58
 
57
59
  it 'creates predicate methods when first defined' do
58
- @app.set :foo, 'hello world'
59
- assert @app.respond_to?(:foo?)
60
- assert @app.foo?
61
- @app.set :foo, nil
62
- assert !@app.foo?
60
+ @base.set :foo, 'hello world'
61
+ assert @base.respond_to?(:foo?)
62
+ assert @base.foo?
63
+ @base.set :foo, nil
64
+ assert !@base.foo?
63
65
  end
64
66
 
65
67
  it 'uses existing setter methods if detected' do
66
- class << @app
68
+ class << @base
67
69
  def foo
68
70
  @foo
69
71
  end
@@ -72,255 +74,294 @@ describe 'Options' do
72
74
  end
73
75
  end
74
76
 
75
- @app.set :foo, 'bam'
76
- assert_equal 'oops', @app.foo
77
+ @base.set :foo, 'bam'
78
+ assert_equal 'oops', @base.foo
77
79
  end
78
80
 
79
81
  it "sets multiple options to true with #enable" do
80
- @app.enable :sessions, :foo, :bar
81
- assert @app.sessions
82
- assert @app.foo
83
- assert @app.bar
82
+ @base.enable :sessions, :foo, :bar
83
+ assert @base.sessions
84
+ assert @base.foo
85
+ assert @base.bar
84
86
  end
85
87
 
86
88
  it "sets multiple options to false with #disable" do
87
- @app.disable :sessions, :foo, :bar
88
- assert !@app.sessions
89
- assert !@app.foo
90
- assert !@app.bar
89
+ @base.disable :sessions, :foo, :bar
90
+ assert !@base.sessions
91
+ assert !@base.foo
92
+ assert !@base.bar
91
93
  end
92
94
 
93
95
  it 'enables MethodOverride middleware when :methodoverride is enabled' do
94
- @app.set :methodoverride, true
95
- @app.put('/') { 'okay' }
96
+ @base.set :methodoverride, true
97
+ @base.put('/') { 'okay' }
98
+ @app = @base
96
99
  post '/', {'_method'=>'PUT'}, {}
97
100
  assert_equal 200, status
98
101
  assert_equal 'okay', body
99
102
  end
100
- end
101
103
 
102
- describe_option 'clean_trace' do
103
- def clean_backtrace(trace)
104
- @base.new.send(:clean_backtrace, trace)
105
- end
104
+ describe 'clean_trace' do
105
+ def clean_backtrace(trace)
106
+ Sinatra::Base.new.send(:clean_backtrace, trace)
107
+ end
106
108
 
107
- it 'is enabled on Base' do
108
- assert @base.clean_trace?
109
- end
109
+ it 'is enabled on Base' do
110
+ assert @base.clean_trace?
111
+ end
110
112
 
111
- it 'is enabled on Default' do
112
- assert @default.clean_trace?
113
- end
113
+ it 'is enabled on Default' do
114
+ assert @default.clean_trace?
115
+ end
114
116
 
115
- it 'does nothing when disabled' do
116
- backtrace = [
117
- "./lib/sinatra/base.rb",
118
- "./myapp:42",
119
- ("#{Gem.dir}/some/lib.rb" if defined?(Gem))
120
- ].compact
121
- @base.set :clean_trace, false
122
- assert_equal backtrace, clean_backtrace(backtrace)
123
- end
117
+ it 'does nothing when disabled' do
118
+ backtrace = [
119
+ "./lib/sinatra/base.rb",
120
+ "./myapp:42",
121
+ ("#{Gem.dir}/some/lib.rb" if defined?(Gem))
122
+ ].compact
124
123
 
125
- it 'removes sinatra lib paths from backtrace when enabled' do
126
- backtrace = [
127
- "./lib/sinatra/base.rb",
128
- "./lib/sinatra/compat.rb:42",
129
- "./lib/sinatra/main.rb:55 in `foo'"
130
- ]
131
- assert clean_backtrace(backtrace).empty?
132
- end
124
+ klass = Class.new(Sinatra::Base)
125
+ klass.disable :clean_trace
133
126
 
134
- it 'removes ./ prefix from backtrace paths when enabled' do
135
- assert_equal ['myapp.rb:42'], clean_backtrace(['./myapp.rb:42'])
136
- end
127
+ assert_equal backtrace, klass.new.send(:clean_backtrace, backtrace)
128
+ end
137
129
 
138
- if defined?(Gem)
139
- it 'removes gem lib paths from backtrace when enabled' do
140
- assert clean_backtrace(["#{Gem.dir}/some/lib"]).empty?
130
+ it 'removes sinatra lib paths from backtrace when enabled' do
131
+ backtrace = [
132
+ "./lib/sinatra/base.rb",
133
+ "./lib/sinatra/compat.rb:42",
134
+ "./lib/sinatra/main.rb:55 in `foo'"
135
+ ]
136
+ assert clean_backtrace(backtrace).empty?
137
+ end
138
+
139
+ it 'removes ./ prefix from backtrace paths when enabled' do
140
+ assert_equal ['myapp.rb:42'], clean_backtrace(['./myapp.rb:42'])
141
141
  end
142
- end
143
- end
144
142
 
145
- describe_option 'run' do
146
- it 'is disabled on Base' do
147
- assert ! @base.run?
143
+ if defined?(Gem)
144
+ it 'removes gem lib paths from backtrace when enabled' do
145
+ assert clean_backtrace(["#{Gem.dir}/some/lib"]).empty?
146
+ end
147
+ end
148
148
  end
149
149
 
150
- it 'is enabled on Default when not in test environment' do
151
- assert @default.development?
152
- assert @default.run?
150
+ describe 'run' do
151
+ it 'is disabled on Base' do
152
+ assert ! @base.run?
153
+ end
153
154
 
154
- @default.set :environment, :development
155
- assert @default.run?
156
- end
155
+ it 'is enabled on Default when not in test environment' do
156
+ @default.set :environment, :development
157
+ assert @default.development?
158
+ assert @default.run?
157
159
 
158
- # TODO: it 'is enabled when $0 == app_file'
159
- end
160
+ @default.set :environment, :development
161
+ assert @default.run?
162
+ end
160
163
 
161
- describe_option 'raise_errors' do
162
- it 'is enabled on Base' do
163
- assert @base.raise_errors?
164
+ # TODO: it 'is enabled when $0 == app_file'
164
165
  end
165
166
 
166
- it 'is enabled on Default only in test' do
167
- @default.set(:environment, :development)
168
- assert @default.development?
169
- assert ! @default.raise_errors?, "disabled development"
167
+ describe 'raise_errors' do
168
+ it 'is enabled on Base' do
169
+ assert @base.raise_errors?
170
+ end
170
171
 
171
- @default.set(:environment, :production)
172
- assert ! @default.raise_errors?
172
+ it 'is enabled on Default only in test' do
173
+ @default.set(:environment, :development)
174
+ assert @default.development?
175
+ assert ! @default.raise_errors?
173
176
 
174
- @default.set(:environment, :test)
175
- assert @default.raise_errors?
176
- end
177
- end
177
+ @default.set(:environment, :production)
178
+ assert ! @default.raise_errors?
178
179
 
179
- describe_option 'dump_errors' do
180
- it 'is disabled on Base' do
181
- assert ! @base.dump_errors?
180
+ @default.set(:environment, :test)
181
+ assert @default.raise_errors?
182
+ end
182
183
  end
183
184
 
184
- it 'is enabled on Default' do
185
- assert @default.dump_errors?
186
- end
185
+ describe 'show_exceptions' do
186
+ it 'is enabled on Default only in development' do
187
+ @base.set(:environment, :development)
188
+ assert @base.show_exceptions?
187
189
 
188
- it 'dumps exception with backtrace to rack.errors' do
189
- Sinatra::Default.disable(:raise_errors)
190
+ assert @default.development?
191
+ assert @default.show_exceptions?
190
192
 
191
- mock_app(Sinatra::Default) {
192
- error do
193
- error = @env['rack.errors'].instance_variable_get(:@error)
194
- error.rewind
193
+ @default.set(:environment, :test)
194
+ assert ! @default.show_exceptions?
195
195
 
196
- error.read
197
- end
196
+ @base.set(:environment, :production)
197
+ assert ! @base.show_exceptions?
198
+ end
198
199
 
199
- get '/' do
200
- raise
201
- end
202
- }
200
+ it 'returns a friendly 500' do
201
+ klass = Sinatra.new(Sinatra::Default)
202
+ mock_app(klass) {
203
+ enable :show_exceptions
203
204
 
204
- get '/'
205
- assert body.include?("RuntimeError") && body.include?("options_test.rb")
206
- end
207
- end
205
+ get '/' do
206
+ raise StandardError
207
+ end
208
+ }
208
209
 
209
- describe_option 'sessions' do
210
- it 'is disabled on Base' do
211
- assert ! @base.sessions?
210
+ get '/'
211
+ assert_equal 500, status
212
+ assert body.include?("StandardError")
213
+ assert body.include?("<code>show_exceptions</code> option")
214
+ end
212
215
  end
213
216
 
214
- it 'is disabled on Default' do
215
- assert ! @default.sessions?
216
- end
217
+ describe 'dump_errors' do
218
+ it 'is disabled on Base' do
219
+ assert ! @base.dump_errors?
220
+ end
217
221
 
218
- # TODO: it 'uses Rack::Session::Cookie when enabled' do
219
- end
222
+ it 'is enabled on Default' do
223
+ assert @default.dump_errors?
224
+ end
220
225
 
221
- describe_option 'logging' do
222
- it 'is disabled on Base' do
223
- assert ! @base.logging?
224
- end
226
+ it 'dumps exception with backtrace to rack.errors' do
227
+ klass = Sinatra.new(Sinatra::Default)
225
228
 
226
- it 'is enabled on Default when not in test environment' do
227
- assert @default.logging?
229
+ mock_app(klass) {
230
+ disable :raise_errors
228
231
 
229
- @default.set :environment, :test
230
- assert ! @default.logging
232
+ error do
233
+ error = @env['rack.errors'].instance_variable_get(:@error)
234
+ error.rewind
235
+
236
+ error.read
237
+ end
238
+
239
+ get '/' do
240
+ raise
241
+ end
242
+ }
243
+
244
+ get '/'
245
+ assert body.include?("RuntimeError") && body.include?("options_test.rb")
246
+ end
231
247
  end
232
248
 
233
- # TODO: it 'uses Rack::CommonLogger when enabled' do
234
- end
249
+ describe 'sessions' do
250
+ it 'is disabled on Base' do
251
+ assert ! @base.sessions?
252
+ end
253
+
254
+ it 'is disabled on Default' do
255
+ assert ! @default.sessions?
256
+ end
235
257
 
236
- describe_option 'static' do
237
- it 'is disabled on Base' do
238
- assert ! @base.static?
258
+ # TODO: it 'uses Rack::Session::Cookie when enabled' do
239
259
  end
240
260
 
241
- it 'is enabled on Default' do
242
- assert @default.static?
261
+ describe 'logging' do
262
+ it 'is disabled on Base' do
263
+ assert ! @base.logging?
264
+ end
265
+
266
+ it 'is enabled on Default when not in test environment' do
267
+ assert @default.logging?
268
+
269
+ @default.set :environment, :test
270
+ assert ! @default.logging
271
+ end
272
+
273
+ # TODO: it 'uses Rack::CommonLogger when enabled' do
243
274
  end
244
275
 
245
- # TODO: it setup static routes if public is enabled
246
- # TODO: however, that's already tested in static_test so...
247
- end
276
+ describe 'static' do
277
+ it 'is disabled on Base' do
278
+ assert ! @base.static?
279
+ end
248
280
 
249
- describe_option 'host' do
250
- it 'defaults to 0.0.0.0' do
251
- assert_equal '0.0.0.0', @base.host
252
- assert_equal '0.0.0.0', @default.host
281
+ it 'is enabled on Default' do
282
+ assert @default.static?
283
+ end
284
+
285
+ # TODO: it setup static routes if public is enabled
286
+ # TODO: however, that's already tested in static_test so...
253
287
  end
254
- end
255
288
 
256
- describe_option 'port' do
257
- it 'defaults to 4567' do
258
- assert_equal 4567, @base.port
259
- assert_equal 4567, @default.port
289
+ describe 'host' do
290
+ it 'defaults to 0.0.0.0' do
291
+ assert_equal '0.0.0.0', @base.host
292
+ assert_equal '0.0.0.0', @default.host
293
+ end
260
294
  end
261
- end
262
295
 
263
- describe_option 'server' do
264
- it 'is one of thin, mongrel, webrick' do
265
- assert_equal %w[thin mongrel webrick], @base.server
266
- assert_equal %w[thin mongrel webrick], @default.server
296
+ describe 'port' do
297
+ it 'defaults to 4567' do
298
+ assert_equal 4567, @base.port
299
+ assert_equal 4567, @default.port
300
+ end
267
301
  end
268
- end
269
302
 
270
- describe_option 'app_file' do
271
- it 'is nil' do
272
- assert @base.app_file.nil?
273
- assert @default.app_file.nil?
303
+ describe 'server' do
304
+ it 'is one of thin, mongrel, webrick' do
305
+ assert_equal %w[thin mongrel webrick], @base.server
306
+ assert_equal %w[thin mongrel webrick], @default.server
307
+ end
274
308
  end
275
- end
276
309
 
277
- describe_option 'root' do
278
- it 'is nil if app_file is not set' do
279
- assert @base.root.nil?
280
- assert @default.root.nil?
310
+ describe 'app_file' do
311
+ it 'is nil' do
312
+ assert @base.app_file.nil?
313
+ assert @default.app_file.nil?
314
+ end
281
315
  end
282
316
 
283
- it 'is equal to the expanded basename of app_file' do
284
- @base.app_file = __FILE__
285
- assert_equal File.expand_path(File.dirname(__FILE__)), @base.root
317
+ describe 'root' do
318
+ it 'is nil if app_file is not set' do
319
+ assert @base.root.nil?
320
+ assert @default.root.nil?
321
+ end
286
322
 
287
- @default.app_file = __FILE__
288
- assert_equal File.expand_path(File.dirname(__FILE__)), @default.root
289
- end
290
- end
323
+ it 'is equal to the expanded basename of app_file' do
324
+ @base.app_file = __FILE__
325
+ assert_equal File.expand_path(File.dirname(__FILE__)), @base.root
291
326
 
292
- describe_option 'views' do
293
- it 'is nil if root is not set' do
294
- assert @base.views.nil?
295
- assert @default.views.nil?
327
+ @default.app_file = __FILE__
328
+ assert_equal File.expand_path(File.dirname(__FILE__)), @default.root
329
+ end
296
330
  end
297
331
 
298
- it 'is set to root joined with views/' do
299
- @base.root = File.dirname(__FILE__)
300
- assert_equal File.dirname(__FILE__) + "/views", @base.views
332
+ describe 'views' do
333
+ it 'is nil if root is not set' do
334
+ assert @base.views.nil?
335
+ assert @default.views.nil?
336
+ end
301
337
 
302
- @default.root = File.dirname(__FILE__)
303
- assert_equal File.dirname(__FILE__) + "/views", @default.views
304
- end
305
- end
338
+ it 'is set to root joined with views/' do
339
+ @base.root = File.dirname(__FILE__)
340
+ assert_equal File.dirname(__FILE__) + "/views", @base.views
306
341
 
307
- describe_option 'public' do
308
- it 'is nil if root is not set' do
309
- assert @base.public.nil?
310
- assert @default.public.nil?
342
+ @default.root = File.dirname(__FILE__)
343
+ assert_equal File.dirname(__FILE__) + "/views", @default.views
344
+ end
311
345
  end
312
346
 
313
- it 'is set to root joined with public/' do
314
- @base.root = File.dirname(__FILE__)
315
- assert_equal File.dirname(__FILE__) + "/public", @base.public
347
+ describe 'public' do
348
+ it 'is nil if root is not set' do
349
+ assert @base.public.nil?
350
+ assert @default.public.nil?
351
+ end
316
352
 
317
- @default.root = File.dirname(__FILE__)
318
- assert_equal File.dirname(__FILE__) + "/public", @default.public
353
+ it 'is set to root joined with public/' do
354
+ @base.root = File.dirname(__FILE__)
355
+ assert_equal File.dirname(__FILE__) + "/public", @base.public
356
+
357
+ @default.root = File.dirname(__FILE__)
358
+ assert_equal File.dirname(__FILE__) + "/public", @default.public
359
+ end
319
360
  end
320
- end
321
361
 
322
- describe_option 'lock' do
323
- it 'is disabled by default' do
324
- assert ! @base.lock?
362
+ describe 'lock' do
363
+ it 'is disabled by default' do
364
+ assert ! @base.lock?
365
+ end
325
366
  end
326
367
  end