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