Created
July 3, 2009 02:14
-
-
Save mash/139866 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Test::Base; | |
| { | |
| package TestApp; | |
| use Ark; | |
| package TestApp::Controller::One; | |
| use Ark 'Controller'; | |
| sub one :Local { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= 'one_'; | |
| $c->forward('two'); | |
| } | |
| sub two :Local { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= 'two_'; | |
| $c->detach('three'); | |
| $c->res->{body} .= 'wrong_two_'; | |
| } | |
| sub three :Local { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= 'three'; | |
| } | |
| sub end :Private { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= '__action:' . $c->req->action->reverse; | |
| } | |
| package TestApp::Controller::Two; | |
| use Ark 'Controller'; | |
| sub one :Local { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= 'one_'; | |
| $c->detach; | |
| $c->forward('two'); | |
| } | |
| sub two :Local { | |
| my ($self, $c) = @_; | |
| $c->res->{body} .= 'two_'; | |
| } | |
| } | |
| use Ark::Test 'TestApp', | |
| components => [qw/Controller::One | |
| Controller::Two | |
| /]; | |
| plan 'no_plan'; | |
| { | |
| my $res = request( GET => '/one/one' ); | |
| ok($res->is_success, 'response ok'); | |
| is($res->content, 'one_two_three__action:one/three', 'detach response ok'); | |
| } | |
| { | |
| my $res = request( GET => '/two/one' ); | |
| ok($res->is_success, 'response ok'); | |
| is($res->content, 'one_', 'detach response ok'); | |
| } | |
| __END__ | |
| t/005_detach.... | |
| ok 1 - response ok | |
| not ok 2 - detach response ok | |
| # Failed test 'detach response ok' | |
| # at t/005_detach.t line 59. | |
| # got: 'one_two_three__action:one/one' | |
| # expected: 'one_two_three__action:one/three' | |
| ok 3 - response ok | |
| ok 4 - detach response ok | |
| ok1..4 | |
| # Looks like you failed 1 test of 4. | |
| Dubious, test returned 1 (wstat 256, 0x100) | |
| Failed 1/4 subtests | |
| Test Summary Report | |
| ------------------- | |
| t/005_detach (Wstat: 256 Tests: 4 Failed: 1) | |
| Failed test: 256 Non-zero exit status: 1Files=1, Tests=4, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.28 cusr 0.02 csys = 0.33 CPU) | |
| Result: Failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment