6 use lib 't/lib', 'lib';
12 eval "use Module::Refresh;";
13 plan skip_all => "Module::Refresh is required for this test" if $@;
19 First lets test some of our simple example modules ...
23 my @modules = qw[Foo Bar MyMooseA MyMooseB MyMooseObject];
28 is($_->meta->name, $_, '... initialized the meta correctly');
31 Module::Refresh->new->refresh_module($_ . '.pm')
32 } '... successfully refreshed ' . $_;
37 Now, lets try something a little trickier
38 and actually change the module itself.
42 my $test_module_file = 'TestBaz.pm';
44 my $test_module_source_1 = q|
47 has 'foo' => (is => 'ro', isa => 'Int');
51 my $test_module_source_2 = q|
55 has 'foo' => (is => 'rw', isa => 'Int');
60 open FILE, ">", $test_module_file
61 || die "Could not open $test_module_file because $!";
62 print FILE $test_module_source_1;
67 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
68 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
69 ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo');
72 open FILE, ">", $test_module_file
73 || die "Could not open $test_module_file because $!";
74 print FILE $test_module_source_2;
79 Module::Refresh->new->refresh_module($test_module_file)
80 } '... successfully refreshed ' . $test_module_file;
82 is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly');
83 ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well');
84 ok(TestBaz->isa('Foo'), '... TestBaz is a Foo');
86 unlink $test_module_file;