Skip to content

Commit

Permalink
better mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 18, 2012
1 parent e005c46 commit 76e9c1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 2 additions & 4 deletions lib/Test/Mojo.pm
Expand Up @@ -315,10 +315,8 @@ sub _test {
}

sub _text {
my ($self, $selector) = @_;
my $text;
if (my $e = $self->tx->res->dom->at($selector)) { $text = $e->text }
return $text;
return unless my $e = shift->tx->res->dom->at(@_);
return $e->text;
}

1;
Expand Down
15 changes: 7 additions & 8 deletions t/mojolicious/testing_app.t
Expand Up @@ -15,19 +15,18 @@ 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 .= $t->ua->name })->or(sub { $or .= shift->ua->name });
is $or, 'Mojolicious (Perl)Mojolicious (Perl)',
'both callbacks have been invoked';
my $t = Test::Mojo->new('MojoliciousTest');
my $mode = '';
$t->or(sub { $mode .= $t->app->mode })->or(sub { $mode .= shift->app->mode });
is $mode, 'testingtesting', '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->ua->name })->header_is(Server => 'Mojolicious (Perl)')
->or(sub { $mode .= $t->app->mode })
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_like(qr/Testing Missing/);
is $or, 'Mojolicious (Perl)Mojolicious (Perl)',
'callback has not been invoked';
is $mode, 'testingtesting', '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 76e9c1e

Please sign in to comment.