There is a much cleaner and easier way:
{ local *Foo::new = sub { require MockFoo; return MockFoo->new; }; ... tests ... }; # Foo::new is restored to its old value
In reply to Re: locally redefining subroutine in module
by Corion
in thread locally redefining subroutine in module
by Jasper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |