6 use lib 't/lib', 'lib';
12 use File::Temp 'tempdir';
15 eval "use Module::Refresh;";
16 plan skip_all => "Module::Refresh is required for this test" if $@;
21 First lets test some of our simple example modules ...
25 my @modules = qw[Foo Bar MyMooseA MyMooseB MyMooseObject];
30 is($_->meta->name, $_, '... initialized the meta correctly');
33 Module::Refresh->new->refresh_module($_ . '.pm')
34 } '... successfully refreshed ' . $_;
39 Now, lets try something a little trickier
40 and actually change the module itself.
44 my $dir = tempdir( "MooseTest-XXXXX", CLEANUP => 1, TMPDIR => 1 );
47 my $test_module_file = File::Spec->catdir($dir, 'TestBaz.pm');
49 my $test_module_source_1 = q|
52 has 'foo' => (is => 'ro', isa => 'Int');
56 my $test_module_source_2 = q|
60 has 'foo' => (is => 'rw', isa => 'Int');
65 open FILE, ">", $test_module_file
66 || die "Could not open $test_module_file because $!";
67 print FILE $test_module_source_1;
72 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
73 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
74 ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo');
77 open FILE, ">", $test_module_file
78 || die "Could not open $test_module_file because $!";
79 print FILE $test_module_source_2;
84 Module::Refresh->new->refresh_module($test_module_file)
85 } '... successfully refreshed ' . $test_module_file;
87 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
88 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
89 ok(TestBaz->isa('Foo'), '... TestBaz is a Foo');
91 unlink $test_module_file;