Navigation Menu

Skip to content

Commit

Permalink
cleaning up uses of use_ok()
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Apr 12, 2012
1 parent 118580d commit f06c56b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 45 deletions.
11 changes: 5 additions & 6 deletions t/click_ok.t
Expand Up @@ -2,17 +2,14 @@

use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 3;
use Test::Builder::Tester;

use Test::WWW::Mechanize ();

use lib 't';
use TestServer;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}


my $server = TestServer->new;
my $pid = $server->background;
my $server_root = $server->root;
Expand All @@ -26,3 +23,5 @@ SUBMIT_GOOD_FORM: {
}

$server->stop;

done_testing();
6 changes: 2 additions & 4 deletions t/has_tag.t
Expand Up @@ -2,13 +2,11 @@

use strict;
use warnings;
use Test::More tests => 16;
use Test::More tests => 15;
use Test::Builder::Tester;
use URI::file;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}
use Test::WWW::Mechanize ();

my $mech = Test::WWW::Mechanize->new();
isa_ok($mech,'Test::WWW::Mechanize');
Expand Down
8 changes: 3 additions & 5 deletions t/link_content.t
@@ -1,14 +1,12 @@
#!perl -Tw
#!perl -T

use strict;
use warnings;
use Test::More tests => 12;
use Test::More tests => 11;
use Test::Builder::Tester;
use URI::file;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}
use Test::WWW::Mechanize;

my $mech=Test::WWW::Mechanize->new();
isa_ok($mech,'Test::WWW::Mechanize');
Expand Down
11 changes: 4 additions & 7 deletions t/link_status.t
@@ -1,16 +1,13 @@
#!perl -Tw
#!perl -T

use strict;
use warnings;
use Test::More tests => 10;

use Test::More tests => 9;
use Test::Builder::Tester;
use URI::file;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}

use lib 't';
use Test::WWW::Mechanize ();

my $mech = Test::WWW::Mechanize->new( autocheck => 0 );
isa_ok( $mech,'Test::WWW::Mechanize' );
Expand Down
9 changes: 3 additions & 6 deletions t/links_ok.t
@@ -1,15 +1,12 @@
#!perl -Tw
#!perl -T

use strict;
use warnings;
use Test::More tests => 10;
use Test::More tests => 9;
use Test::Builder::Tester;
use URI::file;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}

use Test::WWW::Mechanize ();

my $mech=Test::WWW::Mechanize->new( autocheck => 0 );
isa_ok($mech,'Test::WWW::Mechanize');
Expand Down
31 changes: 14 additions & 17 deletions t/new.t
@@ -1,30 +1,27 @@
#!perl -Tw
#!perl -T

use warnings;
use strict;
use Test::More tests => 7;

BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}
use Test::More tests => 6;

NEW: {
my $m = Test::WWW::Mechanize->new;
isa_ok( $m, 'Test::WWW::Mechanize' );
}
use Test::WWW::Mechanize ();

my $mech = Test::WWW::Mechanize->new;
isa_ok( $mech, 'Test::WWW::Mechanize' );

# Stolen from WWW::Mechanize's t/new.t.
# If this works, then subclassing works OK.
CONSTRUCTOR_PARMS: {
my $alias = 'Windows IE 6';
my $m = Test::WWW::Mechanize->new( agent => $alias );
isa_ok( $m, 'Test::WWW::Mechanize' );
can_ok( $m, 'request' );
is( $m->agent, $alias, q{Aliases don't get translated in the constructor} );
my $mech = Test::WWW::Mechanize->new( agent => $alias );
isa_ok( $mech, 'Test::WWW::Mechanize' );
can_ok( $mech, 'request' );
is( $mech->agent, $alias, q{Aliases don't get translated in the constructor} );

$m->agent_alias( $alias );
like( $m->agent, qr/^Mozilla.+compatible.+Windows/, 'Alias sets the agent' );
$mech->agent_alias( $alias );
like( $mech->agent, qr/^Mozilla.+compatible.+Windows/, 'Alias sets the agent' );

$m->agent( 'ratso/bongo v.43' );
is( $m->agent, 'ratso/bongo v.43', 'Can still set the agent' );
$mech->agent( 'ratso/bongo v.43' );
is( $mech->agent, 'ratso/bongo v.43', 'Can still set the agent' );
}

0 comments on commit f06c56b

Please sign in to comment.