Skip to content

Commit

Permalink
Fix test suite with new pretty option of the JSON serializer
Browse files Browse the repository at this point in the history
With previous commits, the JSON serializer uses the pretty flag
in development environement, which happens to be the default one.

So every test get a pretty JSON, with \n and indentations, of course they don't
expect that, and fail.

Now, all these test set the env to production to avoid prettyness of the
serializer.
  • Loading branch information
Alexis Sukrieh committed Jan 28, 2011
1 parent 44a6811 commit 1a43674
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions t/12_response/03_charset.t
Expand Up @@ -9,6 +9,8 @@ use Encode;

plan tests => 16;

set environment => 'production';

my $res = Dancer::Response->new(headers => [ 'Content-Type' => 'text/html' ], content_type => 'text/html');
my $psgi_res = Dancer::Handler->render_response($res);
is(@$psgi_res, 3);
Expand Down
2 changes: 2 additions & 0 deletions t/14_serializer/04_mutable.t
Expand Up @@ -13,6 +13,8 @@ BEGIN {

plan tests => 17;

set environment => 'production';

ok(setting('serializer' => 'Mutable'), "serializer Mutable loaded");
my $s = Dancer::Serializer->engine;

Expand Down
4 changes: 4 additions & 0 deletions t/14_serializer/05_live.t
Expand Up @@ -2,6 +2,9 @@ use strict;
use warnings;
use Test::More import => ['!pass'];

use Carp;
$Carp::Verbose = 1;

BEGIN {
use Dancer::ModuleLoader;

Expand All @@ -18,6 +21,7 @@ use LWP::UserAgent;
use HTTP::Request;

plan tests => 30;
set environment => 'production';

test_json();
test_yaml();
Expand Down
1 change: 1 addition & 0 deletions t/14_serializer/06_serialize_response.t
Expand Up @@ -15,6 +15,7 @@ my $json = JSON::encode_json($data);
use Dancer ':syntax';

set serializer => 'JSON';
set environment => 'production';

get '/data' => sub {
$data;
Expand Down
1 change: 1 addition & 0 deletions t/14_serializer/14_show_errors.t
Expand Up @@ -36,6 +36,7 @@ Test::TCP::test_tcp(
setting port => $port;
setting access_log => 0;
setting serializer => 'JSON';
set environment => 'production';

get '/with_errors' => sub {
setting show_errors => 1;
Expand Down
2 changes: 1 addition & 1 deletion t/lib/TestSerializer.pm
Expand Up @@ -5,7 +5,7 @@ use Dancer;
setting serializer => 'JSON';

get '/json' => sub {
to_json({foo => 'bar'}, pretty => 1);
to_json({foo => 'bar'}, { pretty => 1});
};

get '/' => sub {
Expand Down

0 comments on commit 1a43674

Please sign in to comment.