Add tests which should fail, but don't.
[catagits/Catalyst-Action-REST.git] / t / catalyst-action-rest-action-dispatch.t
CommitLineData
7656dd12 1use strict;
2use warnings;
5f461845 3use Test::More tests => 21;
7656dd12 4use FindBin;
5
6use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
7use Test::Rest;
8
9# Should use the default serializer, YAML
10my $t = Test::Rest->new( 'content_type' => 'text/plain' );
11
12use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST';
13
14foreach my $method (qw(GET DELETE POST PUT OPTIONS)) {
15 my $run_method = lc($method);
7656dd12 16 my $res;
17 if ( grep /$method/, qw(GET DELETE OPTIONS) ) {
18 $res = request( $t->$run_method( url => '/actions/test' ) );
19 } else {
20 $res = request(
21 $t->$run_method(
22 url => '/actions/test',
23 data => '',
24 )
25 );
26 }
27 ok( $res->is_success, "$method request succeeded" );
28 is(
29 $res->content,
5f461845 30 "$method",
7656dd12 31 "$method request had proper response"
32 );
33 is(
5f461845 34 $res->header('X-Was-In-TopLevel'),
35 '1',
36 "went through top level action for dispatching to $method"
37 );
38 is(
7656dd12 39 $res->header('Using-Action'),
40 'STATION',
41 "went through action for dispatching to $method"
42 );
43}
44