diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-06-22 12:37:12 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-06-22 12:38:24 -0500 |
commit | f1b91129c91259731320329b561896a22b97f341 (patch) | |
tree | 644c0e8b594160fa4e8c613b292e24dc0fb2dfdd /t | |
parent | efed66d882f7073ed05b7b62012ae1b70e6ef05b (diff) | |
download | plack-middleware-class-refresh-f1b91129c91259731320329b561896a22b97f341.tar.gz plack-middleware-class-refresh-f1b91129c91259731320329b561896a22b97f341.zip |
more tests
Diffstat (limited to 't')
-rw-r--r-- | t/basic.t | 89 |
1 files changed, 66 insertions, 23 deletions
@@ -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; |