Add tests which should fail, but don't.
[catagits/Catalyst-Action-REST.git] / t / catalyst-action-rest-action-dispatch.t
1 use strict;
2 use warnings;
3 use Test::More tests => 21;
4 use FindBin;
5
6 use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
7 use Test::Rest;
8
9 # Should use the default serializer, YAML
10 my $t = Test::Rest->new( 'content_type' => 'text/plain' );
11
12 use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST';
13
14 foreach my $method (qw(GET DELETE POST PUT OPTIONS)) {
15     my $run_method = lc($method);
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,
30         "$method",
31         "$method request had proper response"
32     );
33     is(
34         $res->header('X-Was-In-TopLevel'),
35         '1',
36         "went through top level action for dispatching to $method"
37     );
38     is(
39         $res->header('Using-Action'),
40         'STATION',
41         "went through action for dispatching to $method"
42     );
43 }
44