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 in a few regex specs
Dan Herrera (author)
Sun Aug 24 23:31:11 -0700 2008
commit  c8acc7a5383ed047a6a96c84ec621cffd50f5903
tree    52ab98cfd0949ab4c586e1ce580e96dddb0f0c14
parent  0e8361bc48a62d3b1b6dffff2d6e7e9757149940
...
4
5
6
7
 
 
 
 
 
 
 
 
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
...
4
5
6
 
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
@@ -4,8 +4,37 @@ describe "When recognizing requests," do
0
 
0
   describe "a route with a Regexp path condition" do
0
     
0
- it "should allow mixing regular expression paths with string paths when nesting match blocks"
0
+ it "should allow a regex expression" do
0
+ Merb::Router.prepare do |r|
0
+ r.match(%r{^/foos?/(bar|baz)/([a-z0-9]+)}).to(:controller => "foo", :action => "[1]", :id => "[2]")
0
+ end
0
+
0
+ route_to("/foo/bar/baz").should have_route(:controller => "foo", :action => "bar", :id => "baz")
0
+ route_to("/foos/bar/baz").should have_route(:controller => "foo", :action => "bar", :id => "baz")
0
+ route_to("/bars/foo/baz").should have_nil_route
0
+ end
0
     
0
+ it "should allow mixing regular expression paths with string paths" do
0
+ Merb::Router.prepare do |r|
0
+ r.match(%r{^/(foo|bar)/baz/([a-z0-9]+)}).to(:controller => "[1]", :action => "baz", :id => "[2]")
0
+ end
0
+
0
+ route_to("/foo/baz/bar").should have_route(:controller => "foo", :action => "baz", :id => "bar")
0
+ route_to("/bar/baz/foo").should have_route(:controller => "bar", :action => "baz", :id => "foo")
0
+ route_to("/for/bar/baz").should have_nil_route
0
+ end
0
+
0
+ it "should allow mixing regular expression paths with string paths when nesting match blocks" do
0
+ Merb::Router.prepare do |r|
0
+ r.match("/buh/") do |buh|
0
+ buh.match(%r{^(foo|bar)/baz/([a-z0-9]+)}).to(:controller => "[1]", :action => "baz", :id => "[2]")
0
+ end
0
+ end
0
+
0
+ route_to("/buh/foo/baz/1").should have_route(:controller => "foo", :action => "baz", :id => "1")
0
+ route_to("/buh/bar/baz/buh").should have_route(:controller => "bar", :action => "baz", :id => "buh")
0
+ route_to("/buh/baz/foo/buh").should have_nil_route
0
+ end
0
   end
0
 
0
 end

Comments

    No one has commented yet.