Make mech tests skip unless mech new enough. RT#55303
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / live_app.t
CommitLineData
790f9ddb 1#!/usr/bin/perl
790f9ddb 2use strict;
3use warnings;
bd1101db 4
5use FindBin qw/$Bin/;
6use lib "$Bin/lib";
7
ed61ff6d 8use Test::More;
ed61ff6d 9BEGIN {
3aff571e 10 do {
11 eval { require Test::WWW::Mechanize::Catalyst }
12 and
13 Test::WWW::Mechanize::Catalyst->VERSION('0.51')
14 }
ed61ff6d 15 or plan skip_all =>
16 "Test::WWW::Mechanize::Catalyst is needed for this test";
17 plan tests => 4;
18}
790f9ddb 19use HTTP::Request;
861c2f44 20
21use Test::More;
790f9ddb 22use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
790f9ddb 23my $mech = Test::WWW::Mechanize::Catalyst->new;
790f9ddb 24$mech->get("http://localhost/moose");
513d8ab6 25is( $mech->status, 401, "status is 401" ) or die $mech->content;
ed61ff6d 26$mech->content_lacks( "foo", "no output" );
790f9ddb 27my $r = HTTP::Request->new( GET => "http://localhost/moose" );
28$r->authorization_basic(qw/foo s3cr3t/);
ed61ff6d 29$mech->request($r);
30is( $mech->status, 200, "status is 200" );
31$mech->content_contains( "foo", "foo output" );
513d8ab6 32