roda 3.28.0 → 3.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +10 -0
  3. data/README.rdoc +10 -0
  4. data/doc/release_notes/3.29.0.txt +15 -0
  5. data/lib/roda.rb +1 -0
  6. data/lib/roda/plugins/caching.rb +2 -0
  7. data/lib/roda/plugins/common_logger.rb +1 -1
  8. data/lib/roda/plugins/exception_page.rb +7 -1
  9. data/lib/roda/plugins/indifferent_params.rb +2 -0
  10. data/lib/roda/version.rb +1 -1
  11. metadata +4 -214
  12. data/Rakefile +0 -108
  13. data/doc/release_notes/1.0.0.txt +0 -329
  14. data/doc/release_notes/1.1.0.txt +0 -226
  15. data/doc/release_notes/1.2.0.txt +0 -406
  16. data/doc/release_notes/1.3.0.txt +0 -109
  17. data/doc/release_notes/2.0.0.txt +0 -75
  18. data/doc/release_notes/2.1.0.txt +0 -124
  19. data/doc/release_notes/2.10.0.txt +0 -27
  20. data/doc/release_notes/2.11.0.txt +0 -70
  21. data/doc/release_notes/2.12.0.txt +0 -40
  22. data/doc/release_notes/2.13.0.txt +0 -10
  23. data/doc/release_notes/2.14.0.txt +0 -44
  24. data/doc/release_notes/2.15.0.txt +0 -53
  25. data/doc/release_notes/2.16.0.txt +0 -48
  26. data/doc/release_notes/2.17.0.txt +0 -62
  27. data/doc/release_notes/2.18.0.txt +0 -69
  28. data/doc/release_notes/2.19.0.txt +0 -30
  29. data/doc/release_notes/2.2.0.txt +0 -97
  30. data/doc/release_notes/2.20.0.txt +0 -5
  31. data/doc/release_notes/2.21.0.txt +0 -17
  32. data/doc/release_notes/2.22.0.txt +0 -41
  33. data/doc/release_notes/2.23.0.txt +0 -29
  34. data/doc/release_notes/2.24.0.txt +0 -65
  35. data/doc/release_notes/2.25.0.txt +0 -14
  36. data/doc/release_notes/2.26.0.txt +0 -13
  37. data/doc/release_notes/2.27.0.txt +0 -56
  38. data/doc/release_notes/2.28.0.txt +0 -17
  39. data/doc/release_notes/2.29.0.txt +0 -156
  40. data/doc/release_notes/2.3.0.txt +0 -109
  41. data/doc/release_notes/2.4.0.txt +0 -55
  42. data/doc/release_notes/2.5.0.txt +0 -23
  43. data/doc/release_notes/2.5.1.txt +0 -4
  44. data/doc/release_notes/2.6.0.txt +0 -21
  45. data/doc/release_notes/2.7.0.txt +0 -75
  46. data/doc/release_notes/2.8.0.txt +0 -44
  47. data/doc/release_notes/2.9.0.txt +0 -6
  48. data/spec/all.rb +0 -1
  49. data/spec/assets/css/app.scss +0 -1
  50. data/spec/assets/css/no_access.css +0 -1
  51. data/spec/assets/css/raw.css +0 -1
  52. data/spec/assets/js/head/app.js +0 -1
  53. data/spec/composition_spec.rb +0 -31
  54. data/spec/define_roda_method_spec.rb +0 -274
  55. data/spec/env_spec.rb +0 -11
  56. data/spec/freeze_spec.rb +0 -37
  57. data/spec/integration_spec.rb +0 -209
  58. data/spec/matchers_spec.rb +0 -832
  59. data/spec/opts_spec.rb +0 -42
  60. data/spec/plugin/_after_hook_spec.rb +0 -19
  61. data/spec/plugin/all_verbs_spec.rb +0 -29
  62. data/spec/plugin/assets_preloading_spec.rb +0 -98
  63. data/spec/plugin/assets_spec.rb +0 -745
  64. data/spec/plugin/backtracking_array_spec.rb +0 -42
  65. data/spec/plugin/branch_locals_spec.rb +0 -106
  66. data/spec/plugin/caching_spec.rb +0 -337
  67. data/spec/plugin/chunked_spec.rb +0 -201
  68. data/spec/plugin/class_level_routing_spec.rb +0 -164
  69. data/spec/plugin/class_matchers_spec.rb +0 -40
  70. data/spec/plugin/common_logger_spec.rb +0 -85
  71. data/spec/plugin/content_for_spec.rb +0 -162
  72. data/spec/plugin/content_security_policy_spec.rb +0 -175
  73. data/spec/plugin/cookies_spec.rb +0 -51
  74. data/spec/plugin/csrf_spec.rb +0 -111
  75. data/spec/plugin/default_headers_spec.rb +0 -82
  76. data/spec/plugin/default_status_spec.rb +0 -95
  77. data/spec/plugin/delay_build_spec.rb +0 -23
  78. data/spec/plugin/delegate_spec.rb +0 -23
  79. data/spec/plugin/delete_empty_headers_spec.rb +0 -27
  80. data/spec/plugin/direct_call_spec.rb +0 -28
  81. data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
  82. data/spec/plugin/drop_body_spec.rb +0 -24
  83. data/spec/plugin/early_hints_spec.rb +0 -19
  84. data/spec/plugin/empty_root_spec.rb +0 -14
  85. data/spec/plugin/environments_spec.rb +0 -42
  86. data/spec/plugin/error_email_spec.rb +0 -97
  87. data/spec/plugin/error_handler_spec.rb +0 -216
  88. data/spec/plugin/error_mail_spec.rb +0 -93
  89. data/spec/plugin/exception_page_spec.rb +0 -168
  90. data/spec/plugin/flash_spec.rb +0 -121
  91. data/spec/plugin/h_spec.rb +0 -11
  92. data/spec/plugin/halt_spec.rb +0 -119
  93. data/spec/plugin/hash_matcher_spec.rb +0 -27
  94. data/spec/plugin/hash_routes_spec.rb +0 -535
  95. data/spec/plugin/head_spec.rb +0 -52
  96. data/spec/plugin/header_matchers_spec.rb +0 -98
  97. data/spec/plugin/heartbeat_spec.rb +0 -74
  98. data/spec/plugin/hooks_spec.rb +0 -152
  99. data/spec/plugin/indifferent_params_spec.rb +0 -14
  100. data/spec/plugin/json_parser_spec.rb +0 -141
  101. data/spec/plugin/json_spec.rb +0 -83
  102. data/spec/plugin/mail_processor_spec.rb +0 -451
  103. data/spec/plugin/mailer_spec.rb +0 -282
  104. data/spec/plugin/match_affix_spec.rb +0 -43
  105. data/spec/plugin/match_hook_spec.rb +0 -79
  106. data/spec/plugin/middleware_spec.rb +0 -237
  107. data/spec/plugin/middleware_stack_spec.rb +0 -81
  108. data/spec/plugin/module_include_spec.rb +0 -48
  109. data/spec/plugin/multi_route_spec.rb +0 -268
  110. data/spec/plugin/multi_run_spec.rb +0 -87
  111. data/spec/plugin/multi_view_spec.rb +0 -50
  112. data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
  113. data/spec/plugin/named_templates_spec.rb +0 -96
  114. data/spec/plugin/not_allowed_spec.rb +0 -69
  115. data/spec/plugin/not_found_spec.rb +0 -128
  116. data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
  117. data/spec/plugin/padrino_render_spec.rb +0 -34
  118. data/spec/plugin/param_matchers_spec.rb +0 -69
  119. data/spec/plugin/params_capturing_spec.rb +0 -33
  120. data/spec/plugin/partials_spec.rb +0 -43
  121. data/spec/plugin/pass_spec.rb +0 -29
  122. data/spec/plugin/path_matchers_spec.rb +0 -42
  123. data/spec/plugin/path_rewriter_spec.rb +0 -45
  124. data/spec/plugin/path_spec.rb +0 -222
  125. data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
  126. data/spec/plugin/precompile_templates_spec.rb +0 -61
  127. data/spec/plugin/public_spec.rb +0 -85
  128. data/spec/plugin/render_each_spec.rb +0 -82
  129. data/spec/plugin/render_locals_spec.rb +0 -114
  130. data/spec/plugin/render_spec.rb +0 -912
  131. data/spec/plugin/request_aref_spec.rb +0 -51
  132. data/spec/plugin/request_headers_spec.rb +0 -39
  133. data/spec/plugin/response_request_spec.rb +0 -43
  134. data/spec/plugin/route_block_args_spec.rb +0 -86
  135. data/spec/plugin/route_csrf_spec.rb +0 -305
  136. data/spec/plugin/run_append_slash_spec.rb +0 -77
  137. data/spec/plugin/run_handler_spec.rb +0 -53
  138. data/spec/plugin/sessions_spec.rb +0 -452
  139. data/spec/plugin/shared_vars_spec.rb +0 -45
  140. data/spec/plugin/sinatra_helpers_spec.rb +0 -537
  141. data/spec/plugin/slash_path_empty_spec.rb +0 -22
  142. data/spec/plugin/static_routing_spec.rb +0 -192
  143. data/spec/plugin/static_spec.rb +0 -30
  144. data/spec/plugin/status_303_spec.rb +0 -28
  145. data/spec/plugin/status_handler_spec.rb +0 -158
  146. data/spec/plugin/streaming_spec.rb +0 -246
  147. data/spec/plugin/strip_path_prefix_spec.rb +0 -24
  148. data/spec/plugin/symbol_matchers_spec.rb +0 -51
  149. data/spec/plugin/symbol_status_spec.rb +0 -25
  150. data/spec/plugin/symbol_views_spec.rb +0 -32
  151. data/spec/plugin/timestamp_public_spec.rb +0 -85
  152. data/spec/plugin/type_routing_spec.rb +0 -348
  153. data/spec/plugin/typecast_params_spec.rb +0 -1370
  154. data/spec/plugin/unescape_path_spec.rb +0 -22
  155. data/spec/plugin/view_options_spec.rb +0 -170
  156. data/spec/plugin_spec.rb +0 -71
  157. data/spec/redirect_spec.rb +0 -41
  158. data/spec/request_spec.rb +0 -97
  159. data/spec/response_spec.rb +0 -199
  160. data/spec/route_spec.rb +0 -39
  161. data/spec/session_middleware_spec.rb +0 -129
  162. data/spec/session_spec.rb +0 -37
  163. data/spec/spec_helper.rb +0 -137
  164. data/spec/version_spec.rb +0 -14
  165. data/spec/views/_test.erb +0 -1
  166. data/spec/views/a.erb +0 -1
  167. data/spec/views/a.rdoc +0 -2
  168. data/spec/views/about.erb +0 -1
  169. data/spec/views/about.str +0 -1
  170. data/spec/views/about/_test.css.gz +0 -0
  171. data/spec/views/about/_test.erb +0 -1
  172. data/spec/views/about/_test.erb.gz +0 -0
  173. data/spec/views/about/comp_test.erb +0 -1
  174. data/spec/views/b.erb +0 -1
  175. data/spec/views/c.erb +0 -1
  176. data/spec/views/comp_layout.erb +0 -1
  177. data/spec/views/comp_test.erb +0 -1
  178. data/spec/views/content-yield.erb +0 -1
  179. data/spec/views/each.str +0 -1
  180. data/spec/views/home.erb +0 -2
  181. data/spec/views/home.str +0 -2
  182. data/spec/views/iv.erb +0 -1
  183. data/spec/views/layout-alternative.erb +0 -2
  184. data/spec/views/layout-yield.erb +0 -3
  185. data/spec/views/layout.erb +0 -2
  186. data/spec/views/layout.str +0 -2
  187. data/spec/views/multiple-layout.erb +0 -1
  188. 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