Skip to content

Instantly share code, notes, and snippets.

@sugar84
Created August 16, 2011 16:24
Show Gist options
  • Select an option

  • Save sugar84/1149473 to your computer and use it in GitHub Desktop.

Select an option

Save sugar84/1149473 to your computer and use it in GitHub Desktop.
mojo cookie bug or not?
use Mojolicious::Lite;
any '/' => sub {
my $self = shift;
my $name = $self->param("name");
#cookie with value
$self->cookie(baz => 'bar');
#cookie without value
$self->cookie(foo => '');
return defined $name
? $self->render(text => $self->cookie($name))
: $self->render(text => "hello");
};
use Test::Mojo;
use Test::More tests => 7;
my $t = Test::Mojo->new;
$t->get_ok('/');
$t->post_form_ok('/', { name => "baz"})
->status_is(200)
->content_is('bar')
;
$t->post_form_ok('/', { name => "foo"})
->status_is(200)
->content_is('')
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment