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,22 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
describe "unescape_path_path plugin" do
|
4
|
-
it "decodes URL-encoded routing path" do
|
5
|
-
app(:unescape_path) do |r|
|
6
|
-
r.on 'b' do
|
7
|
-
r.get(/(.)/) do |a|
|
8
|
-
"#{a}-b"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
r.get :name do |name|
|
13
|
-
name
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
body('/a').must_equal 'a'
|
18
|
-
body('/%61').must_equal 'a'
|
19
|
-
body('%2f%61').must_equal 'a'
|
20
|
-
body('%2f%62%2f%61').must_equal 'a-b'
|
21
|
-
end
|
22
|
-
end
|
@@ -1,170 +0,0 @@
|
|
1
|
-
require_relative "../spec_helper"
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'tilt/erb'
|
5
|
-
rescue LoadError
|
6
|
-
warn "tilt not installed, skipping view_options plugin test"
|
7
|
-
else
|
8
|
-
describe "view_options plugin view subdirs" do
|
9
|
-
before do
|
10
|
-
app(:bare) do
|
11
|
-
plugin :render, :views=>"."
|
12
|
-
plugin :view_options
|
13
|
-
|
14
|
-
route do |r|
|
15
|
-
append_view_subdir 'spec'
|
16
|
-
|
17
|
-
r.on "home" do
|
18
|
-
set_view_subdir 'spec/views'
|
19
|
-
view("home", :locals=>{:name => "Agent Smith", :title => "Home"}, :layout_opts=>{:locals=>{:title=>"Home"}})
|
20
|
-
end
|
21
|
-
|
22
|
-
r.on "about" do
|
23
|
-
append_view_subdir 'views'
|
24
|
-
r.on 'test' do
|
25
|
-
append_view_subdir 'about'
|
26
|
-
r.is('view'){view("comp_test")}
|
27
|
-
r.is{render("comp_test")}
|
28
|
-
end
|
29
|
-
render("about", :locals=>{:title => "About Roda"})
|
30
|
-
end
|
31
|
-
|
32
|
-
r.on "path" do
|
33
|
-
render('spec/views/about', :locals=>{:title => "Path"}, :layout_opts=>{:locals=>{:title=>"Home"}})
|
34
|
-
end
|
35
|
-
|
36
|
-
r.on 'test' do
|
37
|
-
set_view_subdir 'spec/views'
|
38
|
-
r.is('view'){view("comp_test")}
|
39
|
-
r.is{render("comp_test")}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should use set subdir if template name does not contain a slash" do
|
46
|
-
body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should not use set subdir if template name contains a slash" do
|
50
|
-
body("/about").strip.must_equal "<h1>About Roda</h1>"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should not change behavior when subdir is not set" do
|
54
|
-
body("/path").strip.must_equal "<h1>Path</h1>"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should handle template compilation correctly" do
|
58
|
-
@app.plugin :render, :layout=>'./spec/views/comp_layout'
|
59
|
-
3.times do
|
60
|
-
body("/test").strip.must_equal "ct"
|
61
|
-
body("/about/test").strip.must_equal "about-ct"
|
62
|
-
body("/test/view").strip.must_equal "act\nb"
|
63
|
-
body("/about/test/view").strip.must_equal "aabout-ct\nb"
|
64
|
-
end
|
65
|
-
if Roda::RodaPlugins::Render::COMPILED_METHOD_SUPPORT
|
66
|
-
method_cache = @app.opts[:render][:template_method_cache]
|
67
|
-
method_cache[['spec/views', 'comp_test']].must_be_kind_of(Symbol)
|
68
|
-
method_cache[['spec/views/about', 'comp_test']].must_be_kind_of(Symbol)
|
69
|
-
method_cache[:_roda_layout].must_be_kind_of(Symbol)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "view_options plugin" do
|
75
|
-
it "should not use :views view option for layout" do
|
76
|
-
app(:bare) do
|
77
|
-
plugin :render, :views=>'spec/views', :allowed_paths=>['spec/views']
|
78
|
-
plugin :view_options
|
79
|
-
|
80
|
-
route do
|
81
|
-
set_view_options :views=>'spec/views/about'
|
82
|
-
set_layout_options :template=>'layout-alternative'
|
83
|
-
view('_test', :locals=>{:title=>'About Roda'}, :layout_opts=>{:locals=>{:title=>'Home'}})
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Subdir: About Roda</h1>"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should allow overriding :layout plugin option with set_layout_options :template" do
|
91
|
-
app(:bare) do
|
92
|
-
plugin :render, :views=>'spec/views', :allowed_paths=>['spec/views']
|
93
|
-
plugin :view_options
|
94
|
-
|
95
|
-
route do
|
96
|
-
set_view_options :views=>'spec/views/about'
|
97
|
-
set_layout_options :template=>'layout-alternative'
|
98
|
-
view('_test', :locals=>{:title=>'About Roda'}, :layout_opts=>{:locals=>{:title=>'Home'}})
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Subdir: About Roda</h1>"
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should allow overriding :layout_opts :template plugin option with set_layout_options :template" do
|
106
|
-
app(:bare) do
|
107
|
-
plugin :render, :views=>'spec/views', :allowed_paths=>['spec/views'], :layout_opts=>{:template=>'layout'}
|
108
|
-
plugin :view_options
|
109
|
-
|
110
|
-
route do
|
111
|
-
set_view_options :views=>'spec/views/about', :layout=>'layout-alternative'
|
112
|
-
set_layout_options :template=>'layout-alternative'
|
113
|
-
view('_test', :locals=>{:title=>'About Roda'}, :layout_opts=>{:locals=>{:title=>'Home'}})
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Subdir: About Roda</h1>"
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should allow overriding :layout plugin option with set_view_options :layout" do
|
121
|
-
app(:bare) do
|
122
|
-
plugin :render, :views=>'spec/views', :allowed_paths=>['spec/views'], :layout=>'layout'
|
123
|
-
plugin :view_options
|
124
|
-
|
125
|
-
route do
|
126
|
-
set_view_options :views=>'spec/views/about', :layout=>'layout-alternative'
|
127
|
-
view('_test', :locals=>{:title=>'About Roda'}, :layout_opts=>{:locals=>{:title=>'Home'}})
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Subdir: About Roda</h1>"
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should set view and layout options to use" do
|
135
|
-
app(:bare) do
|
136
|
-
plugin :render, :allowed_paths=>['spec/views']
|
137
|
-
plugin :view_options
|
138
|
-
plugin :render_locals, :render=>{:title=>'About Roda'}, :layout=>{:title=>'Home'}
|
139
|
-
|
140
|
-
route do
|
141
|
-
set_view_options :views=>'spec/views'
|
142
|
-
set_layout_options :views=>'spec/views', :template=>'layout-alternative'
|
143
|
-
view('about')
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>About Roda</h1>"
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should merge multiple calls to set view and layout options" do
|
151
|
-
app(:bare) do
|
152
|
-
plugin :render, :allowed_paths=>['spec/views']
|
153
|
-
plugin :view_options
|
154
|
-
plugin :render_locals, :render=>{:title=>'Home', :b=>'B'}, :layout=>{:title=>'About Roda', :a=>'A'}
|
155
|
-
|
156
|
-
route do
|
157
|
-
set_layout_options :views=>'spec/views', :template=>'multiple-layout', :engine=>'str'
|
158
|
-
set_view_options :views=>'spec/views', :engine=>'str'
|
159
|
-
|
160
|
-
set_layout_options :engine=>'erb'
|
161
|
-
set_view_options :engine=>'erb'
|
162
|
-
|
163
|
-
view('multiple')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
body.strip.must_equal "About Roda:A::Home:B"
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
data/spec/plugin_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "plugins" do
|
4
|
-
it "should be able to override class, instance, response, and request methods, and execute configure method" do
|
5
|
-
c = Module.new do
|
6
|
-
self::ClassMethods = Module.new do
|
7
|
-
def fix(str)
|
8
|
-
opts[:prefix] + str.strip
|
9
|
-
end
|
10
|
-
end
|
11
|
-
self::InstanceMethods = Module.new do
|
12
|
-
def fix(str)
|
13
|
-
super("a" + str)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
self::RequestMethods = Module.new do
|
17
|
-
def hello(&block)
|
18
|
-
on self.class.hello, &block
|
19
|
-
end
|
20
|
-
end
|
21
|
-
self::RequestClassMethods = Module.new do
|
22
|
-
def hello(&block)
|
23
|
-
'hello'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
self::ResponseMethods = Module.new do
|
27
|
-
def foobar
|
28
|
-
self.class.foobar
|
29
|
-
end
|
30
|
-
end
|
31
|
-
self::ResponseClassMethods = Module.new do
|
32
|
-
def foobar
|
33
|
-
"Default "
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.load_dependencies(mod, prefix)
|
38
|
-
mod.send(:include, Module.new do
|
39
|
-
def fix(str)
|
40
|
-
self.class.fix(str)
|
41
|
-
end
|
42
|
-
end)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.configure(mod, prefix)
|
46
|
-
mod.opts[:prefix] = prefix
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
app(:bare) do
|
51
|
-
plugin(c, "Foo ").must_be_nil
|
52
|
-
|
53
|
-
route do |r|
|
54
|
-
r.hello do
|
55
|
-
fix(response.foobar)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
body('/hello').must_equal 'Foo aDefault'
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should support registering plugins and loading them by symbol" do
|
64
|
-
Roda::RodaPlugins.register_plugin(:foo, Module.new{module self::InstanceMethods; def a; '1' end end})
|
65
|
-
app(:foo) do
|
66
|
-
a
|
67
|
-
end
|
68
|
-
|
69
|
-
body.must_equal '1'
|
70
|
-
end
|
71
|
-
end
|
data/spec/redirect_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "redirects" do
|
4
|
-
it "should be immediately processed" do
|
5
|
-
app do |r|
|
6
|
-
r.root do
|
7
|
-
r.redirect "/hello"
|
8
|
-
"Foo"
|
9
|
-
end
|
10
|
-
|
11
|
-
r.is "about" do
|
12
|
-
r.redirect "/hello", 301
|
13
|
-
"Foo"
|
14
|
-
end
|
15
|
-
|
16
|
-
r.is 'foo' do
|
17
|
-
r.get do
|
18
|
-
r.redirect
|
19
|
-
end
|
20
|
-
|
21
|
-
r.post do
|
22
|
-
r.redirect
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
status.must_equal 302
|
28
|
-
header('Location').must_equal '/hello'
|
29
|
-
body.must_equal ''
|
30
|
-
|
31
|
-
status("/about").must_equal 301
|
32
|
-
header('Location', "/about").must_equal '/hello'
|
33
|
-
body("/about").must_equal ''
|
34
|
-
|
35
|
-
status("/foo", 'REQUEST_METHOD'=>'POST').must_equal 302
|
36
|
-
header('Location', "/foo", 'REQUEST_METHOD'=>'POST').must_equal '/foo'
|
37
|
-
body("/foo", 'REQUEST_METHOD'=>'POST').must_equal ''
|
38
|
-
|
39
|
-
proc{req('/foo')}.must_raise(Roda::RodaError)
|
40
|
-
end
|
41
|
-
end
|
data/spec/request_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "request.path, .remaining_path, and .matched_path" do
|
4
|
-
it "should return the script name and path_info as a string" do
|
5
|
-
app do |r|
|
6
|
-
r.on "foo" do
|
7
|
-
"#{r.path}:#{r.matched_path}:#{r.remaining_path}"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
body("/foo/bar").must_equal "/foo/bar:/foo:/bar"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "request.real_remaining_path" do
|
16
|
-
it "should be an alias of remaining_path" do
|
17
|
-
app do |r|
|
18
|
-
r.on "foo" do
|
19
|
-
"#{r.remaining_path}:#{r.real_remaining_path}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
body("/foo/bar").must_equal "/bar:/bar"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "request.halt" do
|
28
|
-
it "should return rack response as argument given it as argument" do
|
29
|
-
app do |r|
|
30
|
-
r.halt [200, {}, ['foo']]
|
31
|
-
end
|
32
|
-
|
33
|
-
body.must_equal "foo"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should use current response if no argument is given" do
|
37
|
-
app do |r|
|
38
|
-
response.write('foo')
|
39
|
-
r.halt
|
40
|
-
end
|
41
|
-
|
42
|
-
body.must_equal "foo"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "request.scope" do
|
47
|
-
it "should return roda instance" do
|
48
|
-
app(:bare) do
|
49
|
-
attr_accessor :b
|
50
|
-
|
51
|
-
route do |r|
|
52
|
-
self.b = 'a'
|
53
|
-
request.scope.b
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
body.must_equal "a"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "request.inspect" do
|
62
|
-
it "should return information about request" do
|
63
|
-
app(:bare) do
|
64
|
-
def self.inspect
|
65
|
-
'Foo'
|
66
|
-
end
|
67
|
-
|
68
|
-
route do |r|
|
69
|
-
request.inspect
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
body('/a/b').must_equal "#<Foo::RodaRequest GET /a/b>"
|
74
|
-
body('REQUEST_METHOD'=>'POST').must_equal "#<Foo::RodaRequest POST />"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "TERM.inspect" do
|
79
|
-
it "should return TERM" do
|
80
|
-
app do |r|
|
81
|
-
r.class::TERM.inspect
|
82
|
-
end
|
83
|
-
|
84
|
-
body.must_equal "TERM"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "roda_class" do
|
89
|
-
it "should return the related roda subclass" do
|
90
|
-
app do |r|
|
91
|
-
self.class.opts[:a] = 'a'
|
92
|
-
r.class.roda_class.opts[:a] + r.roda_class.opts[:a]
|
93
|
-
end
|
94
|
-
|
95
|
-
body.must_equal "aa"
|
96
|
-
end
|
97
|
-
end
|
data/spec/response_spec.rb
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "response #[] and #[]=" do
|
4
|
-
it "should get/set headers" do
|
5
|
-
app do |r|
|
6
|
-
response['foo'] = 'bar'
|
7
|
-
response['foo'] + response.headers['foo']
|
8
|
-
end
|
9
|
-
|
10
|
-
header('foo').must_equal "bar"
|
11
|
-
body.must_equal 'barbar'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "response #headers and #body" do
|
16
|
-
it "should return headers and body" do
|
17
|
-
app do |r|
|
18
|
-
response.headers['foo'] = 'bar'
|
19
|
-
response.write response.body.is_a?(Array)
|
20
|
-
end
|
21
|
-
|
22
|
-
header('foo').must_equal "bar"
|
23
|
-
body.must_equal 'true'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "response #write" do
|
28
|
-
it "should add to body" do
|
29
|
-
app do |r|
|
30
|
-
response.write 'a'
|
31
|
-
response.write 'b'
|
32
|
-
end
|
33
|
-
|
34
|
-
body.must_equal 'ab'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "response #finish" do
|
39
|
-
it "should set status to 404 if body has not been written to" do
|
40
|
-
app do |r|
|
41
|
-
s, h, b = response.finish
|
42
|
-
"#{s}#{h['Content-Type']}#{b.length}"
|
43
|
-
end
|
44
|
-
|
45
|
-
body.must_equal '404text/html0'
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should set status to 200 if body has been written to" do
|
49
|
-
app do |r|
|
50
|
-
response.write 'a'
|
51
|
-
s, h, b = response.finish
|
52
|
-
response.write "#{s}#{h['Content-Type']}#{b.length}"
|
53
|
-
end
|
54
|
-
|
55
|
-
body.must_equal 'a200text/html1'
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should set Content-Length header" do
|
59
|
-
app do |r|
|
60
|
-
response.write 'a'
|
61
|
-
response['Content-Length'].must_be_nil
|
62
|
-
throw :halt, response.finish
|
63
|
-
end
|
64
|
-
|
65
|
-
header('Content-Length').must_equal '1'
|
66
|
-
end
|
67
|
-
|
68
|
-
[204, 304, 100].each do |status|
|
69
|
-
it "should not set Content-Type or Content-Length header on a #{status} response" do
|
70
|
-
app do |r|
|
71
|
-
response.status = status
|
72
|
-
throw :halt, response.finish
|
73
|
-
end
|
74
|
-
|
75
|
-
header('Content-Type').must_be_nil
|
76
|
-
header('Content-Length').must_be_nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should not set Content-Type header on a 205 response, but should set a Content-Length header" do
|
81
|
-
app do |r|
|
82
|
-
response.status = 205
|
83
|
-
throw :halt, response.finish
|
84
|
-
end
|
85
|
-
|
86
|
-
header('Content-Type').must_be_nil
|
87
|
-
header('Content-Length').must_equal '0'
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should not overwrite existing status" do
|
91
|
-
app do |r|
|
92
|
-
response.status = 500
|
93
|
-
s, h, b = response.finish
|
94
|
-
"#{s}#{h['Content-Type']}#{b.length}"
|
95
|
-
end
|
96
|
-
|
97
|
-
body.must_equal '500text/html0'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "response #finish_with_body" do
|
102
|
-
it "should use given body" do
|
103
|
-
app do |r|
|
104
|
-
throw :halt, response.finish_with_body(['123'])
|
105
|
-
end
|
106
|
-
|
107
|
-
body.must_equal '123'
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should set status to 200 if status has not been set" do
|
111
|
-
app do |r|
|
112
|
-
throw :halt, response.finish_with_body([])
|
113
|
-
end
|
114
|
-
|
115
|
-
status.must_equal 200
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should not set Content-Length header" do
|
119
|
-
app do |r|
|
120
|
-
response.write 'a'
|
121
|
-
response['Content-Length'].must_be_nil
|
122
|
-
throw :halt, response.finish_with_body(['123'])
|
123
|
-
end
|
124
|
-
|
125
|
-
header('Content-Length').must_be_nil
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should not overwrite existing status" do
|
129
|
-
app do |r|
|
130
|
-
response.status = 500
|
131
|
-
throw :halt, response.finish_with_body(['123'])
|
132
|
-
end
|
133
|
-
|
134
|
-
status.must_equal 500
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "response #redirect" do
|
139
|
-
it "should set location and status" do
|
140
|
-
app do |r|
|
141
|
-
r.on 'a' do
|
142
|
-
response.redirect '/foo', 303
|
143
|
-
end
|
144
|
-
r.on do
|
145
|
-
response.redirect '/bar'
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
status('/a').must_equal 303
|
150
|
-
status.must_equal 302
|
151
|
-
header('Location', '/a').must_equal '/foo'
|
152
|
-
header('Location').must_equal '/bar'
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "response #empty?" do
|
157
|
-
it "should return whether the body is empty" do
|
158
|
-
app do |r|
|
159
|
-
r.on 'a' do
|
160
|
-
response['foo'] = response.empty?.to_s
|
161
|
-
end
|
162
|
-
r.on do
|
163
|
-
response.write 'a'
|
164
|
-
response['foo'] = response.empty?.to_s
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
header('foo', '/a').must_equal 'true'
|
169
|
-
header('foo').must_equal 'false'
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "response #inspect" do
|
174
|
-
it "should return information about response" do
|
175
|
-
app(:bare) do
|
176
|
-
def self.inspect
|
177
|
-
'Foo'
|
178
|
-
end
|
179
|
-
|
180
|
-
route do |r|
|
181
|
-
response.status = 200
|
182
|
-
response.inspect
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
body.must_equal '#<Foo::RodaResponse 200 {} []>'
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "roda_class" do
|
191
|
-
it "should return the related roda subclass" do
|
192
|
-
app do |r|
|
193
|
-
self.class.opts[:a] = 'a'
|
194
|
-
response.class.roda_class.opts[:a] + response.roda_class.opts[:a]
|
195
|
-
end
|
196
|
-
|
197
|
-
body.must_equal "aa"
|
198
|
-
end
|
199
|
-
end
|