This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag v0.11 in repository libdancer-plugin-rest-perl.
commit 2351618c5e071d1ddee780842cec6a1b55829fd7 Author: Breno G. de Oliveira <g...@cpan.org> Date: Tue Mar 25 02:01:43 2014 -0300 tests for resource params and prepare_serializer_for_format --- t/05_serializer_and_resource.t | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/t/05_serializer_and_resource.t b/t/05_serializer_and_resource.t new file mode 100644 index 0000000..fdfee4a --- /dev/null +++ b/t/05_serializer_and_resource.t @@ -0,0 +1,49 @@ +use strict; +use warnings; +use Dancer::ModuleLoader; +use Test::More import => ['!pass']; + +# Dancer::Test had a bug in version previous 1.3059_01 that prevent this test +# from running correctly. +my $dancer_version = eval "\$Dancer::VERSION"; +$dancer_version =~ s/_//g; +plan skip_all => "Dancer 1.3059_01 is needed for this test (you have $dancer_version)" + if $dancer_version < 1.305901; + +{ + package Webservice; + use Dancer; + use Dancer::Plugin::REST; + + setting environment => 'testing'; + prepare_serializer_for_format; + resource user => + get => sub { [ id => params->{id}, format => params->{format} ] }, + delete => sub { [ id => params->{id}, format => params->{format} ] }, + create => sub { [ user => params->{user}, format => params->{format} ] }, + update => sub { [ user => params->{user}, format => params->{format} ] }; +} + +use Dancer::Test; +plan tests => 4; + +my $r = dancer_response GET => '/user/42.json'; + +is $r->{content}, '["id","42","format","json"]' + => "'id' and 'format' params are properly set for resource during GET"; + +$r = dancer_response POST => '/user.json', { params => { user => 'test' } }; + +is $r->{content}, '["user","test","format","json"]' + => "'user' and 'format' params properly set for resource during POST"; + +$r = dancer_response PUT => '/user/1.json', { params => { user => 'anothertest' } }; + +is $r->{content}, '["user","anothertest","format","json"]' + => "'user' and 'format' params properly set for resource during PUT"; + +$r = dancer_response DELETE => '/user/6.json'; + +is $r->{content}, '["id","6","format","json"]' + => "'id' and 'format' params properly set for resource during DELETE"; + -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdancer-plugin-rest-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits