[Bps-public-commit] r11232 - in WebChart: t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Mar 27 09:59:06 EDT 2008


Author: sunnavy
Date: Thu Mar 27 09:59:05 2008
New Revision: 11232

Modified:
   WebChart/lib/WebChart.pm
   WebChart/t/webchart.t

Log:
make type and data mandatory

Modified: WebChart/lib/WebChart.pm
==============================================================================
--- WebChart/lib/WebChart.pm	(original)
+++ WebChart/lib/WebChart.pm	Thu Mar 27 09:59:05 2008
@@ -82,6 +82,12 @@
 
 sub render {
     my $self = shift;
+    my %args = @_;
+
+    for (qw/type data/) {
+        croak "need to set $_ arg" unless $args{$_};
+    }
+
     return $self->renderer->render(
         (
             map { $_ => $self->$_ } (

Modified: WebChart/t/webchart.t
==============================================================================
--- WebChart/t/webchart.t	(original)
+++ WebChart/t/webchart.t	Thu Mar 27 09:59:05 2008
@@ -3,10 +3,9 @@
 
 use lib 't/lib';
 use WebChart;
-use WebChart::Test qw/is_file/;
 use File::Spec;
 
-use Test::More tests => 24;
+use Test::More tests => 26;
 
 my $wc      = WebChart->new;
 my %default = (
@@ -62,7 +61,7 @@
     [ 22,     25,     20,     21 ],        # second data set
 ];
 
-%args = ( data => $data );
+%args = ( data => $data, type => 'bars' );
 
 my %return = $wc->render(%args);
 is_deeply(
@@ -73,6 +72,7 @@
 
 %args = (
     data        => $data,
+    type        => 'bars',
     width       => 800,
     height      => 600,
     css_class   => 'foo bar',
@@ -83,6 +83,12 @@
 is_deeply(
     \%return,
     { %default, %args },
-"args can be supplied that overwrides the WebChart object's default value"
+    "args can be supplied that overwrides the WebChart object's default value"
 );
 
+eval { $wc->render( type => 'bars' ); };
+ok( $@, 'data arg is mandatory for render sub' );
+
+eval { $wc->render( data => $data ); };
+ok( $@, 'setting type arg is mandatory for render sub' );
+



More information about the Bps-public-commit mailing list