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
startrader (author)
Thu May 15 20:28:58 -0700 2008
michaelklishin (committer)
Fri May 16 15:11:44 -0700 2008
commit  47e48f25a89e065fd1aba6c122e28197daf24f2e
tree    69be000f81503e02b338eaffe2d3dc0a16d0992b
parent  56f5c097e66722e2f47f3ad7b77e01799d507d19
merb-core / spec / public / router / nested_matches_spec.rb
100644 52 lines (45 sloc) 1.756 kb
1
2
3
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
41
42
43
44
45
46
47
48
49
50
51
52
require File.join(File.dirname(__FILE__), "spec_helper")
 
describe "A route derived from the blocks of #match" do
  
  it "should inherit the :controller option." do
    Merb::Router.prepare do |r|
      r.match('/alpha', :controller=>'Alphas') do |alpha|
        alpha.match('').to(:action=>'normal')
      end
    end
    route_to('/alpha').should have_route(:controller=>'Alphas',:action=>'normal')
  end
  
  it "should inherit the :action option." do
    Merb::Router.prepare do |r|
      r.match('/alpha', :action=>'wierd') do |alpha|
        alpha.match('').to(:controller=>'Alphas')
      end
    end
    route_to('/alpha').should have_route(:controller=>'Alphas',:action=>'wierd')
  end
  
  it "should inherit the default :action of 'index'" do
    Merb::Router.prepare do |r|
      r.match('/alpha', :controller=>'Alphas') do |alpha|
        alpha.match('').to({})
      end
    end
    route_to('/alpha').should have_route(:controller=>'Alphas',:action=>'index')
  end
  
  it "should make use of the :params option" do
    Merb::Router.prepare do |r|
      r.match('/alpha', :controller=>'Alphas', :params =>{:key=>'value'}) do |alpha|
        alpha.match('').to(:action=>'normal',:key2=>'value2')
      end
    end
    route_to('/alpha').should have_route(:controller=>'Alphas',:key=>'value',:action=>'normal',:key2=>'value2')
  end
  
  it "should inherit the parameters through many levels" do
    Merb::Router.prepare do |r|
      r.match('/alpha', :controller=>'Alphas') do |alpha|
        alpha.match('/beta', :action=>'normal') do |beta|
          beta.match('/:id').to(:id=>':id')
        end
      end
    end
    route_to('/alpha/beta/gamma').should have_route(:controller=>'Alphas',:action=>'normal', :id=>'gamma')
  end
  
end