���������Ф��ʤ��������ɤ��Υ����ɤϰ��ڥƥ��Ȥ�񤫤ʤ��ä����ɡ�����Ϥ������̵�����ޤä�����äƼ����ȿ���뤷��Ruby�ΤȤ��Ϥ�����Spec�񤤤��Τ�Perl�ΤȤ��Ͻ񤫤ʤ����Ȥ��դ����Ƥ롢�Ȼפä��Τǥƥ��Ȥ�񤤤Ƥߤ뤳�Ȥˤ�����
���ƥƥ��Ȥ����ɡ�HTTP::Engine�ˤϤ������ƥ����ѤΥ��󥿡��ե��������Ѱդ���Ƥ��롣���ȡ��ƥ��ȥꥯ�����Ȥ���������⥸�塼���⤢�롣�ʤ�������㤢�äϴ�ñ����
- interface => { module => 'Test' } ��engine����
- HTTP::Engine::Test::Request��request����
- engine��run�᥽�åɤ˥ƥ��ȥꥯ�����Ȥ��ꤲ�Ƥ��
- �֤äƤ����쥹�ݥ󥹤�����å�����
�äƤ��ȤǤ��͡��狼��ޤ���
�ޤ�����ľ�˽񤤤Ƥߤ�
�������̾��ʤ��ΤǤϤäĤ����㤪����Udon::App��GET�ꥯ�����Ȥ��ꤲ��ƥ��ȤϤ���ʴ�����
use strict; use warnings; use FindBin qw($Bin); use Udon::App; use Test::More; use HTTP::Engine::Test::Request; plan tests => 1; my $app = Udon::App->new( { viewdir => "$Bin/../view" } ); my $engine = $app->setup_engine( { module => 'Test' } ); my $req = HTTP::Engine::Test::Request->new( uri => 'http://udon.example.org/', method => 'GET' ); my $res = $engine->run($req); is $res->code, 403, 'should return "Forbidden" when GET request';
�դࡢ�ޤ�����ñ�Ǥ��͡����ȤϤ���ʴ����Ǥɤ�ɤ�$req���äƤɤ�ɤ�$engine->run���Ƥ����ɤ���
Test::Declare
�Ȥ����ǡ�Test::More�Ϥޤ�������Ƥ��ǻȤ������¤����Ȥ�̵��������ɤ⡢���ʤ���RSpec���繥�����������ޤä�Objective-C�Υƥ��Ȥˤޤ�RSpec��Ȥä��㤦�ͤȤ��ƤϾ������ɤ�����������ʤ����Τ�Test::Declare�äƤ�Ĥ�ȤäƤߤ뤳�Ȥˤ�����
use strict; use warnings; use FindBin qw($Bin); use Udon::App; use Test::Declare; use HTTP::Engine::Test::Request; plan tests => blocks; describe 'GET' => run { my $res; init { my $app = Udon::App->new( { viewdir => "$Bin/../view" } ); my $engine = $app->setup_engine( { module => 'Test' } ); }; test 'should return "Forbidden"' => run { $res = $engine->run( HTTP::Engine::Test::Request->new( uri => 'http://udon.example.org/', method => 'GET' ), ); is $res->code, 403; }; };
�褦�����������ɤ����ɤ��ʤä������䡢�١��̤� describe �����äƤ뤫�鵤�����ä��󤸤�ʤ�������顣�����Ȥۤ顢�������Ʋ����Ф���ƥ��ȤʤΤ��������Ƚ��֤ȥƥ��ȥ����ɤȤ��ҤȤޤȤ�ˤʤäƤ������狼��䤹������󡣤͡�
������ɤ�������ɡ�setup_engine�Ȥ�HTTP::Engine::Test::Request->new�Ȥ������٤��������ʤ������Υ����ɤ��Ȱ�Ĥ����ñ¤¤¤Æ¤Ê¤ï¿½ï¿½ï¿½ï¿½ï¿½Þ¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½É¡ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½404�פ�Spec���餤�����夷�褦�Ȼפ��Ȥ���äȤ���ʤꤹ�롣����ʤ������Ʊ���ʤ�����鲿�٤�ñ¤¤ï¿½ï¿½ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½Ë¤ï¿½ï¿½ï¿½ï¿½ï¿½
Test::HTTP::Engine
����������Rack�ΤȤ���Rack::Test��Ȥä����Ū�ˤ��äѤꤷ�������㤢Ʊ����ˡ�Dz�褷�Ƥߤ���ɤ��󤸤�ʤ����������Ȼפ�Ω�ä�Ŭ���ˤ���ʤ�Τ��Ϥ��Ƥߤ���
package Test::HTTP::Engine; use strict; use warnings; use Exporter; use HTTP::Engine::Test::Request; our @ISA = qw(Exporter); our @EXPORT = qw(engine get); sub engine { die } sub get { my $path = shift; engine->run( HTTP::Engine::Test::Request->new( uri => "http://example.org/$path", method => 'GET' ), env => \%ENV ); } 1;
�ǡ������Ȥ��Ȥ��ä��Υƥ��ȤϤ����ʤ롣
use strict; use warnings; use FindBin qw($Bin); use Udon::App; use Test::Declare; use Test::HTTP::Engine; plan tests => blocks; # engine�������ϳƥƥ��ȤǾ�ñ¤¤ï¿½ï¿½ï¿½ï¿½Ñ¤ï¿½ï¿½ï¿½ no warnings 'redefine'; *Test::HTTP::Engine::engine = sub { my $app = Udon::App->new( { viewdir => "$Bin/../view" } ); $app->setup_engine( { module => 'Test' } ); }; describe 'GET' => run { test 'should return "Forbidden"' => run { is get('/')->code, 403; is get('/get')->code, 403; }; test 'should return "I\'m a teapot" with mode="prev"' => run { is get('/?mode=prev')->code, 418; }; test 'should return "Gone" with mode="next"' => run { is get('/?mode=next')->code, 410; }; };
���äѤꤷ��������äȥƥ������䤷�����ɤ��ä���긫�פ����������Ϥ��Ȥʤ�RSpec�Ǥ˶��դ����������뤾�����Ȥ�post�Ȥ�delete�Ȥ����äƤ���Rack::Test�Ǥ�ä��Τȶᤤ���Ȥ��Ǥ��롣�פ��դ��Ǻ�ä����ɰճ����ɤ��ʡ�
�ƥ��Ȥ��ñ�������դ��Ƥʤ��ǽ񤱤��
�Ȥ����櫓��Apache��ServerSimple�ǥ����Хץ�������Ω���夲���ꤷ�ʤ��Ƥ⥵���äȥ��ץ�Υƥ��Ȥ��������ä��ɤ��Ǥ��͡�����ʴ�ñ�ʤ�ǽ餫��ƥ��Ƚ񤱤�äƸ���줽���Ǥ��͡��䡢���ޤ��衣�����ȸ�Ǥ��ɤ󲰤Τ�Ĥˤ�ƥ����ɲä��Ȥ��ޤ��äơ��Ҥ���
�ɵ�
��ʬ�Ǥ�Test::HTTP::Engine::engine������֤�������Τ�̵����ʡ����ʤ󤫰㤦�ʡ��ȻפäƤ��顢yappo���󤫤�
engine {}; �� setup �����ۤ��������⡼
�ȤΤ��ȡ��Ȥ������Ǽ�ľ���档