[Catalyst-commits] r8234 - in Catalyst-Action-REST/0.60/trunk: .
lib/Catalyst/Action lib/Catalyst/Controller t
jshirley at dev.catalyst.perl.org
jshirley at dev.catalyst.perl.org
Wed Aug 20 18:44:13 BST 2008
Author: jshirley
Date: 2008-08-20 18:44:12 +0100 (Wed, 20 Aug 2008)
New Revision: 8234
Modified:
Catalyst-Action-REST/0.60/trunk/Changes
Catalyst-Action-REST/0.60/trunk/Makefile.PL
Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Action/REST.pm
Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Controller/REST.pm
Catalyst-Action-REST/0.60/trunk/t/catalyst-action-serialize-accept.t
Catalyst-Action-REST/0.60/trunk/t/catalyst-request-rest.t
Catalyst-Action-REST/0.60/trunk/t/json.t
Log:
Fixing the tests to run without JSON at all, revamping the author/contrib section
Modified: Catalyst-Action-REST/0.60/trunk/Changes
===================================================================
--- Catalyst-Action-REST/0.60/trunk/Changes 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/Changes 2008-08-20 17:44:12 UTC (rev 8234)
@@ -1,3 +1,8 @@
+Wed Aug 20 10:42:00 PST 2008 (jshirley) - Release 0.65
+ Fully revamped tests to work without any JSON support
+ Final removal of JSON::Syck
+ Special thanks to jgoulah for helping test this release
+
Wed Aug 13 08:55:00 PST 2008 (jshirley) - Release 0.64
New dist to fix issue with Module::Install
Modified: Catalyst-Action-REST/0.60/trunk/Makefile.PL
===================================================================
--- Catalyst-Action-REST/0.60/trunk/Makefile.PL 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/Makefile.PL 2008-08-20 17:44:12 UTC (rev 8234)
@@ -17,8 +17,8 @@
feature 'JSON (application/json) support',
-default => 0,
- 'JSON' => undef;
- 'JSON::XS' => undef;
+ 'JSON' => '2.12';
+ 'JSON::XS' => '2.2222';
feature 'Data::Denter (text/x-data-denter) support',
-default => 0,
Modified: Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Action/REST.pm
===================================================================
--- Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Action/REST.pm 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Action/REST.pm 2008-08-20 17:44:12 UTC (rev 8234)
@@ -18,7 +18,7 @@
BEGIN { require 5.008001; }
-our $VERSION = '0.64';
+our $VERSION = '0.65';
# This is wrong in several ways. First, there's no guarantee that
# Catalyst.pm has not been subclassed. Two, there's no guarantee that
@@ -155,16 +155,26 @@
L<Catalyst::Action::Serialize>, L<Catalyst::Action::Deserialize>
+=head1 MAINTAINER
+
+J. Shirley <jshirley at gmail.com>
+
+=head1 CONTRIBUTORS
+
+Christopher Laco
+
+Luke Saunders
+
+John Goulah
+
+Daisuke Maki <daisuke at endeworks.jp>
+
=head1 AUTHOR
Adam Jacob <adam at stalecoffee.org>, with lots of help from mst and jrockway
Marchex, Inc. paid me while I developed this module. (http://www.marchex.com)
-=head1 CONTRIBUTERS
-
-Daisuke Maki <daisuke at endeworks.jp>
-
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
Modified: Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Controller/REST.pm
===================================================================
--- Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Controller/REST.pm 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/lib/Catalyst/Controller/REST.pm 2008-08-20 17:44:12 UTC (rev 8234)
@@ -1,6 +1,6 @@
package Catalyst::Controller::REST;
-our $VERSION = 0.64;
+our $VERSION = '0.65';
=head1 NAME
Modified: Catalyst-Action-REST/0.60/trunk/t/catalyst-action-serialize-accept.t
===================================================================
--- Catalyst-Action-REST/0.60/trunk/t/catalyst-action-serialize-accept.t 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/t/catalyst-action-serialize-accept.t 2008-08-20 17:44:12 UTC (rev 8234)
@@ -18,7 +18,7 @@
'stash_key' => 'rest',
'map' => {
'text/x-yaml' => 'YAML',
- 'application/json' => 'JSON',
+ 'application/json' => 'JSON',
'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
'text/broken' => 'Broken',
},
@@ -49,7 +49,6 @@
use Data::Serializer;
use FindBin;
use Data::Dump qw(dump);
-use JSON::Syck;
use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/broken");
use Test::Rest;
@@ -69,21 +68,32 @@
$req->remove_header('Content-Type');
$req->header('Accept', 'text/x-yaml');
my $res = request($req);
- ok( $res->is_success, 'GET the serialized request succeeded' );
- is( $res->content, $data, "Request returned proper data");
- is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type')
+ SKIP: {
+ skip "can't test text/x-yaml without YAML support",
+ 3 if (
+ not $res->is_success and
+ $res->content =~ m#Content-Type text/x-yaml is not supported#
+ );
+ ok( $res->is_success, 'GET the serialized request succeeded' );
+ is( $res->content, $data, "Request returned proper data");
+ is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type')
+
+ };
}
-{
- my $at = Test::Rest->new('content_type' => 'text/doesnt-exist');
+SKIP: {
+ eval 'require JSON';
+ skip "can't test application/json without JSON support", 3 if $@;
+ my $json = JSON->new;
+ my $at = Test::Rest->new('content_type' => 'text/doesnt-exist');
my $req = $at->get(url => '/test');
$req->header('Accept', 'application/json');
my $res = request($req);
- ok( $res->is_success, 'GET the serialized request succeeded' );
- my $ret = JSON::Syck::Load($res->content);
- is( $ret->{lou}, 'is my cat', "Request returned proper data");
- is( $res->header('Content-type'), 'application/json', 'Accept header used if content-type mapping not found')
-}
+ ok( $res->is_success, 'GET the serialized request succeeded' );
+ my $ret = $json->decode($res->content);
+ is( $ret->{lou}, 'is my cat', "Request returned proper data");
+ is( $res->header('Content-type'), 'application/json', 'Accept header used if content-type mapping not found')
+};
# Make sure we don't get a bogus content-type when using default
# serializer (rt.cpan.org ticket 27949)
Modified: Catalyst-Action-REST/0.60/trunk/t/catalyst-request-rest.t
===================================================================
--- Catalyst-Action-REST/0.60/trunk/t/catalyst-request-rest.t 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/t/catalyst-request-rest.t 2008-08-20 17:44:12 UTC (rev 8234)
@@ -87,7 +87,7 @@
$request->headers( HTTP::Headers->new );
$request->parameters( {} );
$request->method('GET');
- $request->content_type('text/x-json');
+ $request->content_type('application/json');
$request->headers->header(
'Accept' =>
# From Firefox 2.0 when it requests an html page
@@ -95,7 +95,7 @@
);
is_deeply( $request->accepted_content_types,
- [ qw( text/x-json
+ [ qw( application/json
text/xml application/xml application/xhtml+xml
image/png
text/html
Modified: Catalyst-Action-REST/0.60/trunk/t/json.t
===================================================================
--- Catalyst-Action-REST/0.60/trunk/t/json.t 2008-08-18 22:38:19 UTC (rev 8233)
+++ Catalyst-Action-REST/0.60/trunk/t/json.t 2008-08-20 17:44:12 UTC (rev 8234)
@@ -1,34 +1,35 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More;
use FindBin;
use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
use Test::Rest;
-use_ok 'Catalyst::Test', 'Test::Serialize';
+eval 'require JSON';
+plan skip_all => 'Install JSON to run this test' if ($@);
-SKIP: {
- my $has_serializer = eval "require JSON::Syck";
+plan tests => 9;
- skip "JSON::Syck not available", 8, unless $has_serializer;
+use_ok 'Catalyst::Test', 'Test::Serialize';
- for ('text/x-json', 'application/json') {
- my $t = Test::Rest->new('content_type' => $_);
- my $monkey_template = {
- monkey => 'likes chicken!',
- };
- my $mres = request($t->get(url => '/monkey_get'));
- ok( $mres->is_success, 'GET the monkey succeeded' );
- is_deeply(JSON::Syck::Load($mres->content), $monkey_template, "GET returned the right data");
+my $json = JSON->new;
+# The text/x-json should throw a warning
+for ('text/x-json', 'application/json') {
+ my $t = Test::Rest->new('content_type' => $_);
+ my $monkey_template = {
+ monkey => 'likes chicken!',
+ };
+ my $mres = request($t->get(url => '/monkey_get'));
+ ok( $mres->is_success, 'GET the monkey succeeded' );
+ is_deeply($json->decode($mres->content), $monkey_template, "GET returned the right data");
- my $post_data = {
- 'sushi' => 'is good for monkey',
- };
- my $mres_post = request($t->post(url => '/monkey_put', data => JSON::Syck::Dump($post_data)));
- ok( $mres_post->is_success, "POST to the monkey succeeded");
- is_deeply($mres_post->content, "is good for monkey", "POST data matches");
- }
-};
+ my $post_data = {
+ 'sushi' => 'is good for monkey',
+ };
+ my $mres_post = request($t->post(url => '/monkey_put', data => $json->encode($post_data)));
+ ok( $mres_post->is_success, "POST to the monkey succeeded");
+ is_deeply($mres_post->content, "is good for monkey", "POST data matches");
+}
1;
More information about the Catalyst-commits
mailing list