Skip to content

Commit

Permalink
better tests for or method
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 18, 2012
1 parent a860d82 commit e934b75
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions t/mojolicious/testing_app.t
Expand Up @@ -15,17 +15,20 @@ use lib "$FindBin::Bin/lib";
use Test::Mojo;

# "Anything less than immortality is a complete waste of time!"
my $t = Test::Mojo->new('MojoliciousTest');
my $or;
$t->or(sub { $or++ })->or(sub { $or++ });
is $or, 2, 'both callbacks have been invoked';
my $t = Test::Mojo->new('MojoliciousTest');
my $or = '';
$t->or(sub { $or .= shift->ua->name })->or(sub { $or .= shift->ua->name });
is $or, 'Mojolicious (Perl)Mojolicious (Perl)',
'both callbacks have been invoked';

# SyntaxError::foo in testing mode (syntax error in controller)
$t->get_ok('/syntax_error/foo')->status_is(500)->or(sub { $or++ })
$t->get_ok('/syntax_error/foo')->status_is(500)
->or(sub { $or .= shift->ua->name })
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_like(qr/Testing Missing/);
is $or, 2, 'callback has not been invoked';
is $or, 'Mojolicious (Perl)Mojolicious (Perl)',
'callback has not been invoked';

# Foo::syntaxerror in testing mode (syntax error in template)
$t->get_ok('/foo/syntaxerror')->status_is(500)
Expand Down

0 comments on commit e934b75

Please sign in to comment.