Permalink
Browse files

fixedd broken test. this test depended on wassr.jp, but that is gone

away!
  • Loading branch information...
tokuhirom committed Nov 6, 2012
1 parent a662e1b commit f7d74f59e799fcf5e57bb1d7f5b972f9d5b1a309
Showing with 25 additions and 2 deletions.
  1. +25 −2 t/mech.t
View
@@ -1,11 +1,12 @@
use strict;
use warnings;
use utf8;
-use Test::Requires 'Test::WWW::Mechanize::PSGI';
+use Test::Requires 'Test::WWW::Mechanize::PSGI', 'HTTP::Server::PSGI', 'Test::TCP';
use Test::More;
use Moxy;
use FindBin;
use File::Spec::Functions qw/catfile/;
+use Test::TCP;
binmode Test::More->builder->$_, ":utf8" for qw/output failure_output todo_output/;
@@ -14,13 +15,35 @@ my $app = $moxy->to_app();
# -------------------------------------------------------------------------
+my $server = Test::TCP->new(
+ code => sub {
+ my $port = shift;
+ my $server = HTTP::Server::PSGI->new(
+ host => '127.0.0.1',
+ port => $port,
+ timeout => 10,
+ );
+ $server->run(sub {
+ no utf8;
+ my $content = '<html><head></head><body>お気軽メッセージングハブ</body></html>';
+ return [200, [
+ 'Content-Type' => 'text/html; charset=utf-8',
+ 'Content-Length' => length($content)
+ ], [$content]];
+ });
+ },
+);
+my $port = $server->port;
+
+# -------------------------------------------------------------------------
+
my $mech = Test::WWW::Mechanize::PSGI->new(app => $app);
$mech->get('/');
is $mech->res->code(), 401;
$mech->credentials('oh', 'my god');
$mech->get_ok('/');
$mech->content_contains('http%3A%2F%2Fuaswitcher.moxy%2F', "user agent switcher's url is converted");
-$mech->get_ok('/http://wassr.jp/');
+$mech->get_ok("/http://127.0.0.1:$port/");
$mech->content_contains('お気軽');
done_testing;

0 comments on commit f7d74f5

Please sign in to comment.