PageRenderTime 22ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/t/html_attr.t

http://github.com/gshank/html-formhandler
text | 24 lines | 20 code | 4 blank | 0 comment | 0 complexity | 50c5632e126364d4026f97837d915c53 MD5 | raw file
 1use strict;
 2use warnings;
 3use Test::More;
 4
 5{
 6    package Test::Form;
 7    use HTML::FormHandler::Moose;
 8    extends 'HTML::FormHandler';
 9
10    has '+html_attr' => ( default => sub { { method => 'GET', class => 'hfh test_form', target => '_blank' } } );
11    has_field 'foo' => ( html_attr => { arbitrary => 'something' } );
12    has_field 'bar' => ( html_attr => { writeonly => 1 } );
13}
14
15my $form = Test::Form->new;
16$form->process( params => {} );
17my $rendered = $form->render;
18like( $rendered, qr/class="hfh test_form"/, 'form has class' );
19like( $rendered, qr/method="GET"/, 'form has html method' );
20like( $rendered, qr/arbitrary="something"/, 'field has arbitrary attribute' );
21like( $rendered, qr/writeonly="1"/, 'field has writeonly attribute' );
22like( $rendered, qr/target="_blank"/, 'form has target attribute');
23
24done_testing;