Fix tests to skip if YAML::Syck is not installed
[catagits/Catalyst-Action-REST.git] / t / yaml-html.t
CommitLineData
e601adda 1use strict;
2use warnings;
10018fb4 3use Test::More;
801ec379 4use Test::Requires qw(YAML::Syck);
e601adda 5use YAML::Syck;
6use FindBin;
e601adda 7
8use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
9use Test::Rest;
10
11BEGIN {
12 use_ok 'Catalyst::Test', 'Test::Serialize';
13}
14
15my $has_serializer = eval "require YAML::Syck";
16SKIP: {
17 skip "YAML::Syck not available", 3, unless $has_serializer;
18
19 my $t = Test::Rest->new( 'content_type' => 'text/html' );
20
21 my $monkey_template =
22"<html><title>Test::Serialize</title><body><pre>--- \nmonkey: likes chicken!\n</pre></body></html>";
23 my $mres = request( $t->get( url => '/monkey_get' ) );
24 ok( $mres->is_success, 'GET the monkey succeeded' );
25 is( $mres->content, $monkey_template, "GET returned the right data" );
26
27 my $post_data = { 'sushi' => 'is good for monkey', };
28 my $mres_post =
29 request( $t->post( url => '/monkey_put', data => Dump($post_data) ) );
30 ok( $mres_post->is_error, "POST to the monkey failed; no deserializer." );
31
8aa1a2ee 32 # xss test - RT 63537
33 my $xss_template =
34"<html><title>Test::Serialize</title><body><pre>--- \nmonkey: likes chicken &gt; sushi!\n</pre></body></html>";
35 my $xres = request( $t->get( url => '/xss_get' ) );
36 ok( $xres->is_success, 'GET the xss succeeded' );
37 is( $xres->content, $xss_template, "GET returned the right data" );
38
39
e601adda 40}
411;
10018fb4 42
43done_testing;