Subject: | Kindof patch - status_is |
I find this useful since I use a lot of weird HTTP status codes (web
dav, etc)
=head2 $mech->status_is($url, $code, [ \%LWP_options ,] $desc)
Like C<get_ok>, but accepts accepts a status code to match against the
code recieved from the server. Third agument is as C<get_ok>'s second.
Like well-behaved C<*_ok()> functions, it returns true if the test
passed,
or false if not.
=cut
sub status_is {
my $self = shift;
my $url = shift;
my $status = shift;
my $desc;
my %opts;
if ( @_ ) {
my $flex = shift; # The flexible argument
if ( !defined( $flex ) ) {
$desc = shift;
}
elsif ( ref $flex eq 'HASH' ) {
%opts = %$flex;
$desc = shift;
}
elsif ( ref $flex eq 'ARRAY' ) {
%opts = @$flex;
$desc = shift;
}
else {
$desc = $flex;
}
} # parms left
$self->get( $url, %opts );
if ($self->response and $self->status){
$Test->is_num( $self->status, $status, $desc )
} else {
$Test->diag( "Internal Test error");
}
return $ok;
}