From: Hans Dieter Pearcey Date: Wed, 25 Mar 2009 05:30:38 +0000 (-0400) Subject: refactored test application X-Git-Tag: 0.67_01~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=9d3bee45561e72bc5f859bf1fc2d8164519b7c5a refactored test application --- diff --git a/t/catalyst-action-serialize-query.t b/t/catalyst-action-serialize-query.t index c237872..cfbcb8a 100644 --- a/t/catalyst-action-serialize-query.t +++ b/t/catalyst-action-serialize-query.t @@ -1,39 +1,3 @@ -package Test::Catalyst::Action::Serialize; - -use FindBin; - -use lib ("$FindBin::Bin/../lib"); - -use strict; -use warnings; - -use Catalyst::Runtime '5.70'; - -use Catalyst; - -__PACKAGE__->config( - name => 'Test::Catalyst::Action::Serialize', - serialize => { - 'stash_key' => 'rest', - 'map' => { - 'text/x-yaml' => 'YAML', - 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], - 'text/broken' => 'Broken', - }, - } -); - -__PACKAGE__->setup; - -sub test :Local :ActionClass('Serialize') { - my ( $self, $c ) = @_; - $c->stash->{'rest'} = { - lou => 'is my cat', - }; -} - -package main; - use strict; use warnings; use Test::More tests => 3; @@ -46,9 +10,9 @@ use Test::Rest; # YAML my $t = Test::Rest->new('content_type' => 'text/x-yaml'); -use_ok 'Catalyst::Test', 'Test::Catalyst::Action::Serialize'; +use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST'; -my $req = $t->get(url => '/test?content-type=text/x-yaml'); +my $req = $t->get(url => '/serialize/test?content-type=text/x-yaml'); $req->remove_header('Content-Type'); my $res = request($req); ok( $res->is_success, 'GET the serialized request succeeded' ); diff --git a/t/catalyst-action-serialize.t b/t/catalyst-action-serialize.t index 7a3dbe3..584711f 100644 --- a/t/catalyst-action-serialize.t +++ b/t/catalyst-action-serialize.t @@ -1,47 +1,3 @@ -package Test::Catalyst::Action::Serialize; - -use FindBin; - -use lib ("$FindBin::Bin/../lib"); - -use strict; -use warnings; - -use Catalyst::Runtime '5.70'; - -use Catalyst; - -__PACKAGE__->config( - name => 'Test::Catalyst::Action::Serialize', - serialize => { - 'default' => 'YAML', - 'stash_key' => 'rest', - 'map' => { - 'text/x-yaml' => 'YAML', - 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], - 'text/broken' => 'Broken', - }, - } -); - -__PACKAGE__->setup; - -sub test :Local :ActionClass('Serialize') { - my ( $self, $c ) = @_; - $c->stash->{'rest'} = { - lou => 'is my cat', - }; -} - -sub test_second :Local :ActionClass('Serialize') { - my ( $self, $c ) = @_; - $c->stash->{'rest'} = { - lou => 'is my cat', - }; -} - -package main; - use strict; use warnings; use Test::More tests => 7; @@ -55,23 +11,23 @@ use Test::Rest; # Should use Data::Dumper, via YAML my $t = Test::Rest->new('content_type' => 'text/x-data-dumper'); -use_ok 'Catalyst::Test', 'Test::Catalyst::Action::Serialize'; +use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST'; -my $res = request($t->get(url => '/test')); +my $res = request($t->get(url => '/serialize/test')); ok( $res->is_success, 'GET the serialized request succeeded' ); is( $res->content, "{'lou' => 'is my cat'}", "Request returned proper data"); my $nt = Test::Rest->new('content_type' => 'text/broken'); -my $bres = request($nt->get(url => '/test')); +my $bres = request($nt->get(url => '/serialize/test')); is( $bres->code, 415, 'GET on un-useable Serialize class returns 415'); my $ut = Test::Rest->new('content_type' => 'text/not-happening'); -my $ures = request($ut->get(url => '/test')); +my $ures = request($ut->get(url => '/serialize/test')); is ($bres->code, 415, 'GET on unknown Content-Type returns 415'); # This check is to make sure we can still serialize after the first # request. -my $res2 = request($t->get(url => '/test_second')); +my $res2 = request($t->get(url => '/serialize/test_second')); ok( $res2->is_success, '2nd request succeeded' ); is( $res2->content, "{'lou' => 'is my cat'}", "2nd request returned proper data");