use Test::More; use Test::Mojo; do "ex/qaptcha.pl"; my $t = Test::Mojo->new; $t->get_ok('/inline')->status_is(200) ->content_like(qr'Hello Qaptcha!') ->content_like(qr'script'); $t->get_ok('/')->status_is(200) ->content_like(qr'Hello Qaptcha!') ->content_like(qr'script') ->content_like(qr'QapTcha - jQuery Plugin') ->content_like(qr'QapTcha CSS'); $t->get_ok('/images/bg_draggable_qaptcha.jpg')->status_is(200) ->content_type_is('image/jpeg'); $t->post_ok('/' => {DNT => 1} => form => {firstname => 'hans', lastname => 'test'}) ->status_is(200) ->text_is('div#q_session' => '') ->text_is('div#f_processed' => 'form data not processed'); $t->post_ok('/qaptcha' => {DNT => 1} => form => {action => 'qaptcha', qaptcha_key => 'ABC'}) ->status_is(200) ->json_is({error => 0}); $t->post_ok('/' => {DNT => 1} => form => {firstname => 'hans', lastname => 'test'}) ->status_is(200) ->text_is('div#q_session' => 'ABC') ->text_is('div#f_processed' => 'form data processed'); $t->post_ok('/' => {DNT => 1} => form => {firstname => 'hans', lastname => 'test'}) ->status_is(200) ->text_is('div#q_session' => '') ->text_is('div#f_processed' => 'form data not processed'); done_testing(); __DATA__ @@ layouts/default.html.ep %= qaptcha_include; %= content; @@ index.html.ep %= layout 'default'; 'Hello Qaptcha!'
%= c.session('qaptcha_key');
%= $form_processing;