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
@@ -18,10 +18,10 @@ describe "error_handler plugin" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
body("/a").
|
22
|
-
status("/a").
|
23
|
-
body.
|
24
|
-
status.
|
21
|
+
body("/a").must_equal 'found'
|
22
|
+
status("/a").must_equal 200
|
23
|
+
body.must_equal 'bad idea'
|
24
|
+
status.must_equal 500
|
25
25
|
end
|
26
26
|
|
27
27
|
it "executes on SyntaxError exceptions" do
|
@@ -41,10 +41,10 @@ describe "error_handler plugin" do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
body("/a").
|
45
|
-
status("/a").
|
46
|
-
body.
|
47
|
-
status.
|
44
|
+
body("/a").must_equal 'found'
|
45
|
+
status("/a").must_equal 200
|
46
|
+
body.must_equal 'bad idea'
|
47
|
+
status.must_equal 500
|
48
48
|
end
|
49
49
|
|
50
50
|
it "can override status inside error block" do
|
@@ -59,7 +59,7 @@ describe "error_handler plugin" do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
status.
|
62
|
+
status.must_equal 501
|
63
63
|
end
|
64
64
|
|
65
65
|
it "calculates correct Content-Length" do
|
@@ -73,7 +73,7 @@ describe "error_handler plugin" do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
header('Content-Length').
|
76
|
+
header('Content-Length').must_equal "1"
|
77
77
|
end
|
78
78
|
|
79
79
|
it "clears existing headers" do
|
@@ -89,8 +89,8 @@ describe "error_handler plugin" do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
header('Content-Type').
|
93
|
-
header('Foo').
|
92
|
+
header('Content-Type').must_equal 'text/html'
|
93
|
+
header('Foo').must_equal nil
|
94
94
|
end
|
95
95
|
|
96
96
|
it "can set error via the plugin block" do
|
@@ -104,7 +104,7 @@ describe "error_handler plugin" do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
body.
|
107
|
+
body.must_equal 'bad idea'
|
108
108
|
end
|
109
109
|
|
110
110
|
it "has default error handler also raise" do
|
@@ -116,6 +116,6 @@ describe "error_handler plugin" do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
proc{req}.
|
119
|
+
proc{req}.must_raise(ArgumentError)
|
120
120
|
end
|
121
121
|
end
|
data/spec/plugin/flash_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe "flash plugin" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
body.
|
17
|
+
body.must_equal 'b'
|
18
18
|
end
|
19
19
|
|
20
20
|
it "flash[] sets flash for next page" do
|
@@ -36,88 +36,89 @@ describe "flash plugin" do
|
|
36
36
|
|
37
37
|
env = proc{|h| h['Set-Cookie'] ? {'HTTP_COOKIE'=>h['Set-Cookie'].sub("; path=/; HttpOnly", '')} : {}}
|
38
38
|
_, h, b = req
|
39
|
-
b.join.
|
39
|
+
b.join.must_equal ''
|
40
40
|
_, h, b = req(env[h])
|
41
|
-
b.join.
|
41
|
+
b.join.must_equal 'b'
|
42
42
|
_, h, b = req(env[h])
|
43
|
-
b.join.
|
43
|
+
b.join.must_equal 'bb'
|
44
44
|
_, h, b = req('/a', env[h])
|
45
|
-
b.join.
|
45
|
+
b.join.must_equal 'cbbb'
|
46
46
|
_, h, b = req(env[h])
|
47
|
-
b.join.
|
47
|
+
b.join.must_equal ''
|
48
48
|
_, h, b = req(env[h])
|
49
|
-
b.join.
|
49
|
+
b.join.must_equal 'b'
|
50
50
|
_, h, b = req(env[h])
|
51
|
-
b.join.
|
51
|
+
b.join.must_equal 'bb'
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "FlashHash" do
|
56
56
|
before do
|
57
|
+
require 'roda/plugins/flash'
|
57
58
|
@h = Roda::RodaPlugins::Flash::FlashHash.new
|
58
59
|
end
|
59
60
|
|
60
61
|
it ".new should accept nil for empty hash" do
|
61
62
|
@h = Roda::RodaPlugins::Flash::FlashHash.new(nil)
|
62
|
-
@h.now.
|
63
|
-
@h.next.
|
63
|
+
@h.now.must_equal({})
|
64
|
+
@h.next.must_equal({})
|
64
65
|
end
|
65
66
|
|
66
67
|
it ".new should accept a hash" do
|
67
68
|
@h = Roda::RodaPlugins::Flash::FlashHash.new(1=>2)
|
68
|
-
@h.now.
|
69
|
-
@h.next.
|
69
|
+
@h.now.must_equal(1=>2)
|
70
|
+
@h.next.must_equal({})
|
70
71
|
end
|
71
72
|
|
72
73
|
it "#[]= assigns to next flash" do
|
73
74
|
@h[1] = 2
|
74
|
-
@h.now.
|
75
|
-
@h.next.
|
75
|
+
@h.now.must_equal({})
|
76
|
+
@h.next.must_equal(1=>2)
|
76
77
|
end
|
77
78
|
|
78
79
|
it "#discard removes given key from next hash" do
|
79
80
|
@h[1] = 2
|
80
81
|
@h[nil] = 3
|
81
|
-
@h.next.
|
82
|
+
@h.next.must_equal(1=>2, nil=>3)
|
82
83
|
@h.discard(nil)
|
83
|
-
@h.next.
|
84
|
+
@h.next.must_equal(1=>2)
|
84
85
|
@h.discard(1)
|
85
|
-
@h.next.
|
86
|
+
@h.next.must_equal({})
|
86
87
|
end
|
87
88
|
|
88
89
|
it "#discard removes all entries from next hash with no arguments" do
|
89
90
|
@h[1] = 2
|
90
91
|
@h[nil] = 3
|
91
|
-
@h.next.
|
92
|
+
@h.next.must_equal(1=>2, nil=>3)
|
92
93
|
@h.discard
|
93
|
-
@h.next.
|
94
|
+
@h.next.must_equal({})
|
94
95
|
end
|
95
96
|
|
96
97
|
it "#keep copies entry for key from current hash to next hash" do
|
97
98
|
@h.now[1] = 2
|
98
99
|
@h.now[nil] = 3
|
99
|
-
@h.next.
|
100
|
+
@h.next.must_equal({})
|
100
101
|
@h.keep(nil)
|
101
|
-
@h.next.
|
102
|
+
@h.next.must_equal(nil=>3)
|
102
103
|
@h.keep(1)
|
103
|
-
@h.next.
|
104
|
+
@h.next.must_equal(1=>2, nil=>3)
|
104
105
|
end
|
105
106
|
|
106
107
|
it "#keep copies all entries from current hash to next hash" do
|
107
108
|
@h.now[1] = 2
|
108
109
|
@h.now[nil] = 3
|
109
|
-
@h.next.
|
110
|
+
@h.next.must_equal({})
|
110
111
|
@h.keep
|
111
|
-
@h.next.
|
112
|
+
@h.next.must_equal(1=>2, nil=>3)
|
112
113
|
end
|
113
114
|
|
114
115
|
it "#sweep replaces current hash with next hash" do
|
115
116
|
@h[1] = 2
|
116
117
|
@h[nil] = 3
|
117
|
-
@h.next.
|
118
|
-
@h.now.
|
119
|
-
@h.sweep.
|
120
|
-
@h.next.
|
121
|
-
@h.now.
|
118
|
+
@h.next.must_equal(1=>2, nil=>3)
|
119
|
+
@h.now.must_equal({})
|
120
|
+
@h.sweep.must_equal(1=>2, nil=>3)
|
121
|
+
@h.next.must_equal({})
|
122
|
+
@h.now.must_equal(1=>2, nil=>3)
|
122
123
|
end
|
123
124
|
end
|
data/spec/plugin/h_spec.rb
CHANGED
data/spec/plugin/halt_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "halt plugin" do
|
|
6
6
|
r.halt [200, {}, ['foo']]
|
7
7
|
end
|
8
8
|
|
9
|
-
body.
|
9
|
+
body.must_equal "foo"
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should consider string argument as response body" do
|
@@ -14,7 +14,7 @@ describe "halt plugin" do
|
|
14
14
|
r.halt "foo"
|
15
15
|
end
|
16
16
|
|
17
|
-
body.
|
17
|
+
body.must_equal "foo"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should consider integer argument as response status" do
|
@@ -22,7 +22,7 @@ describe "halt plugin" do
|
|
22
22
|
r.halt 300
|
23
23
|
end
|
24
24
|
|
25
|
-
status.
|
25
|
+
status.must_equal 300
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should consider other single arguments similar to block bodies" do
|
@@ -34,7 +34,7 @@ describe "halt plugin" do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
body.
|
37
|
+
body.must_equal '{"a":1}'
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should consider 2 arguments as response status and body" do
|
@@ -42,8 +42,8 @@ describe "halt plugin" do
|
|
42
42
|
r.halt 300, "foo"
|
43
43
|
end
|
44
44
|
|
45
|
-
status.
|
46
|
-
body.
|
45
|
+
status.must_equal 300
|
46
|
+
body.must_equal "foo"
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should handle 2nd of 2 arguments similar to block bodies" do
|
@@ -55,8 +55,8 @@ describe "halt plugin" do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
status.
|
59
|
-
body.
|
58
|
+
status.must_equal 300
|
59
|
+
body.must_equal '{"a":1}'
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should consider 3 arguments as response" do
|
@@ -64,9 +64,9 @@ describe "halt plugin" do
|
|
64
64
|
r.halt 300, {'a'=>'b'}, "foo"
|
65
65
|
end
|
66
66
|
|
67
|
-
status.
|
68
|
-
header('a').
|
69
|
-
body.
|
67
|
+
status.must_equal 300
|
68
|
+
header('a').must_equal 'b'
|
69
|
+
body.must_equal "foo"
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should handle 3rd of 3 arguments similar to block bodies" do
|
@@ -78,9 +78,9 @@ describe "halt plugin" do
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
status.
|
82
|
-
header('a').
|
83
|
-
body.
|
81
|
+
status.must_equal 300
|
82
|
+
header('a').must_equal 'b'
|
83
|
+
body.must_equal '{"a":1}'
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should raise an error for too many arguments" do
|
@@ -88,7 +88,7 @@ describe "halt plugin" do
|
|
88
88
|
r.halt 300, {'a'=>'b'}, "foo", 1
|
89
89
|
end
|
90
90
|
|
91
|
-
proc{req}.
|
91
|
+
proc{req}.must_raise(Roda::RodaError)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should raise an error for single argument not integer, String, or Array" do
|
@@ -96,6 +96,6 @@ describe "halt plugin" do
|
|
96
96
|
r.halt('a'=>'b')
|
97
97
|
end
|
98
98
|
|
99
|
-
proc{req}.
|
99
|
+
proc{req}.must_raise(Roda::RodaError)
|
100
100
|
end
|
101
101
|
end
|
@@ -18,10 +18,10 @@ describe "hash_matcher plugin" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
body("/foo").
|
22
|
-
body("/foofoo").
|
23
|
-
body("/foofoofoo").
|
24
|
-
status("/foofoofoofoo").
|
25
|
-
status.
|
21
|
+
body("/foo").must_equal '1foo'
|
22
|
+
body("/foofoo").must_equal '2foofoo'
|
23
|
+
body("/foofoofoo").must_equal '3foofoofoo'
|
24
|
+
status("/foofoofoofoo").must_equal 404
|
25
|
+
status.must_equal 404
|
26
26
|
end
|
27
27
|
end
|
data/spec/plugin/head_spec.rb
CHANGED
@@ -17,19 +17,19 @@ describe "head plugin" do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
s, h, b = req
|
20
|
-
s.
|
21
|
-
h['Content-Length'].
|
22
|
-
b.
|
20
|
+
s.must_equal 200
|
21
|
+
h['Content-Length'].must_equal '4'
|
22
|
+
b.must_equal ['root']
|
23
23
|
|
24
24
|
s, h, b = req('REQUEST_METHOD' => 'HEAD')
|
25
|
-
s.
|
26
|
-
h['Content-Length'].
|
27
|
-
b.
|
25
|
+
s.must_equal 200
|
26
|
+
h['Content-Length'].must_equal '4'
|
27
|
+
b.must_equal []
|
28
28
|
|
29
|
-
body('/a').
|
30
|
-
status('/a', 'REQUEST_METHOD' => 'HEAD').
|
29
|
+
body('/a').must_equal 'a'
|
30
|
+
status('/a', 'REQUEST_METHOD' => 'HEAD').must_equal 200
|
31
31
|
|
32
|
-
body('/b').
|
33
|
-
status('/b', 'REQUEST_METHOD' => 'HEAD').
|
32
|
+
body('/b').must_equal 'b'
|
33
|
+
status('/b', 'REQUEST_METHOD' => 'HEAD').must_equal 200
|
34
34
|
end
|
35
35
|
end
|
@@ -8,8 +8,8 @@ describe "accept matcher" do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
body("HTTP_ACCEPT" => "application/xml").
|
12
|
-
status.
|
11
|
+
body("HTTP_ACCEPT" => "application/xml").must_equal "application/xml"
|
12
|
+
status.must_equal 404
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -21,8 +21,8 @@ describe "header matcher" do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
body("HTTP_ACCEPT" => "application/xml").
|
25
|
-
status.
|
24
|
+
body("HTTP_ACCEPT" => "application/xml").must_equal "bar"
|
25
|
+
status.must_equal 404
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should yield the header value if :match_header_yield option is present" do
|
@@ -36,8 +36,8 @@ describe "header matcher" do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
body("HTTP_ACCEPT" => "application/xml").
|
40
|
-
status.
|
39
|
+
body("HTTP_ACCEPT" => "application/xml").must_equal "bar-application/xml"
|
40
|
+
status.must_equal 404
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -49,8 +49,8 @@ describe "host matcher" do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
body("HTTP_HOST" => "example.com").
|
53
|
-
status("HTTP_HOST" => "foo.com").
|
52
|
+
body("HTTP_HOST" => "example.com").must_equal 'worked'
|
53
|
+
status("HTTP_HOST" => "foo.com").must_equal 404
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should match a host with a regexp" do
|
@@ -60,8 +60,8 @@ describe "host matcher" do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
body("HTTP_HOST" => "example.com").
|
64
|
-
status("HTTP_HOST" => "foo.com").
|
63
|
+
body("HTTP_HOST" => "example.com").must_equal 'worked'
|
64
|
+
status("HTTP_HOST" => "foo.com").must_equal 404
|
65
65
|
end
|
66
66
|
|
67
67
|
it "doesn't yield HOST" do
|
@@ -71,7 +71,7 @@ describe "host matcher" do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
body("HTTP_HOST" => "example.com").
|
74
|
+
body("HTTP_HOST" => "example.com").must_equal '0'
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -83,8 +83,8 @@ describe "user_agent matcher" do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
body("HTTP_USER_AGENT" => "chrome31").
|
87
|
-
status.
|
86
|
+
body("HTTP_USER_AGENT" => "chrome31").must_equal "a-chrome-31"
|
87
|
+
status.must_equal 404
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
describe "heartbeat plugin" do
|
4
|
+
it "should return heartbeat response for heartbeat paths only" do
|
5
|
+
app(:bare) do
|
6
|
+
plugin :heartbeat
|
7
|
+
route do |r|
|
8
|
+
r.on 'a' do
|
9
|
+
"a"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
body('/a').must_equal 'a'
|
15
|
+
status.must_equal 404
|
16
|
+
status('/heartbeat').must_equal 200
|
17
|
+
body('/heartbeat').must_equal 'OK'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should support custom heartbeat paths" do
|
21
|
+
app(:bare) do
|
22
|
+
plugin :heartbeat, :path=>'/heartbeat2'
|
23
|
+
route do |r|
|
24
|
+
r.on 'a' do
|
25
|
+
"a"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
body('/a').must_equal 'a'
|
31
|
+
status.must_equal 404
|
32
|
+
status('/heartbeat').must_equal 404
|
33
|
+
status('/heartbeat2').must_equal 200
|
34
|
+
body('/heartbeat2').must_equal 'OK'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should work when using sessions" do
|
38
|
+
app(:bare) do
|
39
|
+
use Rack::Session::Cookie, :secret=>'foo'
|
40
|
+
plugin :heartbeat
|
41
|
+
|
42
|
+
route do |r|
|
43
|
+
session.clear
|
44
|
+
r.on "a" do
|
45
|
+
"a"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
body('/a').must_equal 'a'
|
51
|
+
status.must_equal 404
|
52
|
+
status('/heartbeat').must_equal 200
|
53
|
+
body('/heartbeat').must_equal 'OK'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should work when redirecting" do
|
57
|
+
app(:bare) do
|
58
|
+
plugin :heartbeat
|
59
|
+
|
60
|
+
route do |r|
|
61
|
+
r.on "a" do
|
62
|
+
"a"
|
63
|
+
end
|
64
|
+
r.redirect '/a'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
body('/a').must_equal 'a'
|
69
|
+
status.must_equal 302
|
70
|
+
status('/heartbeat').must_equal 200
|
71
|
+
body('/heartbeat').must_equal 'OK'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|