>   my $mock = Test::MockObject->new('IO::Socket::INET');
> 
>   $mock->fake_new('IO::Socket::INET')
>        ->set_false('connected')
>        ->mock('error', sub { 'localerror' });
> 
> the goal being that when my class calls IO::Socket::INET->new($args) that it
> fails, returning my error string.
> 
> well, it works great (thanks!)

hmph, I'm actually having a difficult time getting ::Extends to do what I
would think it would do.  consider

  use Test::MockObject::Extends;
  my $mock = Test::MockObject::Extends->new('IO::File');
  $mock->mock('open', sub { print "mocked open\n" });

  IO::File->open;

which yields an IO::File::open() error - I would have expected my own
subroutine to be called instead.  some poking around shows me that if you
call fake_new() then $class->new->method() works ok, but class methods
themselves are not overridden, including new(), which is a handy thing to be
able to override :)

anyway, is something wrong with the code or my understanding of what
Test::MockObject::Extends is capable of?

--Geoff

Reply via email to