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
data/spec/route_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "Roda.route" do
|
4
|
-
it "should set the route block" do
|
5
|
-
pr = proc{'123'}
|
6
|
-
app.route(&pr)
|
7
|
-
app.route_block.must_equal pr
|
8
|
-
body.must_equal '123'
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should work if called in subclass and parent class later frozen" do
|
12
|
-
a = app
|
13
|
-
@app = Class.new(a)
|
14
|
-
@app.route{|r| "OK"}
|
15
|
-
body.must_equal "OK"
|
16
|
-
a.freeze
|
17
|
-
body.must_equal "OK"
|
18
|
-
app.freeze
|
19
|
-
body.must_equal "OK"
|
20
|
-
end
|
21
|
-
|
22
|
-
deprecated "should support #call being overridden" do
|
23
|
-
app.class_eval do
|
24
|
-
def call; super end
|
25
|
-
end
|
26
|
-
app.route{'123'}
|
27
|
-
body.must_equal '123'
|
28
|
-
end
|
29
|
-
|
30
|
-
deprecated "should support #_call" do
|
31
|
-
pr = proc{env['PATH_INFO']}
|
32
|
-
app{_call(&pr)}
|
33
|
-
body.must_equal '/'
|
34
|
-
end
|
35
|
-
|
36
|
-
deprecated "should be callable without a block" do
|
37
|
-
app.route.must_be_nil
|
38
|
-
end
|
39
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
if RUBY_VERSION >= '2'
|
4
|
-
require 'roda/session_middleware'
|
5
|
-
|
6
|
-
describe "RodaSessionMiddleware" do
|
7
|
-
include CookieJar
|
8
|
-
|
9
|
-
it "operates like a session middleware" do
|
10
|
-
sess = nil
|
11
|
-
env = nil
|
12
|
-
|
13
|
-
app(:bare) do
|
14
|
-
use RodaSessionMiddleware, :secret=>'1'*64
|
15
|
-
|
16
|
-
route do |r|
|
17
|
-
r.get('s', String, String){|k, v| session[k.to_sym] = v}
|
18
|
-
r.get('g', String){|k| session[k.to_sym].to_s}
|
19
|
-
r.get('c'){|k| session.clear; ''}
|
20
|
-
r.get('sh'){|k| env = r.env; sess = session; ''}
|
21
|
-
''
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
_, h, b = req('/')
|
26
|
-
h['Set-Cookie'].must_be_nil
|
27
|
-
b.must_equal ['']
|
28
|
-
|
29
|
-
_, h, b = req('/s/foo/bar')
|
30
|
-
h['Set-Cookie'].must_match(/\Aroda\.session=(.*); path=\/; HttpOnly(; SameSite=Lax)?\z/m)
|
31
|
-
b.must_equal ['bar']
|
32
|
-
body('/s/foo/bar').must_equal 'bar'
|
33
|
-
body('/g/foo').must_equal 'bar'
|
34
|
-
|
35
|
-
body('/s/foo/baz').must_equal 'baz'
|
36
|
-
body('/g/foo').must_equal 'baz'
|
37
|
-
|
38
|
-
body("/s/foo/\u1234").must_equal "\u1234"
|
39
|
-
body("/g/foo").must_equal "\u1234"
|
40
|
-
|
41
|
-
body("/c").must_equal ""
|
42
|
-
body("/g/foo").must_equal ""
|
43
|
-
|
44
|
-
body('/s/foo/bar')
|
45
|
-
body("/sh").must_equal ""
|
46
|
-
|
47
|
-
sess.must_be_kind_of RodaSessionMiddleware::SessionHash
|
48
|
-
sess.req.must_be_kind_of Roda::RodaRequest
|
49
|
-
sess.data.must_be_nil
|
50
|
-
sess.options[:secret].must_equal('1'*64)
|
51
|
-
sess.inspect.must_include "not yet loaded"
|
52
|
-
sess.loaded?.must_equal false
|
53
|
-
|
54
|
-
a = []
|
55
|
-
sess.each{|k, v| a << k << v}
|
56
|
-
a.must_equal %w'foo bar'
|
57
|
-
sess.data.must_equal("foo"=>"bar")
|
58
|
-
sess.inspect.must_equal '{"foo"=>"bar"}'
|
59
|
-
sess.loaded?.must_equal true
|
60
|
-
|
61
|
-
sess[:foo].must_equal "bar"
|
62
|
-
sess['foo'].must_equal "bar"
|
63
|
-
|
64
|
-
sess.fetch(:foo).must_equal "bar"
|
65
|
-
sess.fetch('foo').must_equal "bar"
|
66
|
-
proc{sess.fetch('foo2')}.must_raise KeyError
|
67
|
-
sess.fetch(:foo, "baz").must_equal "bar"
|
68
|
-
sess.fetch('foo', "baz").must_equal "bar"
|
69
|
-
sess.fetch('foo2', "baz").must_equal "baz"
|
70
|
-
|
71
|
-
sess.has_key?(:foo).must_equal true
|
72
|
-
sess.has_key?("foo").must_equal true
|
73
|
-
sess.has_key?("bar").must_equal false
|
74
|
-
sess.key?("foo").must_equal true
|
75
|
-
sess.key?("bar").must_equal false
|
76
|
-
sess.include?("foo").must_equal true
|
77
|
-
sess.include?("bar").must_equal false
|
78
|
-
|
79
|
-
sess[:foo2] = "bar2"
|
80
|
-
sess['foo2'].must_equal "bar2"
|
81
|
-
sess.store('foo3', "bar3").must_equal "bar3"
|
82
|
-
sess['foo3'].must_equal "bar3"
|
83
|
-
|
84
|
-
env['roda.session.created_at'] = true
|
85
|
-
env['roda.session.updated_at'] = true
|
86
|
-
sess.clear.must_equal({})
|
87
|
-
sess.data.must_equal({})
|
88
|
-
env['roda.session.created_at'].must_be_nil
|
89
|
-
env['roda.session.updated_at'].must_be_nil
|
90
|
-
|
91
|
-
sess['a'] = 'b'
|
92
|
-
env['roda.session.created_at'] = true
|
93
|
-
env['roda.session.updated_at'] = true
|
94
|
-
sess.destroy.must_equal({})
|
95
|
-
sess.data.must_equal({})
|
96
|
-
env['roda.session.created_at'].must_be_nil
|
97
|
-
env['roda.session.updated_at'].must_be_nil
|
98
|
-
|
99
|
-
sess[:foo] = "bar"
|
100
|
-
sess.to_hash.must_equal("foo"=>"bar")
|
101
|
-
sess.to_hash.wont_be_same_as(sess.data)
|
102
|
-
|
103
|
-
sess.update("foo2"=>"bar2", :foo=>"bar3").must_equal("foo"=>"bar3", "foo2"=>"bar2")
|
104
|
-
sess.data.must_equal("foo"=>"bar3", "foo2"=>"bar2")
|
105
|
-
sess.merge!("foo2"=>"bar4").must_equal("foo"=>"bar3", "foo2"=>"bar4")
|
106
|
-
|
107
|
-
sess.replace("foo2"=>"bar5", :foo3=>"bar").must_equal("foo3"=>"bar", "foo2"=>"bar5")
|
108
|
-
sess.data.must_equal("foo3"=>"bar", "foo2"=>"bar5")
|
109
|
-
|
110
|
-
sess.delete(:foo3).must_equal("bar")
|
111
|
-
sess.data.must_equal("foo2"=>"bar5")
|
112
|
-
sess.delete("foo2").must_equal("bar5")
|
113
|
-
sess.data.must_equal({})
|
114
|
-
|
115
|
-
sess.exists?.must_equal true
|
116
|
-
env.delete('roda.session.serialized')
|
117
|
-
sess.exists?.must_equal false
|
118
|
-
|
119
|
-
sess.empty?.must_equal true
|
120
|
-
sess[:foo] = "bar"
|
121
|
-
sess.empty?.must_equal false
|
122
|
-
sess.keys.must_equal ["foo"]
|
123
|
-
sess.values.must_equal ["bar"]
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
data/spec/session_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "session handling" do
|
4
|
-
include CookieJar
|
5
|
-
|
6
|
-
it "should give a warning if session variable is not available" do
|
7
|
-
app do |r|
|
8
|
-
begin
|
9
|
-
session
|
10
|
-
rescue Exception => e
|
11
|
-
e.message
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
body.must_match("You're missing a session handler, try using the sessions plugin.")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return session if rack session middleware is used" do
|
19
|
-
app(:bare) do
|
20
|
-
use Rack::Session::Cookie, :secret=>'1'
|
21
|
-
|
22
|
-
route do |r|
|
23
|
-
r.on do
|
24
|
-
(session[1] ||= 'a'.dup) << 'b'
|
25
|
-
session[1]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
_, _, b = req
|
31
|
-
b.join.must_equal 'ab'
|
32
|
-
_, _, b = req
|
33
|
-
b.join.must_equal 'abb'
|
34
|
-
_, _, b = req
|
35
|
-
b.join.must_equal 'abbb'
|
36
|
-
end
|
37
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
$:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
2
|
-
|
3
|
-
if ENV['WARNING']
|
4
|
-
require 'warning'
|
5
|
-
Warning.ignore([:missing_ivar, :method_redefined, :not_reached], File.dirname(File.dirname(__FILE__)))
|
6
|
-
end
|
7
|
-
|
8
|
-
if ENV['COVERAGE']
|
9
|
-
require 'coverage'
|
10
|
-
require 'simplecov'
|
11
|
-
|
12
|
-
def SimpleCov.roda_coverage(opts = {})
|
13
|
-
start do
|
14
|
-
enable_coverage :branch if ENV['BRANCH_COVERAGE']
|
15
|
-
add_filter "/spec/"
|
16
|
-
add_group('Missing'){|src| src.covered_percent < 100}
|
17
|
-
add_group('Covered'){|src| src.covered_percent == 100}
|
18
|
-
yield self if block_given?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
ENV.delete('COVERAGE')
|
23
|
-
SimpleCov.roda_coverage
|
24
|
-
end
|
25
|
-
|
26
|
-
require_relative "../lib/roda"
|
27
|
-
require "stringio"
|
28
|
-
|
29
|
-
ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
|
30
|
-
gem 'minitest'
|
31
|
-
require "minitest/global_expectations/autorun"
|
32
|
-
|
33
|
-
$RODA_WARN = true
|
34
|
-
def (Roda::RodaPlugins).warn(s)
|
35
|
-
return unless $RODA_WARN
|
36
|
-
$stderr.puts s
|
37
|
-
puts caller.grep(/_spec\.rb:\d+:/)
|
38
|
-
end
|
39
|
-
|
40
|
-
if ENV['RODA_RACK_SESSION_COOKIE'] != '1'
|
41
|
-
require_relative '../lib/roda/session_middleware'
|
42
|
-
DEFAULT_SESSION_MIDDLEWARE_ARGS = [RodaSessionMiddleware, :secret=>'1'*64]
|
43
|
-
DEFAULT_SESSION_ARGS = [:plugin, :sessions, :secret=>'1'*64]
|
44
|
-
else
|
45
|
-
DEFAULT_SESSION_MIDDLEWARE_ARGS = [Rack::Session::Cookie, :secret=>'1']
|
46
|
-
DEFAULT_SESSION_ARGS = [:use, Rack::Session::Cookie, :secret=>'1']
|
47
|
-
end
|
48
|
-
|
49
|
-
module CookieJar
|
50
|
-
def req(path='/', env={})
|
51
|
-
if path.is_a?(Hash)
|
52
|
-
env = path
|
53
|
-
else
|
54
|
-
env['PATH_INFO'] = path.dup
|
55
|
-
end
|
56
|
-
env['HTTP_COOKIE'] = @cookie if @cookie
|
57
|
-
|
58
|
-
a = super(env)
|
59
|
-
if set = a[1]['Set-Cookie']
|
60
|
-
@cookie = set.sub(/(; path=\/)?(; secure)?; HttpOnly/, '')
|
61
|
-
end
|
62
|
-
a
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class Minitest::Spec
|
67
|
-
def self.deprecated(a, &block)
|
68
|
-
it("#{a} (deprecated)") do
|
69
|
-
begin
|
70
|
-
$RODA_WARN = false
|
71
|
-
instance_exec(&block)
|
72
|
-
ensure
|
73
|
-
$RODA_WARN = true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def app(type=nil, &block)
|
79
|
-
case type
|
80
|
-
when :new
|
81
|
-
@app = _app{route(&block) if block}
|
82
|
-
when :bare
|
83
|
-
@app = _app(&block)
|
84
|
-
when Symbol
|
85
|
-
@app = _app do
|
86
|
-
plugin type
|
87
|
-
route(&block)
|
88
|
-
end
|
89
|
-
else
|
90
|
-
if block
|
91
|
-
@app = _app{route(&block)}
|
92
|
-
else
|
93
|
-
@app ||= _app{}
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def req(path='/', env={})
|
99
|
-
if path.is_a?(Hash)
|
100
|
-
env = path
|
101
|
-
else
|
102
|
-
env['PATH_INFO'] = path.dup
|
103
|
-
end
|
104
|
-
|
105
|
-
env = {"REQUEST_METHOD" => "GET", "PATH_INFO" => "/", "SCRIPT_NAME" => ""}.merge(env)
|
106
|
-
@app.call(env)
|
107
|
-
end
|
108
|
-
|
109
|
-
def status(path='/', env={})
|
110
|
-
req(path, env)[0]
|
111
|
-
end
|
112
|
-
|
113
|
-
def header(name, path='/', env={})
|
114
|
-
req(path, env)[1][name]
|
115
|
-
end
|
116
|
-
|
117
|
-
def body(path='/', env={})
|
118
|
-
s = String.new
|
119
|
-
b = req(path, env)[2]
|
120
|
-
b.each{|x| s << x}
|
121
|
-
b.close if b.respond_to?(:close)
|
122
|
-
s
|
123
|
-
end
|
124
|
-
|
125
|
-
def _app(&block)
|
126
|
-
c = Class.new(Roda)
|
127
|
-
c.class_eval(&block)
|
128
|
-
c
|
129
|
-
end
|
130
|
-
|
131
|
-
def with_rack_env(env)
|
132
|
-
ENV['RACK_ENV'] = env
|
133
|
-
yield
|
134
|
-
ensure
|
135
|
-
ENV.delete('RACK_ENV')
|
136
|
-
end
|
137
|
-
end
|
data/spec/version_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
describe "Roda version constants" do
|
4
|
-
it "RodaVersion should be a string in x.y.z integer format" do
|
5
|
-
Roda::RodaVersion.must_match(/\A\d+\.\d+\.\d+\z/)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "Roda*Version and RodaVersionNumber should be integers" do
|
9
|
-
Roda::RodaMajorVersion.must_be_kind_of(Integer)
|
10
|
-
Roda::RodaMinorVersion.must_be_kind_of(Integer)
|
11
|
-
Roda::RodaPatchVersion.must_be_kind_of(Integer)
|
12
|
-
Roda::RodaVersionNumber.must_be_kind_of(Integer)
|
13
|
-
end
|
14
|
-
end
|
data/spec/views/_test.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1><%= title %></h1>
|
data/spec/views/a.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
a
|
data/spec/views/a.rdoc
DELETED
data/spec/views/about.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1><%= title %></h1>
|
data/spec/views/about.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1>#{title}</h1>
|
Binary file
|
data/spec/views/about/_test.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Subdir: <%= title %></h1>
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
about-ct
|
data/spec/views/b.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
b
|
data/spec/views/c.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
c
|
data/spec/views/comp_layout.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
a<%= yield %>b
|
data/spec/views/comp_test.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ct
|
@@ -1 +0,0 @@
|
|
1
|
-
This is the actual content.
|
data/spec/views/each.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
r-#{each if local_variables.include?(:each)}-#{foo if local_variables.include?(:foo)}
|
data/spec/views/home.erb
DELETED
data/spec/views/home.str
DELETED
data/spec/views/iv.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= @a %>
|
data/spec/views/layout-yield.erb
DELETED
data/spec/views/layout.erb
DELETED
data/spec/views/layout.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= title %>:<%= a %>::<%= yield %>
|
data/spec/views/multiple.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= title %>:<%= b %>
|