From: Tomas Doran Date: Fri, 13 Aug 2010 14:06:50 +0000 (+0100) Subject: Refactor tests X-Git-Tag: 0.08~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b519d9c15e6a8bb7cc88528c175a612fa04c144;p=gitmo%2FMooseX-SimpleConfig.git Refactor tests --- diff --git a/Makefile.PL b/Makefile.PL index 7f1e543..f1d0efc 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,6 +10,8 @@ requires 'Moose' => '0.35'; requires 'MooseX::ConfigFromFile' => '0.02'; requires 'Config::Any' => '0.13'; +test_requires 'Test::More' => '0.88'; + # Rebuild README for maintainers system("pod2text lib/MooseX/SimpleConfig.pm >README") and die if $Module::Install::AUTHOR; diff --git a/t/11default.t b/t/11default.t index 1c17662..0011e35 100644 --- a/t/11default.t +++ b/t/11default.t @@ -5,9 +5,11 @@ use warnings; use lib 't/lib'; use lib '../t/lib'; - +use Test::More; +our @classes; BEGIN { - use Test::More; + + @classes = qw/ MXDefaultConfigTest MXDefaultMultipleConfigsTest /; eval "use YAML::Syck ()"; if($@) { @@ -16,11 +18,8 @@ BEGIN { plan skip_all => "YAML or YAML::Syck required for this test"; } } - - plan tests => 7; - use_ok('MXDefaultConfigTest'); - use_ok('MXDefaultWithSubConfigTest'); + use_ok($_) for @classes; } # Can it load a simple YAML file with the options @@ -31,8 +30,11 @@ BEGIN { print $test_yaml "direct_attr: 123\ninherited_ro_attr: asdf\nreq_attr: foo\n"; close($test_yaml); +} + +foreach my $class (@classes) { my $foo = eval { - MXDefaultConfigTest->new_with_config(); + $class->new_with_config(); }; ok(!$@, 'Did not die with good YAML configfile') or diag $@; @@ -40,12 +42,8 @@ BEGIN { is($foo->req_attr, 'foo', 'req_attr works'); is($foo->direct_attr, 123, 'direct_attr works'); is($foo->inherited_ro_attr, 'asdf', 'inherited_ro_attr works'); - - $foo = eval { - MXDefaultWithSubConfigTest->new_with_config(); - }; - ok(!$@, 'Did not die with good YAML configfile') - or diag $@; } +done_testing; + END { unlink('test.yaml') } diff --git a/t/lib/MXDefaultWithSubConfigTest.pm b/t/lib/MXDefaultMultipleConfigsTest.pm similarity index 74% rename from t/lib/MXDefaultWithSubConfigTest.pm rename to t/lib/MXDefaultMultipleConfigsTest.pm index 7703775..0319e52 100644 --- a/t/lib/MXDefaultWithSubConfigTest.pm +++ b/t/lib/MXDefaultMultipleConfigsTest.pm @@ -1,4 +1,4 @@ -package MXDefaultWithSubConfigTest; +package MXDefaultMultipleConfigsTest; use Moose; with 'MooseX::SimpleConfig'; @@ -9,7 +9,6 @@ has 'direct_attr' => (is => 'ro', isa => 'Int'); has 'req_attr' => (is => 'rw', isa => 'Str', required => 1); has '+configfile' => ( default => sub { [ 'test.yaml' ] } ); -#has '+configfile' => ( default => 'test.yaml' ); no Moose; 1;