summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-06-22 12:37:12 -0500
committerJesse Luehrs <doy@tozt.net>2011-06-22 12:38:24 -0500
commitf1b91129c91259731320329b561896a22b97f341 (patch)
tree644c0e8b594160fa4e8c613b292e24dc0fb2dfdd
parentefed66d882f7073ed05b7b62012ae1b70e6ef05b (diff)
downloadplack-middleware-class-refresh-f1b91129c91259731320329b561896a22b97f341.tar.gz
plack-middleware-class-refresh-f1b91129c91259731320329b561896a22b97f341.zip
more tests
-rw-r--r--t/basic.t89
1 files changed, 66 insertions, 23 deletions
diff --git a/t/basic.t b/t/basic.t
index 2373218..bf775fd 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -12,12 +12,6 @@ use HTTP::Request::Common;
use Plack::Middleware::Class::Refresh;
-my $dir = Test::PMCR::setup_temp_dir('basic');
-
-require Foo;
-require Foo::Bar;
-require Baz::Quux;
-
my $app = sub {
return [
200,
@@ -26,22 +20,71 @@ my $app = sub {
];
};
-test_psgi
- app => Plack::Middleware::Class::Refresh->wrap($app),
- client => sub {
- my $cb = shift;
- {
- my $res = $cb->(GET 'http://localhost/');
- is($res->code, 200, "right code");
- is($res->content, "Foo\nFoo::Bar\nBaz::Quux");
- }
- copy(catfile(qw(t data_new basic Foo.pm)), catfile($dir, 'Foo.pm'))
- || die "couldn't copy: $!";
- {
- my $res = $cb->(GET 'http://localhost/');
- is($res->code, 200, "right code");
- is($res->content, "FOO\nFoo::Bar\nBaz::Quux");
- }
- };
+{
+ my $dir = Test::PMCR::setup_temp_dir('basic');
+
+ require Foo;
+ require Foo::Bar;
+ require Baz::Quux;
+
+ test_psgi
+ app => Plack::Middleware::Class::Refresh->wrap($app),
+ client => sub {
+ my $cb = shift;
+ {
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ my $res = $cb->(GET 'http://localhost/');
+ is($res->code, 200, "right code");
+ is($res->content, "Foo\nFoo::Bar\nBaz::Quux");
+ is($warnings, undef, "no warnings when not verbose");
+ }
+ copy(catfile(qw(t data_new basic Foo.pm)), catfile($dir, 'Foo.pm'))
+ || die "couldn't copy: $!";
+ {
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ my $res = $cb->(GET 'http://localhost/');
+ is($res->code, 200, "right code");
+ is($res->content, "FOO\nFoo::Bar\nBaz::Quux", "right content");
+ is($warnings, undef, "no warnings when not verbose");
+ }
+ };
+}
+
+Class::Refresh->unload_module($_) for 'Foo', 'Foo::Bar', 'Baz::Quux';
+
+{
+ my $dir = Test::PMCR::setup_temp_dir('basic');
+
+ require Foo;
+ require Foo::Bar;
+ require Baz::Quux;
+
+ test_psgi
+ app => Plack::Middleware::Class::Refresh->wrap($app, verbose => 1),
+ client => sub {
+ my $cb = shift;
+ {
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ my $res = $cb->(GET 'http://localhost/');
+ is($res->code, 200, "right code");
+ is($res->content, "Foo\nFoo::Bar\nBaz::Quux");
+ is($warnings, undef, "no warnings yet");
+ }
+ copy(catfile(qw(t data_new basic Foo.pm)), catfile($dir, 'Foo.pm'))
+ || die "couldn't copy: $!";
+ {
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ my $res = $cb->(GET 'http://localhost/');
+ is($res->code, 200, "right code");
+ is($res->content, "FOO\nFoo::Bar\nBaz::Quux", "right content");
+ like($warnings, qr/^Class Foo has been changed, refreshing/,
+ "right warning");
+ }
+ };
+}
done_testing;