public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
merb-core / spec / public / router / deferred_spec.rb
100644 22 lines (17 sloc) 0.679 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require File.join(File.dirname(__FILE__), "spec_helper")
 
describe "Deferred routes" do
 
  before :each do
    Merb::Router.prepare do |r|
      r.match("/deferred/:zoo").defer_to do |request, params|
        params.merge(:controller => "w00t") if params[:zoo]
      end
      r.default_routes
    end
  end
  
  it "should match routes based on the incoming params" do
    route_to("/deferred/baz", :boo => "12").should have_route(:controller => "w00t", :zoo => "baz")
  end
 
  it "should fall back to the default route if the deferred condition is not met" do
    route_to("/deferred").should have_route(:controller => "deferred", :action => "index")
  end
  
end