7 $ENV{GITALIST_CONFIG} = $Bin;
8 $ENV{GITALIST_REPO_DIR} = '';
10 use Catalyst::Test qw/Gitalist/;
14 our @EXPORT = (@Test::More::EXPORT, @Test::Exception::EXPORT, qw/
32 goto \&Exporter::import;
38 require Test::WWW::Mechanize::Catalyst;
39 require WWW::Mechanize::TreeBuilder;
40 my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'Gitalist');
41 WWW::Mechanize::TreeBuilder->meta->apply($mech,
42 tree_class => 'HTML::TreeBuilder::XPath',
46 constant->import('MECH', $mech );
49 # Rechecking the same link multiple times is slow and lame!
50 # Nicked this from WWW::Mechanize and memoized it...
52 sub Test::WWW::Mechanize::Catalyst::page_links_ok {
56 $desc = 'All links ok' unless defined $desc;
58 my @links = $self->followable_links();
59 my @urls = Test::WWW::Mechanize::_format_links(\@links);
61 my @failures = $self->_check_links_status( [ grep { ! $seen_links{$_}++ } @urls ] );
62 my $ok = (@failures==0);
65 diag( $_ ) for @failures;
73 my $request = "/$uri";
74 $request .= "?$qs" if defined $qs;
75 my $response = request($request);
76 ok($response->is_success || $response->is_redirect, "ok $request");
78 my $res = MECH()->get($request);
79 ok $res->is_success, "ok mech $request (" . $res->code . ')';
80 MECH()->page_links_ok("All links ok from $request")
81 if $res->content_type =~ m|text/html|;
88 my $to_curry = shift || \&test_uri;
91 $to_curry->("$prefix/$uri", @_);