Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 21374
Status: rejected
Priority: 0/
Queue: Test-WWW-Mechanize

People
Owner: Nobody in particular
Requestors: LGODDARD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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; }
Of course, 'status' ought to be 'code' - bad cut'n'paste will kill me one day.