Created
February 25, 2014 12:06
-
-
Save memememomo/9207662 to your computer and use it in GitHub Desktop.
Test::Mojoでアップロード処理をテストする ref: http://qiita.com/memememomo/items/023c00ba9fe1e3f8f658
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
use strict; | |
use warnings; | |
use utf8; | |
use Encode; | |
use Test::Mojo; | |
use Test::More; | |
use File::Basename; | |
use Mojo::Asset::File; | |
$ENV{MOJO_HOME} = dirname(__FILE__) . '/../'; | |
require "$ENV{MOJO_HOME}/myapp.pl"; | |
my $t = Test::Mojo->new; | |
# アップロードする画像ファイル読み込み | |
my $asset = Mojo::Asset::File->new(path => dirname(__FILE__) . '/31683776.gif'); | |
$t->post_ok('/upload' => form => { | |
# ハッシュでアップロードするファイルの情報を指定する | |
image => { | |
filename => '31683776.gif', | |
'Content-Type' => 'image/gif', | |
content => $asset->slurp, | |
}, | |
}) | |
->status_is(302); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment