Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
104 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package Moxy::Request; | ||
use strict; | ||
use warnings; | ||
use base qw/Plack::Request/; | ||
|
||
sub as_http_request { | ||
my $self = shift; | ||
return HTTP::Request->new( | ||
$self->method, | ||
$self->uri, | ||
$self->headers, | ||
$self->raw_body, | ||
); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use strict; | ||
use warnings; | ||
use utf8; | ||
use Test::Requires 'Test::WWW::Mechanize::PSGI'; | ||
use Test::More; | ||
use Moxy; | ||
use FindBin; | ||
use File::Spec::Functions qw/catfile/; | ||
|
||
binmode Test::More->builder->$_, ":utf8" for qw/output failure_output todo_output/; | ||
|
||
my $moxy = Moxy->new( | ||
{ | ||
global => { | ||
assets_path => catfile( $FindBin::Bin, '..', 'assets' ), | ||
'log' => { | ||
level => 'info', | ||
}, | ||
session => { | ||
store => { | ||
module => 'Test', | ||
config => {}, | ||
}, | ||
} | ||
}, | ||
plugins => [ | ||
{ module => 'UserAgentSwitcher' }, | ||
], | ||
} | ||
); | ||
my $app = $moxy->to_app(); | ||
|
||
# ------------------------------------------------------------------------- | ||
|
||
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->get_ok('/http://wassr.jp/'); | ||
$mech->content_contains('お気軽'); | ||
|
||
done_testing; |