Commit | Line | Data |
d0d292d4 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use FindBin; |
aadb0c7d |
5 | use Test::Requires qw(JSON::MaybeXS); |
d0d292d4 |
6 | |
7 | use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib"); |
8 | use Test::Rest; |
9 | use utf8; |
10 | |
d0d292d4 |
11 | use_ok 'Catalyst::Test', 'Test::Serialize', 'Catalyst::Action::Serialize::JSON'; |
12 | |
13 | my $json = JSON->new->utf8; |
14 | |
15 | for ('text/javascript','application/x-javascript','application/javascript') { |
16 | my $t = Test::Rest->new('content_type' => $_); |
17 | my $monkey_template = { monkey => 'likes chicken!' }; |
18 | |
f2d34339 |
19 | my $mres = request($t->get(url => '/monkey_get?callback=My_Animal.omnivore')); |
d0d292d4 |
20 | ok( $mres->is_success, 'GET the monkey succeeded' ); |
21 | |
f2d34339 |
22 | my ($json_param) = $mres->content =~ /^My_Animal.omnivore\((.*)?\);$/; |
d0d292d4 |
23 | is_deeply($json->decode($json_param), $monkey_template, "GET returned the right data"); |
24 | } |
25 | |
26 | 1; |
10018fb4 |
27 | |
28 | done_testing; |