roda 3.28.0 → 3.29.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/README.rdoc +10 -0
- data/doc/release_notes/3.29.0.txt +15 -0
- data/lib/roda.rb +1 -0
- data/lib/roda/plugins/caching.rb +2 -0
- data/lib/roda/plugins/common_logger.rb +1 -1
- data/lib/roda/plugins/exception_page.rb +7 -1
- data/lib/roda/plugins/indifferent_params.rb +2 -0
- data/lib/roda/version.rb +1 -1
- metadata +4 -214
- data/Rakefile +0 -108
- data/doc/release_notes/1.0.0.txt +0 -329
- data/doc/release_notes/1.1.0.txt +0 -226
- data/doc/release_notes/1.2.0.txt +0 -406
- data/doc/release_notes/1.3.0.txt +0 -109
- data/doc/release_notes/2.0.0.txt +0 -75
- data/doc/release_notes/2.1.0.txt +0 -124
- data/doc/release_notes/2.10.0.txt +0 -27
- data/doc/release_notes/2.11.0.txt +0 -70
- data/doc/release_notes/2.12.0.txt +0 -40
- data/doc/release_notes/2.13.0.txt +0 -10
- data/doc/release_notes/2.14.0.txt +0 -44
- data/doc/release_notes/2.15.0.txt +0 -53
- data/doc/release_notes/2.16.0.txt +0 -48
- data/doc/release_notes/2.17.0.txt +0 -62
- data/doc/release_notes/2.18.0.txt +0 -69
- data/doc/release_notes/2.19.0.txt +0 -30
- data/doc/release_notes/2.2.0.txt +0 -97
- data/doc/release_notes/2.20.0.txt +0 -5
- data/doc/release_notes/2.21.0.txt +0 -17
- data/doc/release_notes/2.22.0.txt +0 -41
- data/doc/release_notes/2.23.0.txt +0 -29
- data/doc/release_notes/2.24.0.txt +0 -65
- data/doc/release_notes/2.25.0.txt +0 -14
- data/doc/release_notes/2.26.0.txt +0 -13
- data/doc/release_notes/2.27.0.txt +0 -56
- data/doc/release_notes/2.28.0.txt +0 -17
- data/doc/release_notes/2.29.0.txt +0 -156
- data/doc/release_notes/2.3.0.txt +0 -109
- data/doc/release_notes/2.4.0.txt +0 -55
- data/doc/release_notes/2.5.0.txt +0 -23
- data/doc/release_notes/2.5.1.txt +0 -4
- data/doc/release_notes/2.6.0.txt +0 -21
- data/doc/release_notes/2.7.0.txt +0 -75
- data/doc/release_notes/2.8.0.txt +0 -44
- data/doc/release_notes/2.9.0.txt +0 -6
- data/spec/all.rb +0 -1
- data/spec/assets/css/app.scss +0 -1
- data/spec/assets/css/no_access.css +0 -1
- data/spec/assets/css/raw.css +0 -1
- data/spec/assets/js/head/app.js +0 -1
- data/spec/composition_spec.rb +0 -31
- data/spec/define_roda_method_spec.rb +0 -274
- data/spec/env_spec.rb +0 -11
- data/spec/freeze_spec.rb +0 -37
- data/spec/integration_spec.rb +0 -209
- data/spec/matchers_spec.rb +0 -832
- data/spec/opts_spec.rb +0 -42
- data/spec/plugin/_after_hook_spec.rb +0 -19
- data/spec/plugin/all_verbs_spec.rb +0 -29
- data/spec/plugin/assets_preloading_spec.rb +0 -98
- data/spec/plugin/assets_spec.rb +0 -745
- data/spec/plugin/backtracking_array_spec.rb +0 -42
- data/spec/plugin/branch_locals_spec.rb +0 -106
- data/spec/plugin/caching_spec.rb +0 -337
- data/spec/plugin/chunked_spec.rb +0 -201
- data/spec/plugin/class_level_routing_spec.rb +0 -164
- data/spec/plugin/class_matchers_spec.rb +0 -40
- data/spec/plugin/common_logger_spec.rb +0 -85
- data/spec/plugin/content_for_spec.rb +0 -162
- data/spec/plugin/content_security_policy_spec.rb +0 -175
- data/spec/plugin/cookies_spec.rb +0 -51
- data/spec/plugin/csrf_spec.rb +0 -111
- data/spec/plugin/default_headers_spec.rb +0 -82
- data/spec/plugin/default_status_spec.rb +0 -95
- data/spec/plugin/delay_build_spec.rb +0 -23
- data/spec/plugin/delegate_spec.rb +0 -23
- data/spec/plugin/delete_empty_headers_spec.rb +0 -27
- data/spec/plugin/direct_call_spec.rb +0 -28
- data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
- data/spec/plugin/drop_body_spec.rb +0 -24
- data/spec/plugin/early_hints_spec.rb +0 -19
- data/spec/plugin/empty_root_spec.rb +0 -14
- data/spec/plugin/environments_spec.rb +0 -42
- data/spec/plugin/error_email_spec.rb +0 -97
- data/spec/plugin/error_handler_spec.rb +0 -216
- data/spec/plugin/error_mail_spec.rb +0 -93
- data/spec/plugin/exception_page_spec.rb +0 -168
- data/spec/plugin/flash_spec.rb +0 -121
- data/spec/plugin/h_spec.rb +0 -11
- data/spec/plugin/halt_spec.rb +0 -119
- data/spec/plugin/hash_matcher_spec.rb +0 -27
- data/spec/plugin/hash_routes_spec.rb +0 -535
- data/spec/plugin/head_spec.rb +0 -52
- data/spec/plugin/header_matchers_spec.rb +0 -98
- data/spec/plugin/heartbeat_spec.rb +0 -74
- data/spec/plugin/hooks_spec.rb +0 -152
- data/spec/plugin/indifferent_params_spec.rb +0 -14
- data/spec/plugin/json_parser_spec.rb +0 -141
- data/spec/plugin/json_spec.rb +0 -83
- data/spec/plugin/mail_processor_spec.rb +0 -451
- data/spec/plugin/mailer_spec.rb +0 -282
- data/spec/plugin/match_affix_spec.rb +0 -43
- data/spec/plugin/match_hook_spec.rb +0 -79
- data/spec/plugin/middleware_spec.rb +0 -237
- data/spec/plugin/middleware_stack_spec.rb +0 -81
- data/spec/plugin/module_include_spec.rb +0 -48
- data/spec/plugin/multi_route_spec.rb +0 -268
- data/spec/plugin/multi_run_spec.rb +0 -87
- data/spec/plugin/multi_view_spec.rb +0 -50
- data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
- data/spec/plugin/named_templates_spec.rb +0 -96
- data/spec/plugin/not_allowed_spec.rb +0 -69
- data/spec/plugin/not_found_spec.rb +0 -128
- data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
- data/spec/plugin/padrino_render_spec.rb +0 -34
- data/spec/plugin/param_matchers_spec.rb +0 -69
- data/spec/plugin/params_capturing_spec.rb +0 -33
- data/spec/plugin/partials_spec.rb +0 -43
- data/spec/plugin/pass_spec.rb +0 -29
- data/spec/plugin/path_matchers_spec.rb +0 -42
- data/spec/plugin/path_rewriter_spec.rb +0 -45
- data/spec/plugin/path_spec.rb +0 -222
- data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
- data/spec/plugin/precompile_templates_spec.rb +0 -61
- data/spec/plugin/public_spec.rb +0 -85
- data/spec/plugin/render_each_spec.rb +0 -82
- data/spec/plugin/render_locals_spec.rb +0 -114
- data/spec/plugin/render_spec.rb +0 -912
- data/spec/plugin/request_aref_spec.rb +0 -51
- data/spec/plugin/request_headers_spec.rb +0 -39
- data/spec/plugin/response_request_spec.rb +0 -43
- data/spec/plugin/route_block_args_spec.rb +0 -86
- data/spec/plugin/route_csrf_spec.rb +0 -305
- data/spec/plugin/run_append_slash_spec.rb +0 -77
- data/spec/plugin/run_handler_spec.rb +0 -53
- data/spec/plugin/sessions_spec.rb +0 -452
- data/spec/plugin/shared_vars_spec.rb +0 -45
- data/spec/plugin/sinatra_helpers_spec.rb +0 -537
- data/spec/plugin/slash_path_empty_spec.rb +0 -22
- data/spec/plugin/static_routing_spec.rb +0 -192
- data/spec/plugin/static_spec.rb +0 -30
- data/spec/plugin/status_303_spec.rb +0 -28
- data/spec/plugin/status_handler_spec.rb +0 -158
- data/spec/plugin/streaming_spec.rb +0 -246
- data/spec/plugin/strip_path_prefix_spec.rb +0 -24
- data/spec/plugin/symbol_matchers_spec.rb +0 -51
- data/spec/plugin/symbol_status_spec.rb +0 -25
- data/spec/plugin/symbol_views_spec.rb +0 -32
- data/spec/plugin/timestamp_public_spec.rb +0 -85
- data/spec/plugin/type_routing_spec.rb +0 -348
- data/spec/plugin/typecast_params_spec.rb +0 -1370
- data/spec/plugin/unescape_path_spec.rb +0 -22
- data/spec/plugin/view_options_spec.rb +0 -170
- data/spec/plugin_spec.rb +0 -71
- data/spec/redirect_spec.rb +0 -41
- data/spec/request_spec.rb +0 -97
- data/spec/response_spec.rb +0 -199
- data/spec/route_spec.rb +0 -39
- data/spec/session_middleware_spec.rb +0 -129
- data/spec/session_spec.rb +0 -37
- data/spec/spec_helper.rb +0 -137
- data/spec/version_spec.rb +0 -14
- data/spec/views/_test.erb +0 -1
- data/spec/views/a.erb +0 -1
- data/spec/views/a.rdoc +0 -2
- data/spec/views/about.erb +0 -1
- data/spec/views/about.str +0 -1
- data/spec/views/about/_test.css.gz +0 -0
- data/spec/views/about/_test.erb +0 -1
- data/spec/views/about/_test.erb.gz +0 -0
- data/spec/views/about/comp_test.erb +0 -1
- data/spec/views/b.erb +0 -1
- data/spec/views/c.erb +0 -1
- data/spec/views/comp_layout.erb +0 -1
- data/spec/views/comp_test.erb +0 -1
- data/spec/views/content-yield.erb +0 -1
- data/spec/views/each.str +0 -1
- data/spec/views/home.erb +0 -2
- data/spec/views/home.str +0 -2
- data/spec/views/iv.erb +0 -1
- data/spec/views/layout-alternative.erb +0 -2
- data/spec/views/layout-yield.erb +0 -3
- data/spec/views/layout.erb +0 -2
- data/spec/views/layout.str +0 -2
- data/spec/views/multiple-layout.erb +0 -1
- data/spec/views/multiple.erb +0 -1
@@ -1,216 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "error_handler plugin" do
|
4
|
-
it "executes only if error raised" do
|
5
|
-
app(:bare) do
|
6
|
-
plugin :error_handler
|
7
|
-
|
8
|
-
error do |e|
|
9
|
-
e.message
|
10
|
-
end
|
11
|
-
|
12
|
-
route do |r|
|
13
|
-
r.on "a" do
|
14
|
-
"found"
|
15
|
-
end
|
16
|
-
|
17
|
-
raise ArgumentError, "bad idea"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
body("/a").must_equal 'found'
|
22
|
-
status("/a").must_equal 200
|
23
|
-
body.must_equal 'bad idea'
|
24
|
-
status.must_equal 500
|
25
|
-
end
|
26
|
-
|
27
|
-
deprecated "works if #call is overridden" do
|
28
|
-
app(:bare) do
|
29
|
-
plugin :error_handler
|
30
|
-
|
31
|
-
def call
|
32
|
-
super
|
33
|
-
end
|
34
|
-
|
35
|
-
error do |e|
|
36
|
-
e.message
|
37
|
-
end
|
38
|
-
|
39
|
-
route do |r|
|
40
|
-
r.on "a" do
|
41
|
-
"found"
|
42
|
-
end
|
43
|
-
|
44
|
-
raise ArgumentError, "bad idea"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
body("/a").must_equal 'found'
|
49
|
-
status("/a").must_equal 200
|
50
|
-
body.must_equal 'bad idea'
|
51
|
-
status.must_equal 500
|
52
|
-
end
|
53
|
-
|
54
|
-
it "executes on SyntaxError exceptions" do
|
55
|
-
app(:bare) do
|
56
|
-
plugin :error_handler
|
57
|
-
|
58
|
-
error do |e|
|
59
|
-
e.message
|
60
|
-
end
|
61
|
-
|
62
|
-
route do |r|
|
63
|
-
r.on "a" do
|
64
|
-
"found"
|
65
|
-
end
|
66
|
-
|
67
|
-
raise SyntaxError, 'bad idea'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
body("/a").must_equal 'found'
|
72
|
-
status("/a").must_equal 200
|
73
|
-
body.must_equal 'bad idea'
|
74
|
-
status.must_equal 500
|
75
|
-
end
|
76
|
-
|
77
|
-
it "executes on custom exception classes" do
|
78
|
-
app(:bare) do
|
79
|
-
plugin :error_handler, :classes=>[StandardError]
|
80
|
-
|
81
|
-
error do |e|
|
82
|
-
e.message
|
83
|
-
end
|
84
|
-
|
85
|
-
route do |r|
|
86
|
-
r.on "a" do
|
87
|
-
raise 'foo'
|
88
|
-
end
|
89
|
-
|
90
|
-
raise SyntaxError, 'bad idea'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
proc{body}.must_raise SyntaxError
|
95
|
-
body("/a").must_equal 'foo'
|
96
|
-
|
97
|
-
@app = Class.new(@app)
|
98
|
-
proc{body}.must_raise SyntaxError
|
99
|
-
body("/a").must_equal 'foo'
|
100
|
-
end
|
101
|
-
|
102
|
-
it "can override status inside error block" do
|
103
|
-
app(:bare) do
|
104
|
-
plugin :error_handler do |e|
|
105
|
-
response.status = 501
|
106
|
-
e.message
|
107
|
-
end
|
108
|
-
|
109
|
-
route do |r|
|
110
|
-
raise ArgumentError, "bad idea"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
status.must_equal 501
|
115
|
-
end
|
116
|
-
|
117
|
-
it "calculates correct Content-Length" do
|
118
|
-
app(:bare) do
|
119
|
-
plugin :error_handler do |e|
|
120
|
-
"a"
|
121
|
-
end
|
122
|
-
|
123
|
-
route do |r|
|
124
|
-
raise ArgumentError, "bad idea"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
header('Content-Length').must_equal "1"
|
129
|
-
end
|
130
|
-
|
131
|
-
it "clears existing headers" do
|
132
|
-
app(:bare) do
|
133
|
-
plugin :error_handler do |e|
|
134
|
-
"a"
|
135
|
-
end
|
136
|
-
|
137
|
-
route do |r|
|
138
|
-
response['Content-Type'] = 'text/pdf'
|
139
|
-
response['Foo'] = 'bar'
|
140
|
-
raise ArgumentError, "bad idea"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
header('Content-Type').must_equal 'text/html'
|
145
|
-
header('Foo').must_be_nil
|
146
|
-
end
|
147
|
-
|
148
|
-
it "can set error via the plugin block" do
|
149
|
-
app(:bare) do
|
150
|
-
plugin :error_handler do |e|
|
151
|
-
e.message
|
152
|
-
end
|
153
|
-
|
154
|
-
route do |r|
|
155
|
-
raise ArgumentError, "bad idea"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
body.must_equal 'bad idea'
|
160
|
-
end
|
161
|
-
|
162
|
-
it "has default error handler also raise" do
|
163
|
-
app(:bare) do
|
164
|
-
plugin :error_handler
|
165
|
-
|
166
|
-
route do |r|
|
167
|
-
raise ArgumentError, "bad idea"
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
proc{req}.must_raise(ArgumentError)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "logs exceptions during after processing of error handler" do
|
175
|
-
app(:bare) do
|
176
|
-
plugin :error_handler do |e|
|
177
|
-
e.message * 2
|
178
|
-
end
|
179
|
-
plugin :hooks
|
180
|
-
|
181
|
-
after do
|
182
|
-
raise "foo"
|
183
|
-
end
|
184
|
-
|
185
|
-
route do |r|
|
186
|
-
''
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
errors = StringIO.new
|
191
|
-
body('rack.errors'=>errors).must_equal 'foofoo'
|
192
|
-
errors.rewind
|
193
|
-
errors.read.split("\n").first.must_equal "Error in after hook processing of error handler: RuntimeError: foo"
|
194
|
-
end
|
195
|
-
|
196
|
-
it "has access to current remaining_path" do
|
197
|
-
app(:bare) do
|
198
|
-
plugin :error_handler do |e|
|
199
|
-
request.remaining_path
|
200
|
-
end
|
201
|
-
|
202
|
-
route do |r|
|
203
|
-
r.on('a') do
|
204
|
-
raise ArgumentError, "bad idea"
|
205
|
-
end
|
206
|
-
|
207
|
-
raise ArgumentError, "bad idea"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
body.must_equal '/'
|
212
|
-
body('/b').must_equal '/b'
|
213
|
-
body('/a').must_equal ''
|
214
|
-
body('/a/c').must_equal '/c'
|
215
|
-
end
|
216
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'mail'
|
5
|
-
rescue LoadError
|
6
|
-
warn "mail not installed, skipping mail plugin test"
|
7
|
-
else
|
8
|
-
Mail.defaults do
|
9
|
-
delivery_method :test
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "error_mail plugin" do
|
13
|
-
def app(opts={})
|
14
|
-
@emails = [] unless defined?(@emails)
|
15
|
-
@app ||= super(:bare) do
|
16
|
-
plugin :error_mail, {:to=>'t', :from=>'f'}.merge(opts)
|
17
|
-
|
18
|
-
route do |r|
|
19
|
-
r.get('noerror'){error_mail("Problem"); 'g'}
|
20
|
-
raise ArgumentError, 'bad foo' rescue error_mail($!)
|
21
|
-
'e'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
after do
|
27
|
-
Mail::TestMailer.deliveries.clear
|
28
|
-
end
|
29
|
-
|
30
|
-
def email
|
31
|
-
Mail::TestMailer.deliveries.last
|
32
|
-
end
|
33
|
-
|
34
|
-
it "adds error_mail method for emailing exceptions" do
|
35
|
-
app
|
36
|
-
body('rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'}).must_equal 'e'
|
37
|
-
email.to.must_equal ['t']
|
38
|
-
email.from.must_equal ['f']
|
39
|
-
email.header.to_s.must_match(/^Subject: ArgumentError: bad foo/)
|
40
|
-
email.body.to_s.must_match(/^Backtrace:$.+^ENV:$.+^"rack\.input" => .+^Params:$\s+^"b" => "c"$\s+^Session:$\s+^"d" => "e"$/m)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "have error_mail method support string arguments" do
|
44
|
-
app
|
45
|
-
body('/noerror', 'rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'}).must_equal 'g'
|
46
|
-
email.to.must_equal ['t']
|
47
|
-
email.from.must_equal ['f']
|
48
|
-
email.header.to_s.must_match(/^Subject: Problem/)
|
49
|
-
email.body.to_s.must_match(/^ENV:$.+^"rack\.input" => .+^Params:$\s+^"b" => "c"$\s+^Session:$\s+^"d" => "e"$/m)
|
50
|
-
email.body.to_s.wont_include('Backtrace')
|
51
|
-
end
|
52
|
-
|
53
|
-
it "supports error_mail_content for the content of the email" do
|
54
|
-
app.route do |r|
|
55
|
-
raise ArgumentError, 'bad foo' rescue error_mail_content($!)
|
56
|
-
end
|
57
|
-
b = body('rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'})
|
58
|
-
b.must_match(/^Subject: ArgumentError: bad foo/)
|
59
|
-
b.must_match(/^Backtrace:.+^ENV:.+^"rack\.input" => .+^Params:\s+^"b" => "c"\s+^Session:\s+^"d" => "e"/m)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "adds :prefix option to subject line" do
|
63
|
-
app(:prefix=>'TEST ')
|
64
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
65
|
-
email.header.to_s.must_match(/^Subject: TEST ArgumentError/)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "uses :headers option for additional headers" do
|
69
|
-
app(:headers=>{'Foo'=>'Bar', 'Baz'=>'Quux'})
|
70
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
71
|
-
email.header.to_s.must_match(/^Foo: Bar/)
|
72
|
-
email.header.to_s.must_match(/^Baz: Quux/)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "requires the :to and :from options" do
|
76
|
-
proc{app :from=>nil}.must_raise(Roda::RodaError)
|
77
|
-
proc{app :to=>nil}.must_raise(Roda::RodaError)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "works correctly in subclasses" do
|
81
|
-
@app = Class.new(app)
|
82
|
-
@app.route do |r|
|
83
|
-
raise ArgumentError rescue error_mail($!)
|
84
|
-
'e'
|
85
|
-
end
|
86
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
87
|
-
email.to.must_equal ['t']
|
88
|
-
email.from.must_equal ['f']
|
89
|
-
email.header.to_s.must_match(/^Subject: ArgumentError: ArgumentError/)
|
90
|
-
email.body.to_s.must_match(/^Backtrace:$.+^ENV:$.+^"rack\.input" => .+/m)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "exception_page plugin" do
|
4
|
-
def ep_app(&block)
|
5
|
-
app(:exception_page) do |r|
|
6
|
-
raise "foo" rescue block ? instance_exec($!, &block) : exception_page($!)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def req(path = '/', headers={})
|
11
|
-
if path.is_a?(Hash)
|
12
|
-
super(path.merge('rack.input'=>StringIO.new))
|
13
|
-
else
|
14
|
-
super(path, headers.merge('rack.input'=>StringIO.new))
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns HTML page with exception information if text/html is accepted" do
|
19
|
-
ep_app
|
20
|
-
s, h, body = req('HTTP_ACCEPT'=>'text/html')
|
21
|
-
|
22
|
-
s.must_equal 200
|
23
|
-
h['Content-Type'].must_equal 'text/html'
|
24
|
-
body = body.join
|
25
|
-
body.must_include "<title>RuntimeError at /"
|
26
|
-
body.must_include "<h1>RuntimeError at /</h1>"
|
27
|
-
body.must_include "<h2>foo</h2>"
|
28
|
-
body.must_include __FILE__
|
29
|
-
body.must_include "No GET data"
|
30
|
-
body.must_include "No POST data"
|
31
|
-
body.must_include "No cookie data"
|
32
|
-
body.must_include "Rack ENV"
|
33
|
-
body.must_include "HTTP_ACCEPT"
|
34
|
-
body.must_include "text/html"
|
35
|
-
body.must_include "table td.code"
|
36
|
-
body.must_include "function toggle()"
|
37
|
-
body.wont_include "\"/exception_page.css\""
|
38
|
-
body.wont_include "\"/exception_page.js\""
|
39
|
-
|
40
|
-
size = body.size
|
41
|
-
ep_app{|e| exception_page(e, :context=>10)}
|
42
|
-
body('HTTP_ACCEPT'=>'text/html').size.must_be :>, size
|
43
|
-
|
44
|
-
ep_app{|e| exception_page(e, :assets=>true, :context=>0)}
|
45
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
46
|
-
body.wont_include "table td.code"
|
47
|
-
body.wont_include "function toggle()"
|
48
|
-
body.must_include "\"/exception_page.css\""
|
49
|
-
body.must_include "\"/exception_page.js\""
|
50
|
-
|
51
|
-
ep_app{|e| exception_page(e, :assets=>"/static", :context=>0)}
|
52
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
53
|
-
body.wont_include "table td.code"
|
54
|
-
body.wont_include "function toggle()"
|
55
|
-
body.must_include "\"/static/exception_page.css\""
|
56
|
-
body.must_include "\"/static/exception_page.js\""
|
57
|
-
|
58
|
-
ep_app{|e| exception_page(e, :css_file=>"/foo.css", :context=>0)}
|
59
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
60
|
-
body.wont_include "table td.code"
|
61
|
-
body.must_include "function toggle()"
|
62
|
-
body.must_include "\"/foo.css\""
|
63
|
-
|
64
|
-
ep_app{|e| exception_page(e, :js_file=>"/foo.js", :context=>0)}
|
65
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
66
|
-
body.must_include "table td.code"
|
67
|
-
body.wont_include "function toggle()"
|
68
|
-
body.must_include "\"/foo.js\""
|
69
|
-
|
70
|
-
ep_app{|e| exception_page(e, :assets=>false, :context=>0)}
|
71
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
72
|
-
body.wont_include "table td.code"
|
73
|
-
body.wont_include "function toggle()"
|
74
|
-
body.wont_include "\"/exception_page.css\""
|
75
|
-
body.wont_include "\"/exception_page.js\""
|
76
|
-
|
77
|
-
ep_app{|e| exception_page(e, :assets=>false, :css_file=>"/foo.css", :context=>0)}
|
78
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
79
|
-
body.wont_include "table td.code"
|
80
|
-
body.wont_include "function toggle()"
|
81
|
-
body.must_include "\"/foo.css\""
|
82
|
-
|
83
|
-
ep_app{|e| exception_page(e, :assets=>false, :js_file=>"/foo.js", :context=>0)}
|
84
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
85
|
-
body.wont_include "table td.code"
|
86
|
-
body.wont_include "function toggle()"
|
87
|
-
body.must_include "\"/foo.js\""
|
88
|
-
|
89
|
-
ep_app{|e| exception_page(e, :css_file=>false, :context=>0)}
|
90
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
91
|
-
body.wont_include "table td.code"
|
92
|
-
body.must_include "function toggle()"
|
93
|
-
body.wont_include "\"/exception_page.css\""
|
94
|
-
body.wont_include "\"/exception_page.js\""
|
95
|
-
|
96
|
-
ep_app{|e| exception_page(e, :js_file=>false, :context=>0)}
|
97
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
98
|
-
body.must_include "table td.code"
|
99
|
-
body.wont_include "function toggle()"
|
100
|
-
body.wont_include "\"/exception_page.css\""
|
101
|
-
body.wont_include "\"/exception_page.js\""
|
102
|
-
end
|
103
|
-
|
104
|
-
it "returns plain text page with exception information if text/html is not accepted" do
|
105
|
-
ep_app
|
106
|
-
s, h, body = req
|
107
|
-
|
108
|
-
s.must_equal 200
|
109
|
-
h['Content-Type'].must_equal 'text/plain'
|
110
|
-
body = body.join
|
111
|
-
first, *bt = body.split("\n")
|
112
|
-
first.must_equal "RuntimeError: foo"
|
113
|
-
bt.first.must_include __FILE__
|
114
|
-
end
|
115
|
-
|
116
|
-
it "returns JSON with exception information if :json information is used" do
|
117
|
-
ep_app{|e| exception_page(e, :json=>true)}
|
118
|
-
@app.plugin :json
|
119
|
-
s, h, body = req
|
120
|
-
|
121
|
-
s.must_equal 200
|
122
|
-
h['Content-Type'].must_equal 'application/json'
|
123
|
-
hash = JSON.parse(body.join)
|
124
|
-
bt = hash["exception"].delete("backtrace")
|
125
|
-
hash.must_equal("exception"=>{"class"=>"RuntimeError", "message"=>"foo"})
|
126
|
-
bt.must_be_kind_of Array
|
127
|
-
bt.each{|line| line.must_be_kind_of String}
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should handle backtrace lines in unexpected forms" do
|
131
|
-
ep_app do |e|
|
132
|
-
e.backtrace.first.upcase!
|
133
|
-
e.backtrace[-1] = ''
|
134
|
-
exception_page(e)
|
135
|
-
end
|
136
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
137
|
-
body.must_include "RuntimeError: foo"
|
138
|
-
body.must_include __FILE__
|
139
|
-
body.wont_include 'id="c0"'
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should still show line numbers if the line content cannot be displayed" do
|
143
|
-
app(:exception_page) do |r|
|
144
|
-
instance_eval('raise "foo"', 'foo-bar.rb', 4200+42) rescue exception_page($!)
|
145
|
-
end
|
146
|
-
body = body('HTTP_ACCEPT'=>'text/html')
|
147
|
-
body.must_include "RuntimeError: foo"
|
148
|
-
body.must_include "foo-bar.rb:#{4200+42}"
|
149
|
-
body.must_include __FILE__
|
150
|
-
body.wont_include 'id="c0"'
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should serve exception page assets" do
|
154
|
-
app(:exception_page) do |r|
|
155
|
-
r.exception_page_assets
|
156
|
-
end
|
157
|
-
|
158
|
-
s, h, b = req('/exception_page.css')
|
159
|
-
s.must_equal 200
|
160
|
-
h['Content-Type'].must_equal 'text/css'
|
161
|
-
b.join.must_equal Roda::RodaPlugins::ExceptionPage.css
|
162
|
-
|
163
|
-
s, h, b = req('/exception_page.js')
|
164
|
-
s.must_equal 200
|
165
|
-
h['Content-Type'].must_equal 'application/javascript'
|
166
|
-
b.join.must_equal Roda::RodaPlugins::ExceptionPage.js
|
167
|
-
end
|
168
|
-
end
|