roda 3.28.0 → 3.29.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,82 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "default_headers plugin" do
|
4
|
-
it "sets the default headers to use for the response" do
|
5
|
-
h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}
|
6
|
-
|
7
|
-
app(:bare) do
|
8
|
-
plugin :default_headers, h
|
9
|
-
route do |r|
|
10
|
-
r.halt response.finish_with_body([])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
req[1].must_equal h
|
15
|
-
req[1].wont_be_same_as h
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should not override existing default headers" do
|
19
|
-
h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}
|
20
|
-
|
21
|
-
app(:bare) do
|
22
|
-
plugin :default_headers, h
|
23
|
-
plugin :default_headers
|
24
|
-
|
25
|
-
route do |r|
|
26
|
-
r.halt response.finish_with_body([])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
req[1].must_equal h
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should allow modifying the default headers by reloading the plugin" do
|
34
|
-
app(:bare) do
|
35
|
-
plugin :default_headers, 'Content-Type' => 'text/json'
|
36
|
-
plugin :default_headers, 'Foo' => 'baz'
|
37
|
-
|
38
|
-
route do |r|
|
39
|
-
r.halt response.finish_with_body([])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
req[1].must_equal('Content-Type'=>'text/json', 'Foo'=>'baz')
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should have a default Content-Type header" do
|
47
|
-
h = {'Foo'=>'bar'}
|
48
|
-
|
49
|
-
app(:bare) do
|
50
|
-
plugin :default_headers, h
|
51
|
-
|
52
|
-
route do |r|
|
53
|
-
r.halt response.finish_with_body([])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
req[1].must_equal('Content-Type'=>'text/html', 'Foo'=>'bar')
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should work correctly in subclasses" do
|
61
|
-
h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}
|
62
|
-
|
63
|
-
app(:bare) do
|
64
|
-
plugin :default_headers, h
|
65
|
-
|
66
|
-
route do |r|
|
67
|
-
r.halt response.finish_with_body([])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
@app = Class.new(@app)
|
72
|
-
|
73
|
-
req[1].must_equal h
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should offer default_headers method on class and response instance" do
|
77
|
-
h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}
|
78
|
-
app.plugin :default_headers, h
|
79
|
-
app.default_headers.must_equal h
|
80
|
-
app::RodaResponse.new.default_headers.must_equal h
|
81
|
-
end
|
82
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "default_status plugin" do
|
4
|
-
it "sets the default response status to use for the response" do
|
5
|
-
app(:bare) do
|
6
|
-
plugin :default_status do
|
7
|
-
201
|
8
|
-
end
|
9
|
-
route do |r|
|
10
|
-
r.halt response.finish_with_body([])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
status.must_equal 201
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should exec the plugin block in the context of the instance" do
|
18
|
-
app(:bare) do
|
19
|
-
plugin :default_status do
|
20
|
-
200 + @body[0].length
|
21
|
-
end
|
22
|
-
route do |r|
|
23
|
-
r.path_info
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
status.must_equal 201
|
28
|
-
status('/foo').must_equal 204
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should not override existing response" do
|
32
|
-
app(:bare) do
|
33
|
-
plugin :default_status do
|
34
|
-
201
|
35
|
-
end
|
36
|
-
|
37
|
-
route do |r|
|
38
|
-
response.status = 202
|
39
|
-
r.halt response.finish_with_body([])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
status.must_equal 202
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should work correctly in subclasses" do
|
47
|
-
app(:bare) do
|
48
|
-
plugin :default_status do
|
49
|
-
201
|
50
|
-
end
|
51
|
-
|
52
|
-
route do |r|
|
53
|
-
r.halt response.finish_with_body([])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
@app = Class.new(@app)
|
58
|
-
|
59
|
-
status.must_equal 201
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should raise if not given a block" do
|
63
|
-
proc{app(:default_status)}.must_raise Roda::RodaError
|
64
|
-
end
|
65
|
-
|
66
|
-
[true, false].each do |warn_arity|
|
67
|
-
send(warn_arity ? :deprecated : :it, "works with blocks with invalid arity") do
|
68
|
-
app(:bare) do
|
69
|
-
opts[:check_arity] = :warn if warn_arity
|
70
|
-
plugin :default_status do |r|
|
71
|
-
201
|
72
|
-
end
|
73
|
-
route do |r|
|
74
|
-
r.halt response.finish_with_body([])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
status.must_equal 201
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "does not work with blocks with invalid arity if :check_arity app option is false" do
|
83
|
-
app(:bare) do
|
84
|
-
opts[:check_arity] = false
|
85
|
-
plugin :default_status do |r|
|
86
|
-
201
|
87
|
-
end
|
88
|
-
route do |r|
|
89
|
-
r.halt response.finish_with_body([])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
proc{status}.must_raise ArgumentError
|
94
|
-
end
|
95
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "delay_build plugin" do
|
4
|
-
it "does not build rack app until app is called" do
|
5
|
-
app(:delay_build){"a"}
|
6
|
-
app.instance_variable_get(:@app).must_be_nil
|
7
|
-
body.must_equal "a"
|
8
|
-
# Work around minitest bug
|
9
|
-
refute_equal app.instance_variable_get(:@app), nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it "supports the build! method for backwards compatibility" do
|
13
|
-
app(:delay_build){"a"}
|
14
|
-
body.must_equal "a"
|
15
|
-
c = Class.new do
|
16
|
-
def initialize(_) end
|
17
|
-
def call(_) [200, {}, ["b"]] end
|
18
|
-
end
|
19
|
-
app.use c
|
20
|
-
app.build!
|
21
|
-
body.must_equal "b"
|
22
|
-
end
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "delegate plugin" do
|
4
|
-
it "adds request_delegate and response_delegate class methods for delegating" do
|
5
|
-
app(:bare) do
|
6
|
-
plugin :delegate
|
7
|
-
request_delegate :root
|
8
|
-
response_delegate :headers
|
9
|
-
|
10
|
-
def self.a; 'foo'; end
|
11
|
-
class_delegate :a
|
12
|
-
|
13
|
-
route do
|
14
|
-
root do
|
15
|
-
headers['Content-Type'] = a
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
header('Content-Type').must_equal 'foo'
|
21
|
-
status('/foo').must_equal 404
|
22
|
-
end
|
23
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "delete_empty_headers plugin" do
|
4
|
-
it "automatically deletes headers that are empty" do
|
5
|
-
app(:delete_empty_headers) do |r|
|
6
|
-
response['Foo'] = ''
|
7
|
-
response['Content-Type'] = ''
|
8
|
-
response['Content-Length'] = ''
|
9
|
-
response['Bar'] = '1'
|
10
|
-
'a'
|
11
|
-
end
|
12
|
-
|
13
|
-
req[1].must_equal('Bar'=>'1')
|
14
|
-
end
|
15
|
-
|
16
|
-
it "is called when finishing with a body" do
|
17
|
-
app(:delete_empty_headers) do |r|
|
18
|
-
response['Foo'] = ''
|
19
|
-
response['Content-Type'] = ''
|
20
|
-
response['Content-Length'] = ''
|
21
|
-
response['Bar'] = '1'
|
22
|
-
r.halt response.finish_with_body(['a'])
|
23
|
-
end
|
24
|
-
|
25
|
-
req[1].must_equal('Bar'=>'1')
|
26
|
-
end
|
27
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "direct_call plugin" do
|
4
|
-
it "should have .call skip middleware" do
|
5
|
-
app{'123'}
|
6
|
-
app.use(Class.new do
|
7
|
-
def initialize(_) end
|
8
|
-
def call(env) [200, {}, ['321']] end
|
9
|
-
end)
|
10
|
-
body.must_equal '321'
|
11
|
-
app.plugin :direct_call
|
12
|
-
body.must_equal '123'
|
13
|
-
end
|
14
|
-
|
15
|
-
deprecated "should work when #call is overridden" do
|
16
|
-
app.class_eval do
|
17
|
-
def call; super end
|
18
|
-
route{'123'}
|
19
|
-
end
|
20
|
-
app.use(Class.new do
|
21
|
-
def initialize(_) end
|
22
|
-
def call(env) [200, {}, ['321']] end
|
23
|
-
end)
|
24
|
-
body.must_equal '321'
|
25
|
-
app.plugin :direct_call
|
26
|
-
body.must_equal '123'
|
27
|
-
end
|
28
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
if Rack.release < '1.6'
|
4
|
-
warn "Rack #{Rack.release} used, skipping disallow_file_uploads plugin test"
|
5
|
-
else
|
6
|
-
describe "disallow_file_uploads plugin" do
|
7
|
-
it "disallows the uploading of files" do
|
8
|
-
app do |r|
|
9
|
-
r.params['foo'][:tempfile].read
|
10
|
-
end
|
11
|
-
|
12
|
-
request_body = StringIO.new("------WebKitFormBoundarymwHIM9XjTTVHn3YP\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"bar.txt\"\r\nContent-Type: text/plain\r\n\r\nfoo\n\r\n------WebKitFormBoundarymwHIM9XjTTVHn3YP--\r\n")
|
13
|
-
|
14
|
-
h = {
|
15
|
-
'rack.input'=>request_body,
|
16
|
-
'CONTENT_TYPE'=>'multipart/form-data; boundary=----WebKitFormBoundarymwHIM9XjTTVHn3YP',
|
17
|
-
'CONTENT_LENGTH'=>'184',
|
18
|
-
'REQUEST_METHOD'=>'POST'
|
19
|
-
}
|
20
|
-
body(h.dup).must_equal "foo\n"
|
21
|
-
app.plugin :disallow_file_uploads
|
22
|
-
proc{body(h.dup)}.must_raise Roda::RodaPlugins::DisallowFileUploads::Error
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "drop_body plugin" do
|
4
|
-
it "automatically drops body and Content-Type/Content-Length headers for responses without a body" do
|
5
|
-
app(:drop_body) do |r|
|
6
|
-
response.status = r.path.to_i
|
7
|
-
response.write('a')
|
8
|
-
end
|
9
|
-
|
10
|
-
[101, 102, 204, 304].each do |i|
|
11
|
-
body(i.to_s).must_equal ''
|
12
|
-
header('Content-Type', i.to_s).must_be_nil
|
13
|
-
header('Content-Length', i.to_s).must_be_nil
|
14
|
-
end
|
15
|
-
|
16
|
-
body('205').must_equal ''
|
17
|
-
header('Content-Type', '205').must_be_nil
|
18
|
-
header('Content-Length', '205').must_equal '0'
|
19
|
-
|
20
|
-
body('200').must_equal 'a'
|
21
|
-
header('Content-Type', '200').must_equal 'text/html'
|
22
|
-
header('Content-Length', '200').must_equal '1'
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "early_hints plugin" do
|
4
|
-
it "allows sending early hints to rack.early_hints" do
|
5
|
-
queue = []
|
6
|
-
app(:early_hints) do |r|
|
7
|
-
send_early_hints('Link'=>'</foo.js>; rel=preload; as=script')
|
8
|
-
queue << 'OK'
|
9
|
-
'OK'
|
10
|
-
end
|
11
|
-
|
12
|
-
body.must_equal 'OK'
|
13
|
-
queue.must_equal ['OK']
|
14
|
-
|
15
|
-
queue = []
|
16
|
-
body('rack.early_hints'=>proc{|h| queue << h}).must_equal 'OK'
|
17
|
-
queue.must_equal [{'Link'=>'</foo.js>; rel=preload; as=script'}, 'OK']
|
18
|
-
end
|
19
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "empty_root plugin" do
|
4
|
-
it "makes root match on emtpy path" do
|
5
|
-
app(:empty_root) do |r|
|
6
|
-
r.root{"root"}
|
7
|
-
"notroot"
|
8
|
-
end
|
9
|
-
|
10
|
-
body.must_equal 'root'
|
11
|
-
body("").must_equal 'root'
|
12
|
-
body("a").must_equal 'notroot'
|
13
|
-
end
|
14
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "environments plugin" do
|
4
|
-
before do
|
5
|
-
app
|
6
|
-
app.plugin :environments, :development
|
7
|
-
end
|
8
|
-
|
9
|
-
it "adds environment accessor for getting/setting the environment" do
|
10
|
-
app.environment.must_equal :development
|
11
|
-
app.environment = :test
|
12
|
-
app.environment.must_equal :test
|
13
|
-
|
14
|
-
app.plugin :environments, :production
|
15
|
-
app.environment.must_equal :production
|
16
|
-
end
|
17
|
-
|
18
|
-
it "adds predicates for testing the environment" do
|
19
|
-
app.development?.must_equal true
|
20
|
-
app.test?.must_equal false
|
21
|
-
app.production?.must_equal false
|
22
|
-
end
|
23
|
-
|
24
|
-
it "adds configure method which yields if no arguments are given or an environment matches" do
|
25
|
-
a = []
|
26
|
-
app.configure{a << 1}
|
27
|
-
app.configure(:development){|ap| a << ap}
|
28
|
-
app.configure(:test, :production){a << 2}
|
29
|
-
a.must_equal [1, app]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "defaults environment to RACK_ENV" do
|
33
|
-
with_rack_env('test') do
|
34
|
-
app(:environments){}
|
35
|
-
end
|
36
|
-
app.test?.must_equal true
|
37
|
-
app.development?.must_equal false
|
38
|
-
app(:environments){}
|
39
|
-
app.test?.must_equal false
|
40
|
-
app.development?.must_equal true
|
41
|
-
end
|
42
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "error_email plugin" do
|
4
|
-
def app(opts={})
|
5
|
-
@emails = emails = [] unless defined?(@emails)
|
6
|
-
@app ||= super(:bare) do
|
7
|
-
plugin :error_email, {:to=>'t', :from=>'f', :emailer=>lambda{|h| emails << h}}.merge(opts)
|
8
|
-
|
9
|
-
route do |r|
|
10
|
-
r.get('noerror'){error_email("Problem"); 'g'}
|
11
|
-
raise ArgumentError, 'bad foo' rescue error_email($!)
|
12
|
-
'e'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def email
|
18
|
-
@emails.last
|
19
|
-
end
|
20
|
-
|
21
|
-
it "adds error_email method for emailing exceptions" do
|
22
|
-
app
|
23
|
-
body('rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'}).must_equal 'e'
|
24
|
-
email[:to].must_equal 't'
|
25
|
-
email[:from].must_equal 'f'
|
26
|
-
email[:host].must_equal 'localhost'
|
27
|
-
email[:message].must_match(/^Subject: ArgumentError: bad foo/)
|
28
|
-
email[:message].must_match(/^Backtrace:$.+^ENV:$.+^"rack\.input" => .+^Params:$\s+^"b" => "c"$\s+^Session:$\s+^"d" => "e"$/m)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "have error_email method support string arguments" do
|
32
|
-
app
|
33
|
-
body('/noerror', 'rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'}).must_equal 'g'
|
34
|
-
email[:to].must_equal 't'
|
35
|
-
email[:from].must_equal 'f'
|
36
|
-
email[:host].must_equal 'localhost'
|
37
|
-
email[:message].must_match(/^Subject: Problem/)
|
38
|
-
email[:message].must_match(/^ENV:$.+^"rack\.input" => .+^Params:$\s+^"b" => "c"$\s+^Session:$\s+^"d" => "e"$/m)
|
39
|
-
email[:message].wont_include('Backtrace')
|
40
|
-
end
|
41
|
-
|
42
|
-
it "supports error_email_content for the content of the email" do
|
43
|
-
app.route do |r|
|
44
|
-
raise ArgumentError, 'bad foo' rescue error_email_content($!)
|
45
|
-
end
|
46
|
-
b = body('rack.input'=>StringIO.new, 'QUERY_STRING'=>'b=c', 'rack.session'=>{'d'=>'e'})
|
47
|
-
b.must_match(/^Subject: ArgumentError: bad foo/)
|
48
|
-
b.must_match(/^Backtrace:$.+^ENV:$.+^"rack\.input" => .+^Params:$\s+^"b" => "c"$\s+^Session:$\s+^"d" => "e"$/m)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "uses :host option" do
|
52
|
-
app(:host=>'foo.bar.com')
|
53
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
54
|
-
email[:host].must_equal 'foo.bar.com'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "handles error messages with new lines" do
|
58
|
-
app.route do |r|
|
59
|
-
raise "foo\nbar\nbaz" rescue error_email($!)
|
60
|
-
'e'
|
61
|
-
end
|
62
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
63
|
-
email[:message].must_match %r{From: f\r\nSubject: RuntimeError: foo\r\n bar\r\n baz\r\nTo: t\r\n\r\n}
|
64
|
-
end
|
65
|
-
|
66
|
-
it "adds :prefix option to subject line" do
|
67
|
-
app(:prefix=>'TEST ')
|
68
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
69
|
-
email[:message].must_match(/^Subject: TEST ArgumentError/)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "uses :headers option for additional headers" do
|
73
|
-
app(:headers=>{'Foo'=>'Bar', 'Baz'=>'Quux'})
|
74
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
75
|
-
email[:message].must_match(/^Foo: Bar/)
|
76
|
-
email[:message].must_match(/^Baz: Quux/)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "requires the :to and :from options" do
|
80
|
-
proc{app :from=>nil}.must_raise(Roda::RodaError)
|
81
|
-
proc{app :to=>nil}.must_raise(Roda::RodaError)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "works correctly in subclasses" do
|
85
|
-
@app = Class.new(app)
|
86
|
-
@app.route do |r|
|
87
|
-
raise ArgumentError rescue error_email($!)
|
88
|
-
'e'
|
89
|
-
end
|
90
|
-
body('rack.input'=>StringIO.new).must_equal 'e'
|
91
|
-
email[:to].must_equal 't'
|
92
|
-
email[:from].must_equal 'f'
|
93
|
-
email[:host].must_equal 'localhost'
|
94
|
-
email[:message].must_match(/^Subject: ArgumentError/)
|
95
|
-
email[:message].must_match(/Backtrace.*ENV/m)
|
96
|
-
end
|
97
|
-
end
|