roda 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +34 -0
- data/Rakefile +22 -46
- data/doc/release_notes/2.3.0.txt +109 -0
- data/lib/roda/plugins/assets.rb +2 -1
- data/lib/roda/plugins/caching.rb +1 -1
- data/lib/roda/plugins/chunked.rb +1 -1
- data/lib/roda/plugins/error_email.rb +1 -1
- data/lib/roda/plugins/head.rb +6 -0
- data/lib/roda/plugins/heartbeat.rb +40 -0
- data/lib/roda/plugins/json.rb +23 -3
- data/lib/roda/plugins/json_parser.rb +72 -0
- data/lib/roda/plugins/mailer.rb +22 -5
- data/lib/roda/plugins/named_templates.rb +2 -2
- data/lib/roda/plugins/path_rewriter.rb +82 -0
- data/lib/roda/plugins/precompile_templates.rb +87 -0
- data/lib/roda/plugins/render.rb +111 -43
- data/lib/roda/plugins/render_each.rb +1 -1
- data/lib/roda/plugins/shared_vars.rb +1 -1
- data/lib/roda/plugins/view_options.rb +28 -3
- data/lib/roda/version.rb +1 -1
- data/spec/composition_spec.rb +3 -3
- data/spec/env_spec.rb +1 -1
- data/spec/freeze_spec.rb +6 -6
- data/spec/integration_spec.rb +16 -15
- data/spec/matchers_spec.rb +110 -110
- data/spec/opts_spec.rb +8 -8
- data/spec/plugin/_erubis_escaping_spec.rb +34 -3
- data/spec/plugin/all_verbs_spec.rb +8 -8
- data/spec/plugin/assets_spec.rb +164 -150
- data/spec/plugin/backtracking_array_spec.rb +18 -18
- data/spec/plugin/caching_spec.rb +70 -70
- data/spec/plugin/chunked_spec.rb +38 -38
- data/spec/plugin/class_level_routing_spec.rb +78 -78
- data/spec/plugin/content_for_spec.rb +2 -2
- data/spec/plugin/cookies_spec.rb +4 -4
- data/spec/plugin/csrf_spec.rb +8 -8
- data/spec/plugin/default_headers_spec.rb +6 -6
- data/spec/plugin/delay_build_spec.rb +7 -6
- data/spec/plugin/delegate_spec.rb +2 -2
- data/spec/plugin/delete_empty_headers_spec.rb +2 -2
- data/spec/plugin/drop_body_spec.rb +6 -6
- data/spec/plugin/empty_root_spec.rb +3 -3
- data/spec/plugin/environments_spec.rb +7 -7
- data/spec/plugin/error_email_spec.rb +23 -23
- data/spec/plugin/error_handler_spec.rb +14 -14
- data/spec/plugin/flash_spec.rb +30 -29
- data/spec/plugin/h_spec.rb +1 -1
- data/spec/plugin/halt_spec.rb +16 -16
- data/spec/plugin/hash_matcher_spec.rb +5 -5
- data/spec/plugin/head_spec.rb +10 -10
- data/spec/plugin/header_matchers_spec.rb +13 -13
- data/spec/plugin/heartbeat_spec.rb +74 -0
- data/spec/plugin/hooks_spec.rb +20 -20
- data/spec/plugin/indifferent_params_spec.rb +1 -1
- data/spec/plugin/json_parser_spec.rb +72 -0
- data/spec/plugin/json_spec.rb +22 -9
- data/spec/plugin/mailer_spec.rb +72 -58
- data/spec/plugin/match_affix_spec.rb +2 -2
- data/spec/plugin/middleware_spec.rb +7 -7
- data/spec/plugin/module_include_spec.rb +4 -4
- data/spec/plugin/multi_route_spec.rb +66 -66
- data/spec/plugin/multi_run_spec.rb +21 -21
- data/spec/plugin/named_templates_spec.rb +6 -6
- data/spec/plugin/not_allowed_spec.rb +17 -17
- data/spec/plugin/not_found_spec.rb +14 -14
- data/spec/plugin/padrino_render_spec.rb +2 -2
- data/spec/plugin/param_matchers_spec.rb +6 -6
- data/spec/plugin/partials_spec.rb +3 -3
- data/spec/plugin/pass_spec.rb +7 -7
- data/spec/plugin/path_matchers_spec.rb +6 -6
- data/spec/plugin/path_rewriter_spec.rb +37 -0
- data/spec/plugin/path_spec.rb +41 -40
- data/spec/plugin/per_thread_caching_spec.rb +6 -6
- data/spec/plugin/precompile_templates_spec.rb +74 -0
- data/spec/plugin/render_each_spec.rb +4 -4
- data/spec/plugin/render_spec.rb +179 -76
- data/spec/plugin/shared_vars_spec.rb +4 -4
- data/spec/plugin/sinatra_helpers_spec.rb +121 -121
- data/spec/plugin/slash_path_empty_spec.rb +10 -10
- data/spec/plugin/static_spec.rb +4 -4
- data/spec/plugin/streaming_spec.rb +11 -11
- data/spec/plugin/symbol_matchers_spec.rb +24 -24
- data/spec/plugin/symbol_views_spec.rb +3 -3
- data/spec/plugin/view_options_spec.rb +10 -10
- data/spec/plugin_spec.rb +2 -2
- data/spec/redirect_spec.rb +10 -10
- data/spec/request_spec.rb +8 -8
- data/spec/response_spec.rb +23 -23
- data/spec/session_spec.rb +4 -4
- data/spec/spec_helper.rb +5 -19
- data/spec/version_spec.rb +4 -4
- data/spec/views/iv.erb +1 -0
- metadata +16 -5
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
|
2
2
|
|
3
3
|
describe "module_include plugin" do
|
4
|
-
it "
|
4
|
+
it "must_include given module in request or response class" do
|
5
5
|
app(:bare) do
|
6
6
|
plugin :module_include
|
7
7
|
request_module(Module.new{def h; halt response.finish end})
|
@@ -12,7 +12,7 @@ describe "module_include plugin" do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
req.
|
15
|
+
req.must_equal [1, {}, []]
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should accept blocks and turn them into modules" do
|
@@ -26,7 +26,7 @@ describe "module_include plugin" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
req.
|
29
|
+
req.must_equal [1, {}, []]
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should work if called multiple times with a block" do
|
@@ -42,7 +42,7 @@ describe "module_include plugin" do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
req.
|
45
|
+
req.must_equal [1, {}, []]
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -66,72 +66,72 @@ describe "multi_route plugin" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "adds named routing support" do
|
69
|
-
body.
|
70
|
-
body('REQUEST_METHOD'=>'POST').
|
71
|
-
body('/a').
|
72
|
-
body('/a', 'REQUEST_METHOD'=>'POST').
|
73
|
-
body('/b').
|
74
|
-
body('/b', 'REQUEST_METHOD'=>'POST').
|
75
|
-
status('/c').
|
76
|
-
status('/c', 'REQUEST_METHOD'=>'POST').
|
69
|
+
body.must_equal 'get'
|
70
|
+
body('REQUEST_METHOD'=>'POST').must_equal 'post'
|
71
|
+
body('/a').must_equal 'geta'
|
72
|
+
body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
|
73
|
+
body('/b').must_equal 'getb'
|
74
|
+
body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
|
75
|
+
status('/c').must_equal 404
|
76
|
+
status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
|
77
77
|
end
|
78
78
|
|
79
79
|
it "works when freezing the app" do
|
80
80
|
app.freeze
|
81
|
-
body.
|
82
|
-
body('REQUEST_METHOD'=>'POST').
|
83
|
-
body('/a').
|
84
|
-
body('/a', 'REQUEST_METHOD'=>'POST').
|
85
|
-
body('/b').
|
86
|
-
body('/b', 'REQUEST_METHOD'=>'POST').
|
87
|
-
status('/c').
|
88
|
-
status('/c', 'REQUEST_METHOD'=>'POST').
|
89
|
-
|
90
|
-
proc{app.route("foo"){}}.
|
81
|
+
body.must_equal 'get'
|
82
|
+
body('REQUEST_METHOD'=>'POST').must_equal 'post'
|
83
|
+
body('/a').must_equal 'geta'
|
84
|
+
body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
|
85
|
+
body('/b').must_equal 'getb'
|
86
|
+
body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
|
87
|
+
status('/c').must_equal 404
|
88
|
+
status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
|
89
|
+
|
90
|
+
proc{app.route("foo"){}}.must_raise FrozenError
|
91
91
|
end
|
92
92
|
|
93
93
|
it "uses multi_route to dispatch to any named route" do
|
94
|
-
status('/foo').
|
95
|
-
body('/foo/get/').
|
96
|
-
body('/foo/get/a').
|
97
|
-
body('/foo/post/').
|
98
|
-
body('/foo/post/a').
|
99
|
-
body('/foo/post/b').
|
94
|
+
status('/foo').must_equal 404
|
95
|
+
body('/foo/get/').must_equal 'get'
|
96
|
+
body('/foo/get/a').must_equal 'geta'
|
97
|
+
body('/foo/post/').must_equal 'post'
|
98
|
+
body('/foo/post/a').must_equal 'posta'
|
99
|
+
body('/foo/post/b').must_equal 'foo'
|
100
100
|
end
|
101
101
|
|
102
102
|
it "does not have multi_route match non-String named routes" do
|
103
|
-
body('/foo/p').
|
104
|
-
status('/foo/p/2').
|
103
|
+
body('/foo/p').must_equal 'p'
|
104
|
+
status('/foo/p/2').must_equal 404
|
105
105
|
end
|
106
106
|
|
107
107
|
it "has multi_route pick up routes newly added" do
|
108
|
-
body('/foo/get/').
|
109
|
-
status('/foo/delete').
|
108
|
+
body('/foo/get/').must_equal 'get'
|
109
|
+
status('/foo/delete').must_equal 404
|
110
110
|
app.route('delete'){|r| r.on{'delete'}}
|
111
|
-
body('/foo/delete').
|
111
|
+
body('/foo/delete').must_equal 'delete'
|
112
112
|
end
|
113
113
|
|
114
114
|
it "makes multi_route match longest route if multiple routes have the same prefix" do
|
115
115
|
app.route("post/a"){|r| r.on{"pa2"}}
|
116
116
|
app.route("get/a"){|r| r.on{"ga2"}}
|
117
|
-
status('/foo').
|
118
|
-
body('/foo/get/').
|
119
|
-
body('/foo/get/a').
|
120
|
-
body('/foo/post/').
|
121
|
-
body('/foo/post/a').
|
122
|
-
body('/foo/post/b').
|
117
|
+
status('/foo').must_equal 404
|
118
|
+
body('/foo/get/').must_equal 'get'
|
119
|
+
body('/foo/get/a').must_equal 'ga2'
|
120
|
+
body('/foo/post/').must_equal 'post'
|
121
|
+
body('/foo/post/a').must_equal 'pa2'
|
122
|
+
body('/foo/post/b').must_equal 'foo'
|
123
123
|
end
|
124
124
|
|
125
125
|
it "handles loading the plugin multiple times correctly" do
|
126
126
|
app.plugin :multi_route
|
127
|
-
body.
|
128
|
-
body('REQUEST_METHOD'=>'POST').
|
129
|
-
body('/a').
|
130
|
-
body('/a', 'REQUEST_METHOD'=>'POST').
|
131
|
-
body('/b').
|
132
|
-
body('/b', 'REQUEST_METHOD'=>'POST').
|
133
|
-
status('/c').
|
134
|
-
status('/c', 'REQUEST_METHOD'=>'POST').
|
127
|
+
body.must_equal 'get'
|
128
|
+
body('REQUEST_METHOD'=>'POST').must_equal 'post'
|
129
|
+
body('/a').must_equal 'geta'
|
130
|
+
body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
|
131
|
+
body('/b').must_equal 'getb'
|
132
|
+
body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
|
133
|
+
status('/c').must_equal 404
|
134
|
+
status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
|
135
135
|
end
|
136
136
|
|
137
137
|
it "handles subclassing correctly" do
|
@@ -153,20 +153,20 @@ describe "multi_route plugin" do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
body.
|
157
|
-
body('REQUEST_METHOD'=>'POST').
|
158
|
-
body('/a').
|
159
|
-
body('/a', 'REQUEST_METHOD'=>'POST').
|
160
|
-
body('/b').
|
161
|
-
body('/b', 'REQUEST_METHOD'=>'POST').
|
162
|
-
status('/c').
|
163
|
-
status('/c', 'REQUEST_METHOD'=>'POST').
|
156
|
+
body.must_equal 'post'
|
157
|
+
body('REQUEST_METHOD'=>'POST').must_equal 'get'
|
158
|
+
body('/a').must_equal 'posta'
|
159
|
+
body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'geta'
|
160
|
+
body('/b').must_equal '1b'
|
161
|
+
body('/b', 'REQUEST_METHOD'=>'POST').must_equal '2b'
|
162
|
+
status('/c').must_equal 404
|
163
|
+
status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
|
164
164
|
end
|
165
165
|
|
166
166
|
it "uses the named route return value in multi_route if no block is given" do
|
167
167
|
app.route{|r| r.multi_route}
|
168
|
-
body('/get').
|
169
|
-
body('/post').
|
168
|
+
body('/get').must_equal 'getd'
|
169
|
+
body('/post').must_equal 'postd'
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -176,7 +176,7 @@ describe "multi_route plugin" do
|
|
176
176
|
r.multi_route
|
177
177
|
'a'
|
178
178
|
end
|
179
|
-
body.
|
179
|
+
body.must_equal 'a'
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -223,12 +223,12 @@ describe "multi_route plugin" do
|
|
223
223
|
r.on("bar"){r.route("bar")}
|
224
224
|
end
|
225
225
|
|
226
|
-
body('/foo').
|
227
|
-
body('/foo/foo').
|
228
|
-
body('/foo/bar').
|
229
|
-
body('/bar').
|
230
|
-
body('/bar/foo').
|
231
|
-
body('/bar/bar').
|
226
|
+
body('/foo').must_equal 'f'
|
227
|
+
body('/foo/foo').must_equal 'fff'
|
228
|
+
body('/foo/bar').must_equal 'ffb'
|
229
|
+
body('/bar').must_equal 'b'
|
230
|
+
body('/bar/foo').must_equal 'bbf'
|
231
|
+
body('/bar/bar').must_equal 'bbb'
|
232
232
|
end
|
233
233
|
|
234
234
|
it "handles namespaces in r.multi_route" do
|
@@ -248,11 +248,11 @@ describe "multi_route plugin" do
|
|
248
248
|
r.multi_route
|
249
249
|
end
|
250
250
|
|
251
|
-
body('/foo').
|
252
|
-
body('/foo/foo').
|
253
|
-
body('/foo/bar').
|
254
|
-
body('/bar').
|
255
|
-
body('/bar/foo').
|
256
|
-
body('/bar/bar').
|
251
|
+
body('/foo').must_equal 'f'
|
252
|
+
body('/foo/foo').must_equal 'fff'
|
253
|
+
body('/foo/bar').must_equal 'ffb'
|
254
|
+
body('/bar').must_equal 'b'
|
255
|
+
body('/bar/foo').must_equal 'bbf'
|
256
|
+
body('/bar/bar').must_equal 'bbb'
|
257
257
|
end
|
258
258
|
end
|
@@ -9,24 +9,24 @@ describe "multi_run plugin" do
|
|
9
9
|
|
10
10
|
app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
|
11
11
|
|
12
|
-
body("/a").
|
13
|
-
body("/b").
|
14
|
-
body("/b/a").
|
15
|
-
body.
|
12
|
+
body("/a").must_equal 'a1'
|
13
|
+
body("/b").must_equal 'c'
|
14
|
+
body("/b/a").must_equal 'c'
|
15
|
+
body.must_equal 'c'
|
16
16
|
|
17
17
|
app.run "b", Class.new(Roda).class_eval{route{"b1"}; app}
|
18
18
|
|
19
|
-
body("/a").
|
20
|
-
body("/b").
|
21
|
-
body("/b/a").
|
22
|
-
body.
|
19
|
+
body("/a").must_equal 'a1'
|
20
|
+
body("/b").must_equal 'b1'
|
21
|
+
body("/b/a").must_equal 'b1'
|
22
|
+
body.must_equal 'c'
|
23
23
|
|
24
24
|
app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app}
|
25
25
|
|
26
|
-
body("/a").
|
27
|
-
body("/b").
|
28
|
-
body("/b/a").
|
29
|
-
body.
|
26
|
+
body("/a").must_equal 'a1'
|
27
|
+
body("/b").must_equal 'b1'
|
28
|
+
body("/b/a").must_equal 'b2'
|
29
|
+
body.must_equal 'c'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "works when freezing the app" do
|
@@ -40,12 +40,12 @@ describe "multi_run plugin" do
|
|
40
40
|
app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app}
|
41
41
|
app.freeze
|
42
42
|
|
43
|
-
body("/a").
|
44
|
-
body("/b").
|
45
|
-
body("/b/a").
|
46
|
-
body.
|
43
|
+
body("/a").must_equal 'a1'
|
44
|
+
body("/b").must_equal 'b1'
|
45
|
+
body("/b/a").must_equal 'b2'
|
46
|
+
body.must_equal 'c'
|
47
47
|
|
48
|
-
proc{app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}}.
|
48
|
+
proc{app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}}.must_raise FrozenError
|
49
49
|
end
|
50
50
|
|
51
51
|
it "works when subclassing" do
|
@@ -55,7 +55,7 @@ describe "multi_run plugin" do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
|
58
|
-
body("/a").
|
58
|
+
body("/a").must_equal 'a1'
|
59
59
|
|
60
60
|
a = app
|
61
61
|
@app = Class.new(a)
|
@@ -63,10 +63,10 @@ describe "multi_run plugin" do
|
|
63
63
|
a.run "b", Class.new(Roda).class_eval{route{"b2"}; app}
|
64
64
|
app.run "b", Class.new(Roda).class_eval{route{"b1"}; app}
|
65
65
|
|
66
|
-
body("/a").
|
67
|
-
body("/b").
|
66
|
+
body("/a").must_equal 'a1'
|
67
|
+
body("/b").must_equal 'b1'
|
68
68
|
|
69
69
|
@app = a
|
70
|
-
body("/b").
|
70
|
+
body("/b").must_equal 'b2'
|
71
71
|
end
|
72
72
|
end
|
@@ -25,9 +25,9 @@ describe "named_templates plugin" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
body.
|
28
|
+
body.must_equal 'bar13-foo12-baz'
|
29
29
|
@app = Class.new(@app)
|
30
|
-
body.
|
30
|
+
body.must_equal 'bar13-foo12-baz'
|
31
31
|
end
|
32
32
|
|
33
33
|
it "works when freezing the app" do
|
@@ -50,9 +50,9 @@ describe "named_templates plugin" do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
app.freeze
|
53
|
-
body.
|
53
|
+
body.must_equal 'bar13-foo12-baz'
|
54
54
|
|
55
|
-
proc{app.template(:b){"a"}}.
|
55
|
+
proc{app.template(:b){"a"}}.must_raise FrozenError
|
56
56
|
end
|
57
57
|
|
58
58
|
it "works with the view_subdirs plugin" do
|
@@ -89,8 +89,8 @@ describe "named_templates plugin" do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
body('/foo').
|
93
|
-
body('/bar').
|
92
|
+
body('/foo').must_equal 'foo13-foobar12-baz'
|
93
|
+
body('/bar').must_equal 'bar43-barfoo42-baz'
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
@@ -40,27 +40,27 @@ describe "not_allowed plugin" do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
body.
|
44
|
-
status('REQUEST_METHOD'=>'POST').
|
45
|
-
header('Allow', 'REQUEST_METHOD'=>'POST').
|
43
|
+
body.must_equal 'a'
|
44
|
+
status('REQUEST_METHOD'=>'POST').must_equal 405
|
45
|
+
header('Allow', 'REQUEST_METHOD'=>'POST').must_equal 'GET'
|
46
46
|
|
47
|
-
body('/b').
|
48
|
-
status('/b', 'REQUEST_METHOD'=>'POST').
|
47
|
+
body('/b').must_equal 'b'
|
48
|
+
status('/b', 'REQUEST_METHOD'=>'POST').must_equal 404
|
49
49
|
|
50
|
-
body('/d').
|
51
|
-
status('/d', 'REQUEST_METHOD'=>'POST').
|
50
|
+
body('/d').must_equal 'd'
|
51
|
+
status('/d', 'REQUEST_METHOD'=>'POST').must_equal 404
|
52
52
|
|
53
|
-
body('/e').
|
54
|
-
status('/e', 'REQUEST_METHOD'=>'POST').
|
53
|
+
body('/e').must_equal 'e'
|
54
|
+
status('/e', 'REQUEST_METHOD'=>'POST').must_equal 404
|
55
55
|
|
56
|
-
body('/q').
|
57
|
-
status('/q', 'REQUEST_METHOD'=>'POST').
|
56
|
+
body('/q').must_equal 'q'
|
57
|
+
status('/q', 'REQUEST_METHOD'=>'POST').must_equal 405
|
58
58
|
|
59
|
-
body('/c').
|
60
|
-
body('/c').
|
61
|
-
body('/c', 'REQUEST_METHOD'=>'POST').
|
62
|
-
body('/c', 'REQUEST_METHOD'=>'PATCH').
|
63
|
-
status('/c', 'REQUEST_METHOD'=>'PATCH').
|
64
|
-
header('Allow', '/c', 'REQUEST_METHOD'=>'PATCH').
|
59
|
+
body('/c').must_equal 'cg'
|
60
|
+
body('/c').must_equal 'cg'
|
61
|
+
body('/c', 'REQUEST_METHOD'=>'POST').must_equal 'cp'
|
62
|
+
body('/c', 'REQUEST_METHOD'=>'PATCH').must_equal 'c'
|
63
|
+
status('/c', 'REQUEST_METHOD'=>'PATCH').must_equal 405
|
64
|
+
header('Allow', '/c', 'REQUEST_METHOD'=>'PATCH').must_equal 'GET, POST'
|
65
65
|
end
|
66
66
|
end
|
@@ -16,10 +16,10 @@ describe "not_found plugin" do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
body.
|
20
|
-
status.
|
21
|
-
body("/a").
|
22
|
-
status("/a").
|
19
|
+
body.must_equal 'not found'
|
20
|
+
status.must_equal 404
|
21
|
+
body("/a").must_equal 'found'
|
22
|
+
status("/a").must_equal 200
|
23
23
|
end
|
24
24
|
|
25
25
|
it "allows overriding status inside not_found" do
|
@@ -35,7 +35,7 @@ describe "not_found plugin" do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
status.
|
38
|
+
status.must_equal 403
|
39
39
|
end
|
40
40
|
|
41
41
|
it "calculates correct Content-Length" do
|
@@ -47,7 +47,7 @@ describe "not_found plugin" do
|
|
47
47
|
route{}
|
48
48
|
end
|
49
49
|
|
50
|
-
header('Content-Length').
|
50
|
+
header('Content-Length').must_equal "1"
|
51
51
|
end
|
52
52
|
|
53
53
|
it "clears existing headers" do
|
@@ -63,8 +63,8 @@ describe "not_found plugin" do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
header('Content-Type').
|
67
|
-
header('Foo').
|
66
|
+
header('Content-Type').must_equal 'text/html'
|
67
|
+
header('Foo').must_equal nil
|
68
68
|
end
|
69
69
|
|
70
70
|
it "does not modify behavior if not_found is not called" do
|
@@ -74,8 +74,8 @@ describe "not_found plugin" do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
body.
|
78
|
-
body("/a").
|
77
|
+
body.must_equal ''
|
78
|
+
body("/a").must_equal 'found'
|
79
79
|
end
|
80
80
|
|
81
81
|
it "can set not_found via the plugin block" do
|
@@ -91,8 +91,8 @@ describe "not_found plugin" do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
body.
|
95
|
-
body("/a").
|
94
|
+
body.must_equal 'not found'
|
95
|
+
body("/a").must_equal 'found'
|
96
96
|
end
|
97
97
|
|
98
98
|
it "does not modify behavior if body is not an array" do
|
@@ -108,7 +108,7 @@ describe "not_found plugin" do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
body.
|
111
|
+
body.must_equal ''
|
112
112
|
end
|
113
113
|
|
114
114
|
it "does not modify behavior if body is not an empty array" do
|
@@ -123,6 +123,6 @@ describe "not_found plugin" do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
body.
|
126
|
+
body.must_equal 'a'
|
127
127
|
end
|
128
128
|
end
|