6 use lib 't/lib', 'lib';
12 eval "use Module::Refresh;";
13 plan skip_all => "Module::Refresh is required for this test" if $@;
18 First lets test some of our simple example modules ...
22 my @modules = qw[Foo Bar MyMooseA MyMooseB MyMooseObject];
27 is($_->meta->name, $_, '... initialized the meta correctly');
30 Module::Refresh->new->refresh_module($_ . '.pm')
31 } '... successfully refreshed ' . $_;
36 Now, lets try something a little trickier
37 and actually change the module itself.
41 my $test_module_file = 'TestBaz.pm';
43 my $test_module_source_1 = q|
46 has 'foo' => (is => 'ro', isa => 'Int');
50 my $test_module_source_2 = q|
54 has 'foo' => (is => 'rw', isa => 'Int');
59 open FILE, ">", $test_module_file
60 || die "Could not open $test_module_file because $!";
61 print FILE $test_module_source_1;
66 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
67 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
68 ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo');
71 open FILE, ">", $test_module_file
72 || die "Could not open $test_module_file because $!";
73 print FILE $test_module_source_2;
78 Module::Refresh->new->refresh_module($test_module_file)
79 } '... successfully refreshed ' . $test_module_file;
81 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
82 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
83 ok(TestBaz->isa('Foo'), '... TestBaz is a Foo');
85 unlink $test_module_file;