NAME
Test::Magpie::Inspect - Inspect invocations of methods on mocks
SYNOPSIS
my $mock = mock;
$mock->something({ deep => { structure => [] }};
my $invocation = inspect($mock)->something(anything);
ok(defined $invocation, 'something was called');
is_deeply(($invocation->arguments)[0],
{ deep => { structure => [] }})
DESCRIPTION
Inspecting a mock objects allows you to write slightly clearer tests than having a complex verification call. "inspect" in Test::Magpie gives back an object of this class that, like other functions, has the same API as your mock object.
When a method is called, we see if any invocation matches it's name and argument specification (inspectors can use argument matchers), and if so - return that invocation as a Test::Magpie::Invocation. Otherwise, undef
is returned.
AUTHOR
Oliver Charles
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Oliver Charles <oliver.g.charles@googlemail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.