package MiscTest;
sub dispatch_request { @dispatch }
+ sub string_method { [ 999, [], [""] ]; }
}
my $app = MiscTest->new;
sub run_request { $app->run_test_request( @_ ); }
+string_method_name();
app_is_non_plack();
app_is_object();
+app_is_just_sub();
plack_app_return();
broken_route_def();
invalid_psgi_responses();
done_testing();
+sub string_method_name {
+ @dispatch = ( '/' => "string_method" );
+
+ my $get = run_request( GET => 'http://localhost/' );
+
+ cmp_ok $get->code, '==', 999, "a dispatcher that's a string matching a method on the dispatch object gets executed";
+}
+
sub app_is_non_plack {
my $r = HTTP::Response->new( 999 );
sub to_app { [ 999, [], ["ok"] ] }
}
- my $d = Web::Dispatch->new( dispatch_object => ObjectApp->new );
+ my $o = ObjectApp->new;
+ my $d = Web::Dispatch->new( dispatch_object => $o );
my $res = $d->call;
cmp_ok $res->[0], '==', 999, "Web::Dispatch can dispatch properly, given only an object with to_app method";
}
+sub app_is_just_sub {
+ my $d = Web::Dispatch->new( dispatch_app => sub () { [ 999, [], ["ok"] ] } );
+ my $res = $d->call( {} );
+
+ cmp_ok $res->[0], '==', 999,
+ "Web::Dispatch can dispatch properly, given only an app that's just a sub, with no object involved";
+}
+
sub plack_app_return {
{