0
require File.join(File.dirname(__FILE__), "spec_helper")
0
describe "Regex-based routes" do
0
it "should process a simple regex" do
0
- prepare_route(%r[^/foos?/(bar|baz)/:id], :controller => "foo", :action => "[1]", :id => ":id")
0
+ prepare_route(%r[^/foos?/(bar|baz)/:id], :controller => "foo", :action => "[1]", :id => ":id")
0
route_to("/foo/bar/baz").should have_route(:controller => "foo", :action => "bar", :id => "baz")
0
route_to("/foos/baz/bam").should have_route(:controller => "foo", :action => "baz", :id => "bam")
0
it "should support inbound user agents" do
0
Merb::Router.prepare do |r|
0
r.match(%r[^/foo/(.+)], :user_agent => /(MSIE|Gecko)/).
0
- to(:controller => "foo", :title => "[1]", :action => "show", :agent => ":user_agent[1]")
0
+ to(:controller => "foo", :title => "[1]", :action => "show", :agent => ":user_agent[1]")
0
route_to("/foo/bar", :user_agent => /MSIE/).should have_route(
0
:controller => "foo", :action => "show", :title => "bar", :agent => "MSIE"
0
describe "Routes that are restricted based on incoming params" do
0
it "should allow you to restrict routes to POST requests" do
0
Merb::Router.prepare do |r|
0
r.match("/:controller/create/:id", :method => :post).
0
route_to("/foo/create/12", :method => "post").should have_route(
0
:controller => "foo", :action => "create", :id => "12"
0
route_to("/foo/create/12", :method => "get").should_not have_route(
0
:controller => "foo", :action => "create", :id => "12"
0
it "should allow you to restrict routes based on protocol" do
0
Merb::Router.prepare do |r|
0
r.match(:protocol => "http://").to(:controller => "foo", :action => "bar")
0
route_to("/foo/bar").should have_route(:controller => "foo", :action => "bar")
0
route_to("/boo/hoo", :protocol => "https://").should have_route(:controller => "boo", :action => "hoo")
0
+ it "does not require explicit specifying of params" do
0
+ Merb::Router.prepare do |r|
0
+ r.match!("/fb/:callback_path/:controller/:action")
0
+ route_to("/fb/callybacky/products/search").should have_route(
0
+ :controller => "products", :action => "search", :callback_path => "callybacky"
0
+ route_to("/fb/ping/products/search").should have_route(
0
+ :controller => "products", :action => "search", :callback_path => "ping"
Comments
No one has commented yet.