public
Fork of wycats/merb-core
Description: Merb Core: Enterprise Edition!!!!
Homepage: http://www.merbivore.com
Clone URL: git://github.com/carllerche/merb-core-enterprise-edition.git
Adding more specs for conditions and base router spec
Dan Herrera (author)
Thu Aug 21 22:25:44 -0700 2008
commit  0189df8495ebe7c103fb5b7c1b524fe29a4664d8
tree    d62152e40bac6fea508528bf374032306991a73a
parent  8a8c45f40545b8d7068030ee1d2af5ed45f26cd0
...
119
120
121
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
124
125
...
119
120
121
 
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
0
@@ -119,7 +119,38 @@ describe "When recognizing requests," do
0
       end
0
     end
0
     
0
- it "should have more specs describing complex conditions on variables"
0
+ it "should allow greedy matches to preceed segments" do
0
+ Merb::Router.prepare do |r|
0
+ r.match!("/foo/:bar/something/:else", :bar => /.*/)
0
+ end
0
+
0
+ %w(somewhere somewhere/somehow 123/456/789 i;just/dont-understand).each do |path|
0
+ route_to("/foo/#{path}/something/wonderful").should have_route(:bar => path, :else => "wonderful")
0
+ end
0
+ end
0
+
0
+ it "should allow creating conditions that proceed a glob" do
0
+ Merb::Router.prepare do |r|
0
+ r.match!("/:foo/bar/:glob", :glob => /.*/)
0
+ end
0
+
0
+ %w(somewhere somewhere/somehow 123/456/789 i;just/dont-understand).each do |path|
0
+ route_to("/superblog/bar/#{path}").should have_route(:foo => "superblog", :glob => path)
0
+ route_to("/notablog/foo/#{path}").should have_nil_route
0
+ end
0
+ end
0
+
0
+ it "should match only if all mixed conditions are satisied" do
0
+ Merb::Router.prepare do |r|
0
+ r.match!("/:blog/post/:id", :blog => %r{^[a-zA-Z]+$}, :id => %r{^[0-9]+$})
0
+ end
0
+
0
+ route_to("/superblog/post/123").should have_route(:blog => "superblog", :id => "123")
0
+ route_to("/superblawg/post/321").should have_route(:blog => "superblawg", :id => "321")
0
+ route_to("/superblog/post/asdf").should have_nil_route
0
+ route_to("/superblog1/post/123").should have_nil_route
0
+ route_to("/ab/12").should have_nil_route
0
+ end
0
   end
0
   
0
   describe "a route built with nested conditions" do
...
8
9
10
 
 
 
 
 
 
 
 
 
11
12
13
14
15
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
22
23
0
@@ -8,7 +8,15 @@ describe Merb::Router do
0
       lambda { Merb::Router.match(simple_request) }.should raise_error(Merb::Router::NotCompiledError)
0
     end
0
     
0
+ it "should choose the correct route when multiple routes are defined" do
0
+ Merb::Router.prepare do |r|
0
+ r.match("/denver").to(:controller => "one")
0
+ r.match("/houston").to(:controller => "two")
0
+ end
0
+
0
+ route_to("/denver").should have_route(:controller => "one")
0
+ route_to("/houston").should_not have_route(:controller => "one")
0
+ end
0
   end
0
 
0
-
0
 end
0
\ No newline at end of file
...
6
7
8
 
 
9
10
11
...
6
7
8
9
10
11
12
13
0
@@ -6,6 +6,8 @@ class TestController < Merb::Controller
0
 end
0
 
0
 describe Merb::Test::RouteHelper do
0
+ include Merb::Test::RouteHelper
0
+
0
   before(:each) do
0
     Merb::Router.prepare do |r|
0
       r.match("/", :method => :get).to(:controller => "test_controller", :action => "get").name(:getter)

Comments

    No one has commented yet.