v1.19
[catagits/Catalyst-Action-REST.git] / t / catalyst-action-rest-action-dispatch-for-browsers.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use FindBin;
5
6 use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
7 use Test::Rest;
8
9 my $t = Test::Rest->new( 'content_type' => 'text/plain' );
10
11 use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST';
12
13 my $url = '/actionsforbrowsers/for_browsers';
14
15 foreach my $method (qw(GET POST)) {
16     my $run_method = lc($method);
17     my $result     = "something $method";
18     my $res;
19     if ( $method eq 'GET' ) {
20         $res = request( $t->$run_method( url => $url ) );
21     } else {
22         $res = request(
23             $t->$run_method(
24                 url  => $url,
25                 data => '',
26             )
27         );
28     }
29     ok( $res->is_success, "$method request succeeded" );
30     is(
31         $res->content,
32         "$method",
33         "$method request had proper response"
34     );
35 }
36
37 my $res = request(
38     $t->get(
39         url     => $url,
40         headers => { Accept => 'text/html' },
41     )
42 );
43
44 ok( $res->is_success, "GET request succeeded (client looks like browser)" );
45 is(
46     $res->content,
47     "GET_html",
48     "GET request had proper response (client looks like browser)"
49 );
50
51 done_testing;
52