6 use lib 't/lib', 'lib';
12 use File::Temp 'tempdir';
15 'Module::Refresh' => '0.01', # skip all if not installed
20 First lets test some of our simple example modules ...
24 my @modules = qw[Foo Bar MyMooseA MyMooseB MyMooseObject];
29 is($_->meta->name, $_, '... initialized the meta correctly');
32 Module::Refresh->new->refresh_module($_ . '.pm')
33 }, undef, '... successfully refreshed ' );
38 Now, lets try something a little trickier
39 and actually change the module itself.
43 my $dir = tempdir( "MooseTest-XXXXX", CLEANUP => 1, TMPDIR => 1 );
46 my $test_module_file = File::Spec->catdir($dir, 'TestBaz.pm');
48 my $test_module_source_1 = q|
51 has 'foo' => (is => 'ro', isa => 'Int');
55 my $test_module_source_2 = q|
59 has 'foo' => (is => 'rw', isa => 'Int');
64 open FILE, ">", $test_module_file
65 || die "Could not open $test_module_file because $!";
66 print FILE $test_module_source_1;
71 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
72 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
73 ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo');
76 open FILE, ">", $test_module_file
77 || die "Could not open $test_module_file because $!";
78 print FILE $test_module_source_2;
83 Module::Refresh->new->refresh_module('TestBaz.pm')
84 }, undef, '... successfully refreshed ' );
86 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
87 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
88 ok(TestBaz->isa('Foo'), '... TestBaz is a Foo');
90 unlink $test_module_file;