@@ -152,38 +152,38 @@ the following modules can be used:
152152=back
153153
154154Taking the previous test, assuming it actually creates and uses
155- cookies for sessions:
155+ cookies for sessions (see L<cookie|Dancer2::Manual/"Setting and Updating
156+ Cookies"> and perhaps L<Dancer2::Session::Cookie> for more information on how
157+ to do that):
156158
157159 # ... all the use statements
158160 use HTTP::Cookies;
159161
160162 my $jar = HTTP::Cookies->new;
161163 my $test = Plack::Test->create( MyApp->to_app );
162164
163- subtest 'A empty request' => sub {
164- my $res = $test->request( GET '/' );
165- ok( $res->is_success, 'Successful request' );
166- is( $res->content '{}', 'Empty response back' );
165+ subtest 'Request with invalid user' => sub {
166+ my $req = GET '/sawyer_x';
167+ $jar->add_cookie_header($req);
168+ my $res = $test->request($req);
169+ ok !$res->is_success, 'Request failed';
167170 $jar->extract_cookies($res);
168- ok( $jar->as_string, 'We have cookies!' );
171+
172+ ok !$jar->as_string, 'All cookies deleted';
169173 };
170174
171175 subtest 'Request with user' => sub {
172- my $req = GET '/?user=sawyer_x ';
176+ my $req = GET '/jason ';
173177 $jar->add_cookie_header($req);
174178 my $res = $test->request($req);
175- ok( $res->is_success, 'Successful request' );
176- is( $res->content '{"user":"sawyer_x"}', 'Empty response back' );
179+ ok $res->is_success, 'Successful request';
177180 $jar->extract_cookies($res);
178181
179- ok( ! $jar->as_string, 'All cookies deleted' ) ;
182+ ok ! $jar->as_string, 'All cookies deleted';
180183 };
181184
182185 done_testing();
183186
184- Here a cookie jar is created, all requests and responses, existing
185- cookies, as well as cookies that were deleted by the response, are checked.
186-
187187If you don't want to use an entire user agent for this test, you can use
188188L<HTTP::Cookies> to store cookies and then retrieve them:
189189
0 commit comments