Skip to content

Commit 1a89f12

Browse files
committed
Testing infrastructure adjustments
1 parent 53e1546 commit 1a89f12

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

Web/lib/BlogDB/Web/Test.pm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ package BlogDB::Web::Test;
22
use Import::Into;
33
use Test::More;
44
use Test::Deep;
5-
use Test::Mojo;
5+
use Test::Mojo::BlogDB;
66
use Test::Postgresql58;
77

88
push our @ISA, qw( Exporter );
9-
push our @EXPORT, qw( );
9+
push our @EXPORT, qw( $run_code );
1010

1111
sub import {
1212
shift->export_to_level(1);
1313
my $target = caller;
1414

15-
Mojo::Base->import::into($target, '-strict');
16-
warnings ->import::into($target);
17-
strict ->import::into($target);
18-
Test::More->import::into($target);
19-
Test::Deep->import::into($target);
20-
Test::Mojo->import::into($target);
15+
Mojo::Base ->import::into($target, '-strict', '-signatures' );
16+
warnings ->import::into($target);
17+
strict ->import::into($target);
18+
Test::More ->import::into($target);
19+
Test::Deep ->import::into($target);
20+
Test::Mojo::BlogDB->import::into($target);
2121
}
2222

2323
our $pgsql = Test::Postgresql58->new()
@@ -49,4 +49,4 @@ sub load_psql_file {
4949
undef $dbh;
5050
}
5151

52-
1;
52+
1;

Web/lib/Test/Mojo/BlogDB.pm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package Test::Mojo::BlogDB;
2+
use parent 'Test::Mojo';
3+
use Data::Dumper;
4+
5+
sub new {
6+
my $class = shift;
7+
my $self = $class->SUPER::new(@_);
8+
9+
$self->app->hook( after_dispatch => sub {
10+
my ( $c ) = @_;
11+
$self->stash( $c->stash );
12+
});
13+
14+
return $self;
15+
}
16+
17+
sub stash {
18+
my $self = shift;
19+
$self->{stash} = shift if @_;
20+
return $self->{stash};
21+
}
22+
23+
sub code_block {
24+
my ( $t, $code ) = @_;
25+
26+
$code->($t);
27+
28+
return $t;
29+
}
30+
31+
1;

0 commit comments

Comments
 (0)