Permalink
Browse files

Merge branch 'release/1.3069_02'

  • Loading branch information...
2 parents dbac86f + 015b9d8 commit 5c1e193de994c6508a15e4cf4a63fed74ed3d853 @xsawyerx xsawyerx committed Jul 10, 2011
View
@@ -47,3 +47,4 @@ META.yml
MYMETA.yml
nytprof.out
pm_to_blib
+MYMETA.json
View
@@ -1,3 +1,9 @@
+1.3069_02 10.07.2011
+
+ [ BUG FIXES ]
+ * Fix a bunch of cpan testers reports
+ (Alberto Simões)
+
1.3069_01 07.07.2011
[ BUG FIXES ]
View
@@ -5,7 +5,7 @@ use warnings;
use Carp;
use Cwd 'realpath';
-our $VERSION = '1.3069_01';
+our $VERSION = '1.3069_02';
our $AUTHORITY = 'SUKRIA';
use Dancer::App;
@@ -63,9 +63,9 @@ sub retrieve {
return unless -f $session_file;
- open my $fh, '<', $session_file or die "Can't open '$session_file': $!\n";
+ open my $fh, '+<', $session_file or die "Can't open '$session_file': $!\n";
flock $fh, LOCK_EX or die "Can't lock file '$session_file': $!\n";
- my $content = YAML::LoadFile($session_file);
+ my $content = YAML::LoadFile($fh);
close $fh or die "Can't close '$session_file': $!\n";
return $content;
@@ -14,6 +14,7 @@ my @modules = qw(
Test::TCP
Test::More
JSON
+ YAML
Clone
Plack
XML::Simple
@@ -57,7 +57,7 @@ eval { $session = Dancer::Session::YAML->create() };
my $error = $@;
like(
$@,
- qr/Can't open .* No such file or directory/,
+ qr{Can't open '.*\.*yml':.*},
'session dir was not recreated',
);
@@ -4,55 +4,59 @@ use warnings;
use Dancer ':tests';
use Dancer::Test;
-plan tests => 11;
-
-SKIP: {
- skip 'YAML is needed to run this test', 10
+BEGIN {
+ plan skip_all => "need JSON"
unless Dancer::ModuleLoader->load('JSON');
- set 'serializer' => 'JSON', 'show_errors' => 1;
-
- get '/' => sub { { foo => 'bar' } };
- post '/' => sub { params };
- put '/' => sub { param("id") };
- get '/json' => sub { to_json( { foo => 'bar' } ) };
- get '/error' => sub { send_error( { foo => 42 }, 401 ) };
- get '/error_bis' => sub { send_error( 42, 402 ) };
-
- response_content_is [ PUT => '/',
- {
- body => '{"id": "foo"}' ,
- headers => [ 'Content-Type' => 'application/json' ],
- }
- ] => 'foo';
-
-
- for ( '/', '/json' ) {
- my $res = dancer_response( GET => '/' );
- is $res->header('Content-Type'), 'application/json';
- like $res->content, qr/"foo" : "bar"/;
- }
-
- my $res = dancer_response(
- POST => '/',
- {
- params => { foo => 1 },
- headers => [ 'Content-Type' => 'application/json' ]
- }
- );
- is_deeply(
- from_json( $res->content ),
- { foo => 1 },
- "data is correctly deserialized"
- );
- is $res->header('Content-Type'), 'application/json',
- 'goodcontent type set in response';
-
- $res = dancer_response( GET => '/error' );
- is $res->status, 401;
- is_deeply( from_json( $res->content ), { foo => 42 } );
-
- $res = dancer_response( GET => '/error_bis' );
- is $res->status, 402;
- is_deeply( from_json( $res->content ), { error => 42 } );
+ plan tests => 11;
+}
+
+set 'serializer' => 'JSON', 'show_errors' => 1;
+
+get '/' => sub { { foo => 'bar' } };
+post '/' => sub { params };
+put '/' => sub { param("id") };
+get '/json' => sub { to_json( { foo => 'bar' } ) };
+get '/error' => sub { send_error( { foo => 42 }, 401 ) };
+get '/error_bis' => sub { send_error( 42, 402 ) };
+
+response_content_is [ PUT => '/',
+ {
+ body => '{"id": "foo"}' ,
+ headers => [ 'Content-Type' => 'application/json' ],
+ }
+ ] => 'foo';
+
+
+for ( '/', '/json' ) {
+ my $res = dancer_response( GET => '/' );
+ is $res->header('Content-Type'), 'application/json';
+ like $res->content, qr/"foo" : "bar"/;
}
+
+my $res = dancer_response
+ (
+ POST => '/',
+ {
+ params => { foo => 1 },
+ headers => [ 'Content-Type' => 'application/json' ]
+ }
+ );
+
+is_deeply(
+ from_json( $res->content ),
+ { foo => 1 },
+ "data is correctly deserialized"
+ );
+
+is $res->header('Content-Type'), 'application/json',
+ 'goodcontent type set in response';
+
+$res = dancer_response( GET => '/error' );
+is $res->status, 401;
+is_deeply( from_json( $res->content ), { foo => 42 } );
+
+$res = dancer_response( GET => '/error_bis' );
+is $res->status, 402;
+is_deeply( from_json( $res->content ), { error => 42 } );
+
@@ -17,6 +17,7 @@ plan tests => 3 + @cases;
use Cwd qw(cwd);
use Dancer;
+use Dancer::FileUtils;
my $dir = File::Temp::tempdir(CLEANUP => 1, TMPDIR => 1);
my $cwd = cwd;
@@ -46,5 +47,6 @@ like($help, qr{Usage: .* dancer .* options}sx, 'dancer (without parameters)');
foreach my $case (@cases) {
my $create_here = qx{$cmd -x -a $case 2> err};
- ok (-z 'err', "create $case did not return error");
+ is scalar(Dancer::FileUtils::read_file_content('err')) => '',
+ "create $case did not return error";
}

0 comments on commit 5c1e193

Please sign in to comment.