X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsub-dispatch-args.t;h=71fc4eba44d5f72c42ebfb752037202d0e5c0a5e;hb=c62cf40ac80b302b71683630b11b6157f018ba4a;hp=c68b059fe55fc4c1858f18a892499405d796ccd7;hpb=30e2c525d12f6b82eb3350583cabfc9dda8c5ae3;p=catagits%2FWeb-Simple.git diff --git a/t/sub-dispatch-args.t b/t/sub-dispatch-args.t index c68b059..71fc4eb 100644 --- a/t/sub-dispatch-args.t +++ b/t/sub-dispatch-args.t @@ -34,6 +34,7 @@ use Plack::Test; sub show_landing { my ($self, @args) = @_; local $self->{_dispatcher}; + local $args[-1]->{'Web::Dispatch.original_env'}; return [ 200, ['Content-Type' => 'application/perl' ], [::Dumper \@args], @@ -42,6 +43,7 @@ use Plack::Test; sub show_users { my ($self, @args) = @_; local $self->{_dispatcher}; + local $args[-1]->{'Web::Dispatch.original_env'}; return [ 200, ['Content-Type' => 'application/perl' ], [::Dumper \@args], @@ -50,6 +52,7 @@ use Plack::Test; sub show_user { my ($self, @args) = @_; local $self->{_dispatcher}; + local $args[-1]->{'Web::Dispatch.original_env'}; return [ 200, ['Content-Type' => 'application/perl' ], [::Dumper \@args], @@ -58,6 +61,7 @@ use Plack::Test; sub process_post { my ($self, @args) = @_; local $self->{_dispatcher}; + local $args[-1]->{'Web::Dispatch.original_env'}; return [ 200, ['Content-Type' => 'application/perl' ], [::Dumper \@args], @@ -68,17 +72,12 @@ use Plack::Test; ok my $app = t::Web::Simple::SubDispatchArgs->new, 'made app'; -sub run_request { - my $request = shift; - return test_psgi $app->to_psgi_app, sub { shift->($request) }; -} - -use HTTP::Request::Common qw(GET POST); +sub run_request { $app->run_test_request(@_); } -ok my $get_landing = run_request(GET 'http://localhost/' ), +ok my $get_landing = run_request(GET => 'http://localhost/' ), 'got landing'; -cmp_ok $get_landing->code, '==', 200, +cmp_ok $get_landing->code, '==', 200, '200 on GET'; no strict 'refs'; @@ -91,10 +90,10 @@ no strict 'refs'; is ref($env), 'HASH', 'Got hashref'; } -ok my $get_users = run_request(GET 'http://localhost/user'), +ok my $get_users = run_request(GET => 'http://localhost/user'), 'got user'; -cmp_ok $get_users->code, '==', 200, +cmp_ok $get_users->code, '==', 200, '200 on GET'; { @@ -104,10 +103,10 @@ cmp_ok $get_users->code, '==', 200, is ref($env), 'HASH', 'Got hashref'; } -ok my $get_user = run_request(GET 'http://localhost/user/42'), +ok my $get_user = run_request(GET => 'http://localhost/user/42'), 'got user'; -cmp_ok $get_user->code, '==', 200, +cmp_ok $get_user->code, '==', 200, '200 on GET'; { @@ -117,10 +116,10 @@ cmp_ok $get_user->code, '==', 200, is ref($env), 'HASH', 'Got hashref'; } -ok my $post_user = run_request(POST 'http://localhost/user/42', [id => '99'] ), +ok my $post_user = run_request(POST => 'http://localhost/user/42', [id => '99'] ), 'post user'; -cmp_ok $post_user->code, '==', 200, +cmp_ok $post_user->code, '==', 200, '200 on POST'; { @@ -131,4 +130,3 @@ cmp_ok $post_user->code, '==', 200, is $params->{id}, 99, 'got expected value for id'; is ref($env), 'HASH', 'Got hashref'; } -