improving doc part3 including some fixes found during code review while documenting
[WWW-Mechanize-Script.git] / lib / WWW / Mechanize / Script / Plugin / StatusTest.pm
blob294bc19a66f8d5886b63413d61598fd839aed6a2
1 package WWW::Mechanize::Script::Plugin::StatusTest;
3 use strict;
4 use warnings;
6 use parent qw(WWW::Mechanize::Script::Plugin);
8 # ABSTRACT: prove expected HTTP status of the response
10 our $VERSION = '0.001_003';
12 use 5.014;
14 =method check_value_names()
16 Returns qw(response).
18 =cut
20 sub check_value_names
22 return qw(response);
25 =method check_response(\%check,$mech)
27 This methods proves whether the HTTP status code of the response matches the
28 value configured in I<response> and accumulates I<response_code> into I<$code>
29 when not.
31 Return the accumulated I<$code> and appropriate constructed message, if
32 coparisation failed.
34 =cut
36 sub check_response
38 my ( $self, $check, $mech ) = @_;
40 my $response_code = 0 + $self->get_check_value( $check, "response" );
42 if ( $response_code != $mech->status() )
44 my $err_code = $self->get_check_value( $check, "response_code" ) // 1;
45 return ( $err_code, "response code " . $mech->status() . " != $response_code" );
48 return (0);