Hello community, here is the log from the commit of package perl-Test-MockModule for openSUSE:Factory checked in at 2017-10-11 22:55:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Test-MockModule (Old) and /work/SRC/openSUSE:Factory/.perl-Test-MockModule.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-MockModule" Wed Oct 11 22:55:04 2017 rev:6 rq:532515 version:0.13 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Test-MockModule/perl-Test-MockModule.changes 2017-07-21 22:37:33.109002664 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Test-MockModule.new/perl-Test-MockModule.changes 2017-10-11 22:55:06.629324558 +0200 @@ -1,0 +2,11 @@ +Fri Oct 6 06:03:16 UTC 2017 - co...@suse.com + +- updated to 0.13 + see /usr/share/doc/packages/perl-Test-MockModule/Changes + + v0.13 + - Added the `redefine()` function. It works just like `mock()`, except if the + method being mocked doesn't exist, it causes a panic. Many thanks to Felipe + Gasper for this feature! + +------------------------------------------------------------------- Old: ---- Test-MockModule-0.12.tar.gz New: ---- Test-MockModule-0.13.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Test-MockModule.spec ++++++ --- /var/tmp/diff_new_pack.EEfvUp/_old 2017-10-11 22:55:07.829271937 +0200 +++ /var/tmp/diff_new_pack.EEfvUp/_new 2017-10-11 22:55:07.833271761 +0200 @@ -17,7 +17,7 @@ Name: perl-Test-MockModule -Version: 0.12 +Version: 0.13 Release: 0 #Upstream: GPL-1.0+ %define cpan_name Test-MockModule ++++++ Test-MockModule-0.12.tar.gz -> Test-MockModule-0.13.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-MockModule-0.12/Changes new/Test-MockModule-0.13/Changes --- old/Test-MockModule-0.12/Changes 2017-07-12 22:04:37.000000000 +0200 +++ new/Test-MockModule-0.13/Changes 2017-10-05 19:09:37.000000000 +0200 @@ -1,5 +1,10 @@ Revision history for Test::MockModule +v0.13 + - Added the `redefine()` function. It works just like `mock()`, except if the + method being mocked doesn't exist, it causes a panic. Many thanks to Felipe + Gasper for this feature! + v0.12 - Added the `noop()` function to make mocking noops easier. Thanks for the PR, Ali Zia! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-MockModule-0.12/META.json new/Test-MockModule-0.13/META.json --- old/Test-MockModule-0.12/META.json 2017-07-12 22:04:37.000000000 +0200 +++ new/Test-MockModule-0.13/META.json 2017-10-05 19:09:37.000000000 +0200 @@ -37,7 +37,7 @@ "provides" : { "Test::MockModule" : { "file" : "lib/Test/MockModule.pm", - "version" : "0.12" + "version" : "0.13" } }, "release_status" : "stable", @@ -53,6 +53,6 @@ "url" : "git://github.com/geofffranks/test-mockmodule.git" } }, - "version" : "0.12", + "version" : "0.13", "x_serialization_backend" : "JSON::PP version 2.27400" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-MockModule-0.12/META.yml new/Test-MockModule-0.13/META.yml --- old/Test-MockModule-0.12/META.yml 2017-07-12 22:04:37.000000000 +0200 +++ new/Test-MockModule-0.13/META.yml 2017-10-05 19:09:37.000000000 +0200 @@ -17,7 +17,7 @@ provides: Test::MockModule: file: lib/Test/MockModule.pm - version: '0.12' + version: '0.13' requires: Carp: '0' SUPER: '0' @@ -28,5 +28,5 @@ homepage: https://github.com/geofffranks/test-mockmodule license: http://www.gnu.org/licenses/gpl-3.0.txt repository: git://github.com/geofffranks/test-mockmodule.git -version: '0.12' +version: '0.13' x_serialization_backend: 'CPAN::Meta::YAML version 0.016' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-MockModule-0.12/lib/Test/MockModule.pm new/Test-MockModule-0.13/lib/Test/MockModule.pm --- old/Test-MockModule-0.12/lib/Test/MockModule.pm 2017-07-12 22:04:37.000000000 +0200 +++ new/Test-MockModule-0.13/lib/Test/MockModule.pm 2017-10-05 19:09:37.000000000 +0200 @@ -4,7 +4,7 @@ use Scalar::Util qw/reftype weaken/; use Carp; use SUPER; -$VERSION = '0.12'; +$VERSION = '0.13'; my %mocked; sub new { @@ -46,6 +46,20 @@ return $self->{_package}; } +sub redefine { + my ($self, @mocks) = (shift, @_); + + while ( my ($name, $value) = splice @mocks, 0, 2 ) { + my $sub_name = $self->_full_name($name); + my $coderef = *{$sub_name}{'CODE'}; + if ('CODE' ne ref $coderef) { + croak "$sub_name does not exist!"; + } + } + + return $self->mock(@_); +} + sub mock { my $self = shift; @@ -182,6 +196,10 @@ my $module = Test::MockModule->new('Module::Name'); $module->mock('subroutine', sub { ... }); Module::Name::subroutine(@args); # mocked + + #Same effect, but this will die() if other_subroutine() + #doesn't already exist, which is often desirable. + $module->redefine('other_subroutine', sub { ... }); } Module::Name::subroutine(@args); # original subroutine @@ -317,6 +335,13 @@ $mymodule->mock("strftime", "Yesterday"); is MyModule::minus_twentyfour(), "Yesterday", "`minus-tewntyfour` got mocked"; # suceeds +=item redefine($subroutine) + +The same behavior as C<mock()>, but this will preemptively check to be +sure that all passed subroutines actually exist. This is useful to ensure that +if a mocked module's interface changes the test doesn't just keep on testing a +code path that no longer behaves consistently with the mocked behavior. + =item original($subroutine) Returns the original (unmocked) subroutine