Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better AUTOLOAD tests
  • Loading branch information
kraih committed Aug 5, 2013
1 parent 94fe6c6 commit a2524ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

4.24 2013-08-03
4.24 2013-08-06

4.23 2013-08-01
- Added redirects method to Mojo::Transaction::HTTP.
Expand Down
11 changes: 9 additions & 2 deletions t/mojo/dom.t
Expand Up @@ -1803,7 +1803,7 @@ $dom->find('b')->each(
);
is_deeply \@results, [qw(baz yada)], 'right results';

# Autoload children in XML mode
# AUTOLOAD children in XML mode
$dom = Mojo::DOM->new->xml(1)->parse(<<EOF);
<a id="one">
<B class="two" test>
Expand All @@ -1820,7 +1820,7 @@ is $dom->a->B->c->[1]->text, 'baz', 'right text';
is $dom->a->B->c->[2], undef, 'no result';
is $dom->a->B->c->size, 2, 'right number of elements';

# Autoload children in HTML mode
# AUTOLOAD children in HTML mode
$dom = Mojo::DOM->new(<<EOF);
<a id="one">
<B class="two" test>
Expand All @@ -1837,6 +1837,13 @@ is $dom->a->b->c->[1]->text, 'baz', 'right text';
is $dom->a->b->c->[2], undef, 'no result';
is $dom->a->b->c->size, 2, 'right number of elements';

# Missing method and function
eval { Mojo::DOM->new->missing };
like $@, qr/^Can't locate object method "missing" via package "Mojo::DOM"/,
'right error';
eval { Mojo::DOM::missing() };
like $@, qr/^Undefined subroutine &Mojo::DOM::missing called/, 'right error';

# Direct hash access to attributes in XML mode
$dom = Mojo::DOM->new->xml(1)->parse(<<EOF);
<a id="one">
Expand Down
22 changes: 22 additions & 0 deletions t/mojolicious/app.t
Expand Up @@ -61,6 +61,28 @@ is $t->app->static->file('hello.txt')->slurp,
is $t->app->moniker, 'mojolicious_test', 'right moniker';
is $t->app->secret, $t->app->moniker, 'secret defaults to moniker';

# Missing methods and functions
eval { $t->app->missing };
like $@,
qr/^Can't locate object method "missing" via package "MojoliciousTest"/,
'right error';
eval { Mojolicious::missing() };
like $@, qr/^Undefined subroutine &Mojolicious::missing called/, 'right error';
my $c = $t->app->controller_class->new;
eval { $c->missing };
like $@, qr/^Can't locate object method "missing" via package "@{[ref $c]}"/,
'right error';
eval { Mojolicious::Controller::missing() };
like $@, qr/^Undefined subroutine &Mojolicious::Controller::missing called/,
'right error';
eval { $t->app->routes->missing };
like $@,
qr/^Can't locate object method "missing" via package "Mojolicious::Routes"/,
'right error';
eval { Mojolicious::Routes::missing() };
like $@, qr/^Undefined subroutine &Mojolicious::Routes::missing called/,
'right error';

# Hidden controller attributes and methods
$t->app->routes->hide('bar');
ok !$t->app->routes->is_hidden('foo'), 'not hidden';
Expand Down

0 comments on commit a2524ab

Please sign in to comment.