Skip to content

Commit

Permalink
even more format detection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 15, 2012
1 parent 3fd8194 commit f18ba44
Showing 1 changed file with 45 additions and 10 deletions.
55 changes: 45 additions & 10 deletions t/mojolicious/group_lite_app.t
Expand Up @@ -8,7 +8,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 169;
use Test::More tests => 195;

# "Let's see how crazy I am now, Nixon. The correct answer is very."
use Mojo::ByteStream 'b';
Expand Down Expand Up @@ -185,9 +185,15 @@ get '/no_format' => {text => 'No format detection.'};

# GET /some_formats.txt
# GET /some_formats.html
get '/some_formats' => [format => [qw/txt html/]] =>
get '/some_formats' => [format => [qw/txt json/]] =>
{text => 'Some format detection.'};

# GET /no_real_format.xml
get '/no_real_format.xml' => {text => 'No real format.'};

# GET /one_format.xml
get '/one_format' => [format => 'xml'] => {text => 'One format.'};

my $t = Test::Mojo->new;

# GET /with_under
Expand Down Expand Up @@ -379,24 +385,53 @@ $t->get_ok('/authgroup')->status_is(200)->content_is("You're not ok.");
$t->get_ok('/noauthgroup')->status_is(200)->content_is("Whatever one.\n");

# GET /no_format
$t->get_ok('/no_format')->status_is(200)->content_is('No format detection.');
$t->get_ok('/no_format')->status_is(200)
->content_type_is('text/html;charset=UTF-8')
->content_is('No format detection.');

# GET /no_format.txt
$t->get_ok('/no_format.txt')->status_is(404);
$t->get_ok('/no_format.txt')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /some_formats
$t->get_ok('/some_formats')->status_is(404);
$t->get_ok('/some_formats')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /some_formats.txt
$t->get_ok('/some_formats.txt')->status_is(200)
$t->get_ok('/some_formats.txt')->status_is(200)->content_type_is('text/plain')
->content_is('Some format detection.');

# GET /some_formats.html
$t->get_ok('/some_formats.html')->status_is(200)
->content_is('Some format detection.');
# GET /some_formats.json
$t->get_ok('/some_formats.json')->status_is(200)
->content_type_is('application/json')->content_is('Some format detection.');

# GET /some_formats.xml
$t->get_ok('/some_formats.xml')->status_is(404);
$t->get_ok('/some_formats.xml')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /no_real_format
$t->get_ok('/no_real_format')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /no_real_format.xml
$t->get_ok('/no_real_format.xml')->status_is(200)
->content_type_is('text/html;charset=UTF-8')->content_is('No real format.');

# GET /no_real_format.txt
$t->get_ok('/no_real_format.txt')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /one_format
$t->get_ok('/one_format')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

# GET /one_format.xml
$t->get_ok('/one_format.xml')->status_is(200)->content_type_is('text/xml')
->content_is('One format.');

# GET /one_format.txt
$t->get_ok('/one_format.txt')->status_is(404)
->content_type_is('text/html;charset=UTF-8');

__DATA__
@@ not_found.html.epl
Expand Down

0 comments on commit f18ba44

Please sign in to comment.