bmizerany-sinatra 0.9.0 → 0.9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +40 -0
- data/CHANGES +43 -11
- data/README.rdoc +138 -91
- data/Rakefile +7 -1
- data/compat/events_test.rb +10 -7
- data/compat/helper.rb +13 -1
- data/lib/sinatra/base.rb +72 -26
- data/lib/sinatra/compat.rb +142 -44
- data/lib/sinatra/test/bacon.rb +17 -0
- data/lib/sinatra/test/rspec.rb +7 -0
- data/lib/sinatra/test/spec.rb +7 -0
- data/lib/sinatra/test/unit.rb +1 -1
- data/lib/sinatra/test.rb +94 -90
- data/lib/sinatra.rb +5 -0
- data/sinatra.gemspec +7 -3
- data/test/base_test.rb +33 -14
- data/test/builder_test.rb +12 -16
- data/test/erb_test.rb +11 -16
- data/test/filter_test.rb +48 -12
- data/test/haml_test.rb +14 -18
- data/test/helper.rb +25 -0
- data/test/helpers_test.rb +55 -62
- data/test/mapped_error_test.rb +43 -24
- data/test/middleware_test.rb +8 -13
- data/test/options_test.rb +29 -35
- data/test/reload_test.rb +16 -20
- data/test/request_test.rb +12 -5
- data/test/result_test.rb +16 -20
- data/test/routing_test.rb +124 -71
- data/test/sass_test.rb +8 -12
- data/test/sinatra_test.rb +2 -4
- data/test/static_test.rb +16 -19
- data/test/templates_test.rb +23 -19
- metadata +7 -4
data/test/reload_test.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
$reload_count = 0
|
6
4
|
$reload_app = nil
|
7
5
|
|
8
6
|
describe "Reloading" do
|
9
|
-
include Sinatra::Test
|
10
|
-
|
11
7
|
before {
|
12
8
|
@app = mock_app(Sinatra::Default)
|
13
9
|
$reload_app = @app
|
@@ -20,31 +16,31 @@ describe "Reloading" do
|
|
20
16
|
it 'is enabled by default when in development and the app_file is set' do
|
21
17
|
@app.set :app_file, __FILE__
|
22
18
|
@app.set :environment, :development
|
23
|
-
@app.reload
|
24
|
-
@app.reload
|
19
|
+
assert_same true, @app.reload
|
20
|
+
assert_same true, @app.reload?
|
25
21
|
end
|
26
22
|
|
27
23
|
it 'is disabled by default when running in non-development environment' do
|
28
24
|
@app.set :app_file, __FILE__
|
29
25
|
@app.set :environment, :test
|
30
|
-
|
31
|
-
@app.reload
|
26
|
+
assert !@app.reload
|
27
|
+
assert_same false, @app.reload?
|
32
28
|
end
|
33
29
|
|
34
30
|
it 'is disabled by default when no app_file is available' do
|
35
31
|
@app.set :app_file, nil
|
36
32
|
@app.set :environment, :development
|
37
|
-
|
38
|
-
@app.reload
|
33
|
+
assert !@app.reload
|
34
|
+
assert_same false, @app.reload?
|
39
35
|
end
|
40
36
|
|
41
37
|
it 'can be turned off explicitly' do
|
42
38
|
@app.set :app_file, __FILE__
|
43
39
|
@app.set :environment, :development
|
44
|
-
@app.reload
|
40
|
+
assert_same true, @app.reload
|
45
41
|
@app.set :reload, false
|
46
|
-
@app.reload
|
47
|
-
@app.reload
|
42
|
+
assert_same false, @app.reload
|
43
|
+
assert_same false, @app.reload?
|
48
44
|
end
|
49
45
|
|
50
46
|
it 'reloads the app_file each time a request is made' do
|
@@ -53,13 +49,13 @@ describe "Reloading" do
|
|
53
49
|
@app.get('/') { 'Hello World' }
|
54
50
|
|
55
51
|
get '/'
|
56
|
-
|
57
|
-
|
58
|
-
$reload_count
|
52
|
+
assert_equal 200, status
|
53
|
+
assert_equal 'Hello from reload file', body
|
54
|
+
assert_equal 1, $reload_count
|
59
55
|
|
60
56
|
get '/'
|
61
|
-
|
62
|
-
|
63
|
-
$reload_count
|
57
|
+
assert_equal 200, status
|
58
|
+
assert_equal 'Hello from reload file', body
|
59
|
+
assert_equal 2, $reload_count
|
64
60
|
end
|
65
61
|
end
|
data/test/request_test.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe 'Sinatra::Request' do
|
6
4
|
it 'responds to #user_agent' do
|
7
5
|
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
|
8
|
-
request.
|
9
|
-
|
6
|
+
assert request.respond_to?(:user_agent)
|
7
|
+
assert_equal 'Test', request.user_agent
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'parses POST params when Content-Type is form-dataish' do
|
11
|
+
request = Sinatra::Request.new(
|
12
|
+
'REQUEST_METHOD' => 'PUT',
|
13
|
+
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
|
14
|
+
'rack.input' => StringIO.new('foo=bar')
|
15
|
+
)
|
16
|
+
assert_equal 'bar', request.params['foo']
|
10
17
|
end
|
11
18
|
end
|
data/test/result_test.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe 'Result Handling' do
|
6
|
-
include Sinatra::Test
|
7
|
-
|
8
4
|
it "sets response.body when result is a String" do
|
9
5
|
mock_app {
|
10
6
|
get '/' do
|
@@ -13,8 +9,8 @@ describe 'Result Handling' do
|
|
13
9
|
}
|
14
10
|
|
15
11
|
get '/'
|
16
|
-
|
17
|
-
|
12
|
+
assert ok?
|
13
|
+
assert_equal 'Hello World', body
|
18
14
|
end
|
19
15
|
|
20
16
|
it "sets response.body when result is an Array of Strings" do
|
@@ -25,8 +21,8 @@ describe 'Result Handling' do
|
|
25
21
|
}
|
26
22
|
|
27
23
|
get '/'
|
28
|
-
|
29
|
-
|
24
|
+
assert ok?
|
25
|
+
assert_equal 'HelloWorld', body
|
30
26
|
end
|
31
27
|
|
32
28
|
it "sets response.body when result responds to #each" do
|
@@ -39,8 +35,8 @@ describe 'Result Handling' do
|
|
39
35
|
}
|
40
36
|
|
41
37
|
get '/'
|
42
|
-
|
43
|
-
|
38
|
+
assert ok?
|
39
|
+
assert_equal 'Hello World', body
|
44
40
|
end
|
45
41
|
|
46
42
|
it "sets response.body to [] when result is nil" do
|
@@ -51,8 +47,8 @@ describe 'Result Handling' do
|
|
51
47
|
}
|
52
48
|
|
53
49
|
get '/'
|
54
|
-
|
55
|
-
|
50
|
+
assert ok?
|
51
|
+
assert_equal '', body
|
56
52
|
end
|
57
53
|
|
58
54
|
it "sets status, headers, and body when result is a Rack response tuple" do
|
@@ -63,9 +59,9 @@ describe 'Result Handling' do
|
|
63
59
|
}
|
64
60
|
|
65
61
|
get '/'
|
66
|
-
|
67
|
-
response['Content-Type']
|
68
|
-
|
62
|
+
assert_equal 205, status
|
63
|
+
assert_equal 'foo/bar', response['Content-Type']
|
64
|
+
assert_equal 'Hello World', body
|
69
65
|
end
|
70
66
|
|
71
67
|
it "sets status and body when result is a two-tuple" do
|
@@ -76,8 +72,8 @@ describe 'Result Handling' do
|
|
76
72
|
}
|
77
73
|
|
78
74
|
get '/'
|
79
|
-
|
80
|
-
|
75
|
+
assert_equal 409, status
|
76
|
+
assert_equal 'formula of', body
|
81
77
|
end
|
82
78
|
|
83
79
|
it "sets status when result is a Fixnum status code" do
|
@@ -86,7 +82,7 @@ describe 'Result Handling' do
|
|
86
82
|
}
|
87
83
|
|
88
84
|
get '/'
|
89
|
-
|
90
|
-
body
|
85
|
+
assert_equal 205, status
|
86
|
+
assert_equal '', body
|
91
87
|
end
|
92
88
|
end
|
data/test/routing_test.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe "Routing" do
|
6
|
-
include Sinatra::Test
|
7
|
-
|
8
4
|
%w[get put post delete head].each do |verb|
|
9
5
|
it "defines #{verb.upcase} request handlers with #{verb}" do
|
10
6
|
mock_app {
|
@@ -15,8 +11,8 @@ describe "Routing" do
|
|
15
11
|
|
16
12
|
request = Rack::MockRequest.new(@app)
|
17
13
|
response = request.request(verb.upcase, '/hello', {})
|
18
|
-
response.
|
19
|
-
|
14
|
+
assert response.ok?
|
15
|
+
assert_equal 'Hello World', response.body
|
20
16
|
end
|
21
17
|
end
|
22
18
|
|
@@ -25,30 +21,30 @@ describe "Routing" do
|
|
25
21
|
get('/foo') { }
|
26
22
|
}
|
27
23
|
get '/bar'
|
28
|
-
|
24
|
+
assert_equal 404, status
|
29
25
|
end
|
30
26
|
|
31
27
|
it "exposes params with indifferent hash" do
|
32
28
|
mock_app {
|
33
29
|
get '/:foo' do
|
34
|
-
params['foo']
|
35
|
-
params[:foo]
|
30
|
+
assert_equal 'bar', params['foo']
|
31
|
+
assert_equal 'bar', params[:foo]
|
36
32
|
'well, alright'
|
37
33
|
end
|
38
34
|
}
|
39
35
|
get '/bar'
|
40
|
-
|
36
|
+
assert_equal 'well, alright', body
|
41
37
|
end
|
42
38
|
|
43
39
|
it "merges named params and query string params in params" do
|
44
40
|
mock_app {
|
45
41
|
get '/:foo' do
|
46
|
-
params['foo']
|
47
|
-
params['baz']
|
42
|
+
assert_equal 'bar', params['foo']
|
43
|
+
assert_equal 'biz', params['baz']
|
48
44
|
end
|
49
45
|
}
|
50
46
|
get '/bar?baz=biz'
|
51
|
-
|
47
|
+
assert ok?
|
52
48
|
end
|
53
49
|
|
54
50
|
it "supports named params like /hello/:person" do
|
@@ -58,7 +54,7 @@ describe "Routing" do
|
|
58
54
|
end
|
59
55
|
}
|
60
56
|
get '/hello/Frank'
|
61
|
-
|
57
|
+
assert_equal 'Hello Frank', body
|
62
58
|
end
|
63
59
|
|
64
60
|
it "supports optional named params like /?:foo?/?:bar?" do
|
@@ -69,58 +65,115 @@ describe "Routing" do
|
|
69
65
|
}
|
70
66
|
|
71
67
|
get '/hello/world'
|
72
|
-
|
73
|
-
|
68
|
+
assert ok?
|
69
|
+
assert_equal "foo=hello;bar=world", body
|
74
70
|
|
75
71
|
get '/hello'
|
76
|
-
|
77
|
-
|
72
|
+
assert ok?
|
73
|
+
assert_equal "foo=hello;bar=", body
|
78
74
|
|
79
75
|
get '/'
|
80
|
-
|
81
|
-
|
76
|
+
assert ok?
|
77
|
+
assert_equal "foo=;bar=", body
|
82
78
|
end
|
83
79
|
|
84
80
|
it "supports single splat params like /*" do
|
85
81
|
mock_app {
|
86
82
|
get '/*' do
|
87
|
-
params['splat'].
|
83
|
+
assert params['splat'].kind_of?(Array)
|
88
84
|
params['splat'].join "\n"
|
89
85
|
end
|
90
86
|
}
|
91
87
|
|
92
88
|
get '/foo'
|
93
|
-
|
89
|
+
assert_equal "foo", body
|
94
90
|
|
95
91
|
get '/foo/bar/baz'
|
96
|
-
|
92
|
+
assert_equal "foo/bar/baz", body
|
97
93
|
end
|
98
94
|
|
99
95
|
it "supports mixing multiple splat params like /*/foo/*/*" do
|
100
96
|
mock_app {
|
101
97
|
get '/*/foo/*/*' do
|
102
|
-
params['splat'].
|
98
|
+
assert params['splat'].kind_of?(Array)
|
103
99
|
params['splat'].join "\n"
|
104
100
|
end
|
105
101
|
}
|
106
102
|
|
107
103
|
get '/bar/foo/bling/baz/boom'
|
108
|
-
|
104
|
+
assert_equal "bar\nbling\nbaz/boom", body
|
109
105
|
|
110
106
|
get '/bar/foo/baz'
|
111
|
-
|
107
|
+
assert not_found?
|
112
108
|
end
|
113
109
|
|
114
110
|
it "supports mixing named and splat params like /:foo/*" do
|
115
111
|
mock_app {
|
116
112
|
get '/:foo/*' do
|
117
|
-
|
118
|
-
|
113
|
+
assert_equal 'foo', params['foo']
|
114
|
+
assert_equal ['bar/baz'], params['splat']
|
119
115
|
end
|
120
116
|
}
|
121
117
|
|
122
118
|
get '/foo/bar/baz'
|
123
|
-
|
119
|
+
assert ok?
|
120
|
+
end
|
121
|
+
|
122
|
+
it "supports basic nested params" do
|
123
|
+
mock_app {
|
124
|
+
get '/hi' do
|
125
|
+
params["person"]["name"]
|
126
|
+
end
|
127
|
+
}
|
128
|
+
|
129
|
+
get "/hi?person[name]=John+Doe"
|
130
|
+
assert ok?
|
131
|
+
assert_equal "John Doe", body
|
132
|
+
end
|
133
|
+
|
134
|
+
it "exposes nested params with indifferent hash" do
|
135
|
+
mock_app {
|
136
|
+
get '/testme' do
|
137
|
+
assert_equal 'baz', params['bar']['foo']
|
138
|
+
assert_equal 'baz', params['bar'][:foo]
|
139
|
+
'well, alright'
|
140
|
+
end
|
141
|
+
}
|
142
|
+
get '/testme?bar[foo]=baz'
|
143
|
+
assert_equal 'well, alright', body
|
144
|
+
end
|
145
|
+
|
146
|
+
it "supports deeply nested params" do
|
147
|
+
input = {
|
148
|
+
'browser[chrome][engine][name]' => 'V8',
|
149
|
+
'browser[chrome][engine][version]' => '1.0',
|
150
|
+
'browser[firefox][engine][name]' => 'spidermonkey',
|
151
|
+
'browser[firefox][engine][version]' => '1.7.0',
|
152
|
+
'emacs[map][goto-line]' => 'M-g g',
|
153
|
+
'emacs[version]' => '22.3.1',
|
154
|
+
'paste[name]' => 'hello world',
|
155
|
+
'paste[syntax]' => 'ruby'
|
156
|
+
}
|
157
|
+
expected = {
|
158
|
+
"emacs" => {
|
159
|
+
"map" => { "goto-line" => "M-g g" },
|
160
|
+
"version" => "22.3.1"
|
161
|
+
},
|
162
|
+
"browser" => {
|
163
|
+
"firefox" => {"engine" => {"name"=>"spidermonkey", "version"=>"1.7.0"}},
|
164
|
+
"chrome" => {"engine" => {"name"=>"V8", "version"=>"1.0"}}
|
165
|
+
},
|
166
|
+
"paste" => {"name"=>"hello world", "syntax"=>"ruby"}
|
167
|
+
}
|
168
|
+
mock_app {
|
169
|
+
get '/foo' do
|
170
|
+
assert_equal expected, params
|
171
|
+
'looks good'
|
172
|
+
end
|
173
|
+
}
|
174
|
+
get "/foo?#{param_string(input)}"
|
175
|
+
assert ok?
|
176
|
+
assert_equal 'looks good', body
|
124
177
|
end
|
125
178
|
|
126
179
|
it "supports paths that include spaces" do
|
@@ -131,21 +184,21 @@ describe "Routing" do
|
|
131
184
|
}
|
132
185
|
|
133
186
|
get '/path%20with%20spaces'
|
134
|
-
|
135
|
-
|
187
|
+
assert ok?
|
188
|
+
assert_equal 'looks good', body
|
136
189
|
end
|
137
190
|
|
138
191
|
it "URL decodes named parameters and splats" do
|
139
192
|
mock_app {
|
140
193
|
get '/:foo/*' do
|
141
|
-
params['foo']
|
142
|
-
|
194
|
+
assert_equal 'hello world', params['foo']
|
195
|
+
assert_equal ['how are you'], params['splat']
|
143
196
|
nil
|
144
197
|
end
|
145
198
|
}
|
146
199
|
|
147
200
|
get '/hello%20world/how%20are%20you'
|
148
|
-
|
201
|
+
assert ok?
|
149
202
|
end
|
150
203
|
|
151
204
|
it 'supports regular expressions' do
|
@@ -156,21 +209,21 @@ describe "Routing" do
|
|
156
209
|
}
|
157
210
|
|
158
211
|
get '/foooom/bar'
|
159
|
-
|
160
|
-
|
212
|
+
assert ok?
|
213
|
+
assert_equal 'Hello World', body
|
161
214
|
end
|
162
215
|
|
163
216
|
it 'makes regular expression captures available in params[:captures]' do
|
164
217
|
mock_app {
|
165
218
|
get(/^\/fo(.*)\/ba(.*)/) do
|
166
|
-
|
219
|
+
assert_equal ['orooomma', 'f'], params[:captures]
|
167
220
|
'right on'
|
168
221
|
end
|
169
222
|
}
|
170
223
|
|
171
224
|
get '/foorooomma/baf'
|
172
|
-
|
173
|
-
|
225
|
+
assert ok?
|
226
|
+
assert_equal 'right on', body
|
174
227
|
end
|
175
228
|
|
176
229
|
it "returns response immediately on halt" do
|
@@ -182,8 +235,8 @@ describe "Routing" do
|
|
182
235
|
}
|
183
236
|
|
184
237
|
get '/'
|
185
|
-
|
186
|
-
|
238
|
+
assert ok?
|
239
|
+
assert_equal 'Hello World', body
|
187
240
|
end
|
188
241
|
|
189
242
|
it "transitions to the next matching route on pass" do
|
@@ -194,14 +247,14 @@ describe "Routing" do
|
|
194
247
|
end
|
195
248
|
|
196
249
|
get '/*' do
|
197
|
-
params.
|
250
|
+
assert !params.include?('foo')
|
198
251
|
'Hello World'
|
199
252
|
end
|
200
253
|
}
|
201
254
|
|
202
255
|
get '/bar'
|
203
|
-
|
204
|
-
|
256
|
+
assert ok?
|
257
|
+
assert_equal 'Hello World', body
|
205
258
|
end
|
206
259
|
|
207
260
|
it "transitions to 404 when passed and no subsequent route matches" do
|
@@ -213,7 +266,7 @@ describe "Routing" do
|
|
213
266
|
}
|
214
267
|
|
215
268
|
get '/bar'
|
216
|
-
|
269
|
+
assert not_found?
|
217
270
|
end
|
218
271
|
|
219
272
|
it "passes when matching condition returns false" do
|
@@ -225,11 +278,11 @@ describe "Routing" do
|
|
225
278
|
}
|
226
279
|
|
227
280
|
get '/bar'
|
228
|
-
|
229
|
-
|
281
|
+
assert ok?
|
282
|
+
assert_equal 'Hello World', body
|
230
283
|
|
231
284
|
get '/foo'
|
232
|
-
|
285
|
+
assert not_found?
|
233
286
|
end
|
234
287
|
|
235
288
|
it "does not pass when matching condition returns nil" do
|
@@ -241,8 +294,8 @@ describe "Routing" do
|
|
241
294
|
}
|
242
295
|
|
243
296
|
get '/bar'
|
244
|
-
|
245
|
-
|
297
|
+
assert ok?
|
298
|
+
assert_equal 'Hello World', body
|
246
299
|
end
|
247
300
|
|
248
301
|
it "passes to next route when condition calls pass explicitly" do
|
@@ -254,11 +307,11 @@ describe "Routing" do
|
|
254
307
|
}
|
255
308
|
|
256
309
|
get '/bar'
|
257
|
-
|
258
|
-
|
310
|
+
assert ok?
|
311
|
+
assert_equal 'Hello World', body
|
259
312
|
|
260
313
|
get '/foo'
|
261
|
-
|
314
|
+
assert not_found?
|
262
315
|
end
|
263
316
|
|
264
317
|
it "passes to the next route when host_name does not match" do
|
@@ -269,38 +322,38 @@ describe "Routing" do
|
|
269
322
|
end
|
270
323
|
}
|
271
324
|
get '/foo'
|
272
|
-
|
325
|
+
assert not_found?
|
273
326
|
|
274
327
|
get '/foo', :env => { 'HTTP_HOST' => 'example.com' }
|
275
|
-
|
276
|
-
|
328
|
+
assert_equal 200, status
|
329
|
+
assert_equal 'Hello World', body
|
277
330
|
end
|
278
331
|
|
279
332
|
it "passes to the next route when user_agent does not match" do
|
280
333
|
mock_app {
|
281
|
-
user_agent
|
334
|
+
user_agent(/Foo/)
|
282
335
|
get '/foo' do
|
283
336
|
'Hello World'
|
284
337
|
end
|
285
338
|
}
|
286
339
|
get '/foo'
|
287
|
-
|
340
|
+
assert not_found?
|
288
341
|
|
289
342
|
get '/foo', :env => { 'HTTP_USER_AGENT' => 'Foo Bar' }
|
290
|
-
|
291
|
-
|
343
|
+
assert_equal 200, status
|
344
|
+
assert_equal 'Hello World', body
|
292
345
|
end
|
293
346
|
|
294
347
|
it "makes captures in user agent pattern available in params[:agent]" do
|
295
348
|
mock_app {
|
296
|
-
user_agent
|
349
|
+
user_agent(/Foo (.*)/)
|
297
350
|
get '/foo' do
|
298
351
|
'Hello ' + params[:agent].first
|
299
352
|
end
|
300
353
|
}
|
301
354
|
get '/foo', :env => { 'HTTP_USER_AGENT' => 'Foo Bar' }
|
302
|
-
|
303
|
-
|
355
|
+
assert_equal 200, status
|
356
|
+
assert_equal 'Hello Bar', body
|
304
357
|
end
|
305
358
|
|
306
359
|
it "filters by accept header" do
|
@@ -311,12 +364,12 @@ describe "Routing" do
|
|
311
364
|
}
|
312
365
|
|
313
366
|
get '/', :env => { :accept => 'application/xml' }
|
314
|
-
|
315
|
-
|
316
|
-
response.headers['Content-Type']
|
367
|
+
assert ok?
|
368
|
+
assert_equal 'application/xml', body
|
369
|
+
assert_equal 'application/xml', response.headers['Content-Type']
|
317
370
|
|
318
371
|
get '/', :env => { :accept => 'text/html' }
|
319
|
-
|
372
|
+
assert !ok?
|
320
373
|
end
|
321
374
|
|
322
375
|
it "allows multiple mime types for accept header" do
|
@@ -330,9 +383,9 @@ describe "Routing" do
|
|
330
383
|
|
331
384
|
types.each do |type|
|
332
385
|
get '/', :env => { :accept => type }
|
333
|
-
|
334
|
-
|
335
|
-
response.headers['Content-Type']
|
386
|
+
assert ok?
|
387
|
+
assert_equal type, body
|
388
|
+
assert_equal type, response.headers['Content-Type']
|
336
389
|
end
|
337
390
|
end
|
338
391
|
end
|
data/test/sass_test.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe "Sass Templates" do
|
6
|
-
include Sinatra::Test
|
7
|
-
|
8
4
|
def sass_app(&block)
|
9
5
|
mock_app {
|
10
6
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -15,26 +11,26 @@ describe "Sass Templates" do
|
|
15
11
|
|
16
12
|
it 'renders inline Sass strings' do
|
17
13
|
sass_app { sass "#sass\n :background-color #FFF\n" }
|
18
|
-
|
19
|
-
|
14
|
+
assert ok?
|
15
|
+
assert_equal "#sass {\n background-color: #FFF; }\n", body
|
20
16
|
end
|
21
17
|
|
22
18
|
it 'renders .sass files in views path' do
|
23
19
|
sass_app { sass :hello }
|
24
|
-
|
25
|
-
|
20
|
+
assert ok?
|
21
|
+
assert_equal "#sass {\n background-color: #FFF; }\n", body
|
26
22
|
end
|
27
23
|
|
28
24
|
it 'ignores the layout option' do
|
29
25
|
sass_app { sass :hello, :layout => :layout2 }
|
30
|
-
|
31
|
-
|
26
|
+
assert ok?
|
27
|
+
assert_equal "#sass {\n background-color: #FFF; }\n", body
|
32
28
|
end
|
33
29
|
|
34
30
|
it "raises error if template not found" do
|
35
31
|
mock_app {
|
36
32
|
get('/') { sass :no_such_template }
|
37
33
|
}
|
38
|
-
|
34
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
39
35
|
end
|
40
36
|
end
|
data/test/sinatra_test.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe 'Sinatra' do
|
6
4
|
it 'creates a new Sinatra::Base subclass on new' do
|
@@ -10,6 +8,6 @@ describe 'Sinatra' do
|
|
10
8
|
'Hello World'
|
11
9
|
end
|
12
10
|
end
|
13
|
-
|
11
|
+
assert_same Sinatra::Base, app.superclass
|
14
12
|
end
|
15
13
|
end
|