roda 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +26 -0
- data/README.rdoc +83 -22
- data/Rakefile +1 -1
- data/doc/release_notes/2.1.0.txt +124 -0
- data/lib/roda/plugins/assets.rb +17 -9
- data/lib/roda/plugins/class_level_routing.rb +5 -2
- data/lib/roda/plugins/delegate.rb +6 -3
- data/lib/roda/plugins/indifferent_params.rb +7 -0
- data/lib/roda/plugins/mailer.rb +18 -1
- data/lib/roda/plugins/multi_route.rb +2 -1
- data/lib/roda/plugins/path.rb +75 -6
- data/lib/roda/plugins/render.rb +33 -14
- data/lib/roda/plugins/static.rb +35 -0
- data/lib/roda/plugins/view_options.rb +161 -0
- data/lib/roda/plugins/view_subdirs.rb +6 -63
- data/lib/roda/version.rb +1 -1
- data/spec/composition_spec.rb +12 -0
- data/spec/matchers_spec.rb +34 -0
- data/spec/plugin/assets_spec.rb +112 -17
- data/spec/plugin/delete_empty_headers_spec.rb +12 -0
- data/spec/plugin/mailer_spec.rb +46 -3
- data/spec/plugin/module_include_spec.rb +17 -0
- data/spec/plugin/multi_route_spec.rb +10 -0
- data/spec/plugin/named_templates_spec.rb +6 -0
- data/spec/plugin/not_found_spec.rb +1 -1
- data/spec/plugin/path_spec.rb +76 -0
- data/spec/plugin/render_each_spec.rb +6 -0
- data/spec/plugin/render_spec.rb +40 -1
- data/spec/plugin/sinatra_helpers_spec.rb +5 -0
- data/spec/plugin/static_spec.rb +30 -0
- data/spec/plugin/view_options_spec.rb +117 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/views/multiple-layout.erb +1 -0
- data/spec/views/multiple.erb +1 -0
- metadata +10 -4
- data/spec/plugin/static_path_info_spec.rb +0 -56
- data/spec/plugin/view_subdirs_spec.rb +0 -44
@@ -1,56 +0,0 @@
|
|
1
|
-
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
|
2
|
-
|
3
|
-
describe "static_path_info plugin" do
|
4
|
-
it "does not modify SCRIPT_NAME/PATH_INFO during routing" do
|
5
|
-
app(:bare) do
|
6
|
-
plugin :static_path_info
|
7
|
-
plugin :pass
|
8
|
-
|
9
|
-
route do |r|
|
10
|
-
r.on "foo" do
|
11
|
-
r.is "bar" do
|
12
|
-
"bar|#{env['SCRIPT_NAME']}|#{env['PATH_INFO']}"
|
13
|
-
end
|
14
|
-
r.is "baz" do
|
15
|
-
r.pass
|
16
|
-
end
|
17
|
-
"foo|#{env['SCRIPT_NAME']}|#{env['PATH_INFO']}"
|
18
|
-
end
|
19
|
-
"#{env['SCRIPT_NAME']}|#{env['PATH_INFO']}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
body.should == '|/'
|
24
|
-
body('SCRIPT_NAME'=>'/a').should == '/a|/'
|
25
|
-
body('/foo').should == 'foo||/foo'
|
26
|
-
body('/foo', 'SCRIPT_NAME'=>'/a').should == 'foo|/a|/foo'
|
27
|
-
body('/foo/bar').should == 'bar||/foo/bar'
|
28
|
-
body('/foo/bar', 'SCRIPT_NAME'=>'/a').should == 'bar|/a|/foo/bar'
|
29
|
-
body('/foo/baz').should == 'foo||/foo/baz'
|
30
|
-
body('/foo/baz', 'SCRIPT_NAME'=>'/a').should == 'foo|/a|/foo/baz'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "modifies SCRIPT_NAME/PATH_INFO when calling run" do
|
34
|
-
a = app{|r| "#{r.script_name}|#{r.path_info}"}
|
35
|
-
app(:static_path_info){|r| r.on("a"){r.run a}}
|
36
|
-
body("/a/b").should == "/a|/b"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "restores SCRIPT_NAME/PATH_INFO before returning from run" do
|
40
|
-
a = app{|r| "#{r.script_name}|#{r.path_info}"}
|
41
|
-
app(:static_path_info){|r| s = catch(:halt){r.on("a"){r.run a}}; "#{s[2].join}%#{r.script_name}|#{r.path_info}"}
|
42
|
-
body("/a/b").should == "/a|/b%|/a/b"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "static_path_info request.path, .remaining_path, and .matched_path" do
|
47
|
-
it "should return the script name and path_info as a string" do
|
48
|
-
app(:static_path_info) do |r|
|
49
|
-
r.on "foo" do
|
50
|
-
"#{r.path}:#{r.matched_path}:#{r.remaining_path}"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
body("/foo/bar").should == "/foo/bar:/foo:/bar"
|
55
|
-
end
|
56
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'tilt/erb'
|
5
|
-
rescue LoadError
|
6
|
-
warn "tilt not installed, skipping view_subdirs plugin test"
|
7
|
-
else
|
8
|
-
describe "view_subdirs plugin" do
|
9
|
-
before do
|
10
|
-
app(:bare) do
|
11
|
-
plugin :render, :views=>"./spec"
|
12
|
-
plugin :view_subdirs
|
13
|
-
|
14
|
-
route do |r|
|
15
|
-
r.on "home" do
|
16
|
-
set_view_subdir 'views'
|
17
|
-
view("home", :locals=>{:name => "Agent Smith", :title => "Home"}, :layout_opts=>{:locals=>{:title=>"Home"}})
|
18
|
-
end
|
19
|
-
|
20
|
-
r.on "about" do
|
21
|
-
set_view_subdir 'views'
|
22
|
-
render("views/about", :locals=>{:title => "About Roda"})
|
23
|
-
end
|
24
|
-
|
25
|
-
r.on "path" do
|
26
|
-
render('views/about', :locals=>{:title => "Path"}, :layout_opts=>{:locals=>{:title=>"Home"}})
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should use set subdir if template name does not contain a slash" do
|
33
|
-
body("/home").strip.should == "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should not use set subdir if template name contains a slash" do
|
37
|
-
body("/about").strip.should == "<h1>About Roda</h1>"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should not change behavior when subdir is not set" do
|
41
|
-
body("/path").strip.should == "<h1>Path</h1>"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|