Subject: | unmock_all umocks mocked methods for all objects that mock the class |
Date: | Mon, 25 Mar 2013 00:07:00 -0400 |
To: | bug-Test-MockModule [...] rt.cpan.org |
From: | "David E. Wheeler" <dwheeler [...] cpan.org> |
Example code:
use Test::MockModule;
my $mock1 = Test::MockModule->new('FileHandle');
$mock1->mock(new => 'foo');
my $mock2 = Test::MockModule->new('FileHandle');
$mock2->mock(new => 'bar');
say FileHandle->new;
$mock2->unmock_all;
say FileHandle->new;
Output:
bar
FileHandle=GLOB(0x7f8152865e28)
I would expect the output to be:
bar
foo
The bug is that, even though I call unmock_all on an object, expecting it to just remove the mocks created for *that* object, it ends up removing the mocks for *all* objects that have mocked the same class.