Make LWP a test dep instead of a hard dep
[catagits/Catalyst-Action-REST.git] / t / catalyst-action-rest-action-dispatch-for-browsers.t
CommitLineData
83273f94 1use strict;
2use warnings;
3use Test::More;
4use FindBin;
5
6use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
7use Test::Rest;
8
9my $t = Test::Rest->new( 'content_type' => 'text/plain' );
10
11use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST';
12
13my $url = '/actionsforbrowsers/for_browsers';
14
15foreach 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
37my $res = request(
38 $t->get(
39 url => $url,
40 headers => { Accept => 'text/html' },
41 )
42);
43
44ok( $res->is_success, "GET request succeeded (client looks like browser)" );
45is(
46 $res->content,
47 "GET_html",
48 "GET request had proper response (client looks like browser)"
49);
50
51done_testing;
52