root/lang/perl/HTTP-Router/branches/merb-like/t/20_match.t @ 26593

Revision 26593, 2.2 kB (checked in by masaki, 6 years ago)

テストまだ通りきってないけどこんな感じかな

Line 
1use t::Router;
2
3plan tests => 2 * blocks;
4
5my $router = build_router();
6
7filters {
8    conditions => ['eval'],
9    params     => ['yaml'],
10};
11
12run {
13    my $block = shift;
14    my $match = $router->route_for($block->path, $block->conditions);
15    is_deeply $match->params, $block->params, "@{[ $block->name ]} (params)";
16    is $match->path, $block->path, "@{[ $block->name ]} (path)";
17};
18
19__END__
20=== /
21--- path: /
22--- params
23controller: Root
24action: index
25
26=== GET /
27--- path: /
28--- conditions: { method => 'GET' }
29--- params
30controller: Root
31action: index
32
33=== POST /
34--- path: /
35--- conditions: { method => 'POST' }
36--- params
37controller: Root
38action: index
39
40=== GET /account/login
41--- path: /account/login
42--- conditions: { method => 'GET' }
43--- params
44controller: Account
45action: login
46
47=== POST /account/login
48--- path: /account/login
49--- conditions: { method => 'POST' }
50--- params
51controller: Account
52action: login
53
54=== GET /archives/{year}
55--- path: /archives/2008
56--- params
57controller: Archive
58action: by_year
59year: 2008
60
61=== GET /archives/{year}/{month}
62--- path: /archives/2008/12
63--- params
64controller: Archive
65action: by_month
66year: 2008
67month: 12
68
69=== GET /archives/{year}/{month}/{day}
70--- path: /archives/2008/12/31
71--- params
72controller: Archive
73action: by_day
74year: 2008
75month: 12
76day: 31
77
78=== GET /articles
79--- path: /articles
80--- conditions: { method => 'GET' }
81--- params
82controller: Article
83action: index
84
85=== GET /articles/new
86--- path: /articles/new
87--- conditions: { method => 'GET' }
88--- params
89controller: Article
90action: post
91
92=== POST /articles
93--- path: /articles
94--- conditions: { method => 'POST' }
95--- params
96controller: Article
97action: create
98
99=== GET /articles/{article_id}
100--- path: /articles/14
101--- conditions: { method => 'GET' }
102--- params
103controller: Article
104action: show
105article_id: 14
106
107=== GET /articles/{article_id}/edit
108--- path: /articles/14/edit
109--- conditions: { method => 'GET' }
110--- params
111controller: Article
112action: edit
113article_id: 14
114
115=== PUT /articles/{article_id}
116--- path: /articles/15
117--- conditions: { method => 'PUT' }
118--- params
119controller: Article
120action: update
121article_id: 15
122
123=== DELETE /articles/{article_id}
124--- path: /articles/16
125--- conditions: { method => 'DELETE' }
126--- params
127controller: Article
128action: destroy
129article_id: 16
Note: See TracBrowser for help on using the browser.