From: Karen Etheridge Date: Thu, 7 Feb 2013 23:35:20 +0000 (-0800) Subject: reuse common testing code in a base class X-Git-Tag: v0.08~1^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=233548ddae7e1b8af9ccdf3943c4973bd653d2fe;p=gitmo%2FMooseX-ConfigFromFile.git reuse common testing code in a base class --- diff --git a/dist.ini b/dist.ini index 52735af..85e3fc2 100644 --- a/dist.ini +++ b/dist.ini @@ -28,6 +28,7 @@ version_regexp = ^v([\d._]+)(-TRIAL)?$ [AutoPrereqs] skip = ^A$ +skip = ^Generic$ [InstallGuide] [MetaConfig] diff --git a/t/05_default_sub.t b/t/05_default_sub.t index c91a777..cfe826b 100644 --- a/t/05_default_sub.t +++ b/t/05_default_sub.t @@ -2,7 +2,7 @@ use strict; use warnings FATAL => 'all'; use Test::Requires 'MooseX::SimpleConfig'; # skip all if not reuqired -use Test::More tests => 10; +use Test::More tests => 11; use Test::Fatal; use Test::Deep '!blessed'; use Test::NoWarnings 1.04 ':early'; @@ -17,13 +17,19 @@ my %default_sub; package Generic; use Moose; with 'MooseX::SimpleConfig'; - sub get_config_from_file { } + sub get_config_from_file + { + my ($class, $file) = @_; + $loaded_file{$file}++; + +{} + } } is( exception { my $obj = Generic->new_with_config; is($obj->configfile, undef, 'no configfile set'); + cmp_deeply(\%loaded_file, {}, 'no files loaded'); }, undef, 'no exceptions', @@ -35,13 +41,7 @@ is( { package OverriddenDefault; use Moose; - with 'MooseX::SimpleConfig'; - sub get_config_from_file - { - my ($class, $file) = @_; - $loaded_file{$file}++; - +{} - } + extends 'Generic'; has '+configfile' => ( default => 'OverriddenDefault file', ); @@ -62,13 +62,7 @@ is( { package OverriddenMethod; use Moose; - with 'MooseX::SimpleConfig'; - sub get_config_from_file { - my ($class, $file) = @_; - $loaded_file{$file}++; - +{} - } - + extends 'Generic'; around configfile => sub { my $class = blessed($_[1]) || $_[1]; $default_sub{$class}++;