root/veekun/trunk/t/dex-compat.t

Revision 346, 1.0 kB (checked in by eevee, 14 months ago)

Added a test for Pokedex compatibility URLs.

Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use lib 'lib';
6
7use Test::More tests => 10;
8
9BEGIN { $ENV{CATALYST_DEBUG} = 0; }
10BEGIN { use_ok 'Catalyst::Test', 'Vee' }
11BEGIN { use_ok 'Vee::Controller::Dex::Compat' }
12
13my $req;
14
15# Test correct redirection of old numbered URLs
16
17$req = request('/dex/pokemon/133');
18ok $req->is_redirect,  "Numeric Pokemon URL results in a redirect";
19like $req->header('location'), qr# /dex/pokemon/eevee $ #x,
20    "...and redirects correctly";
21
22$req = request('/dex/move/314');
23ok $req->is_redirect,  "Numeric move URL results in a redirect";
24like $req->header('location'), qr# /dex/moves/air%20cutter $ #x,
25    "...and redirects correctly";
26
27$req = request('/dex/type/5');
28ok $req->is_redirect,  "Numeric type URL results in a redirect";
29like $req->header('location'), qr# /dex/types/ground $ #x,
30    "...and redirects correctly";
31
32# Make sure invalid ones bomb cleanly
33
34$req = request('/dex/type/12');
35ok $req->is_success,  "Invalid numeric type URL succeeds";
36like $req->content, qr/<div id="error">/,
37    "...and provides an error message";
Note: See TracBrowser for help on using the browser.