Hello community,

here is the log from the commit of package perl-Test-MockModule for 
openSUSE:Factory checked in at 2018-05-19 15:39:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Test-MockModule (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Test-MockModule.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Test-MockModule"

Sat May 19 15:39:15 2018 rev:7 rq:610499 version:0.14

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/perl-Test-MockModule/perl-Test-MockModule.changes    
    2017-10-11 22:55:06.629324558 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-Test-MockModule.new/perl-Test-MockModule.changes
   2018-05-19 15:39:16.781622940 +0200
@@ -1,0 +2,12 @@
+Sun May  6 06:00:00 UTC 2018 - [email protected]
+
+- updated to 0.14
+   see /usr/share/doc/packages/perl-Test-MockModule/Changes
+
+  v0.14
+      - Fixes a bug where the `redefine()` function was dying when attempting 
to
+        mock a function that was defined further up a module's inheritance 
chain.
+        It now only dies when the mocked function does not exist in the module 
being
+        mocked, or any of its parent modules. Thanks @atoomic for the 
improvement!
+
+-------------------------------------------------------------------

Old:
----
  Test-MockModule-0.13.tar.gz

New:
----
  Test-MockModule-0.14.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Test-MockModule.spec ++++++
--- /var/tmp/diff_new_pack.g5YMno/_old  2018-05-19 15:39:17.289604354 +0200
+++ /var/tmp/diff_new_pack.g5YMno/_new  2018-05-19 15:39:17.289604354 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Test-MockModule
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,12 +17,12 @@
 
 
 Name:           perl-Test-MockModule
-Version:        0.13
+Version:        0.14
 Release:        0
 #Upstream: GPL-1.0+
 %define cpan_name Test-MockModule
 Summary:        Override subroutines in a module for unit testing
-License:        GPL-3.0+
+License:        GPL-3.0-or-later
 Group:          Development/Libraries/Perl
 Url:            http://search.cpan.org/dist/Test-MockModule/
 Source0:        
https://cpan.metacpan.org/authors/id/G/GF/GFRANKS/%{cpan_name}-%{version}.tar.gz
@@ -34,6 +34,7 @@
 BuildRequires:  perl(Module::Build) >= 0.380000
 BuildRequires:  perl(SUPER)
 BuildRequires:  perl(Test::More) >= 0.88
+BuildRequires:  perl(Test::Warnings)
 Requires:       perl(SUPER)
 %{perl_requires}
 

++++++ Test-MockModule-0.13.tar.gz -> Test-MockModule-0.14.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/Build.PL 
new/Test-MockModule-0.14/Build.PL
--- old/Test-MockModule-0.13/Build.PL   2017-10-05 19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/Build.PL   2018-05-05 13:21:04.000000000 +0200
@@ -27,6 +27,7 @@
        },
        build_requires => {
                'Test::More'          => 0.88,
+               'Test::Warnings'      => 0
        },
 
        add_to_cleanup => [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/Changes 
new/Test-MockModule-0.14/Changes
--- old/Test-MockModule-0.13/Changes    2017-10-05 19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/Changes    2018-05-05 13:21:04.000000000 +0200
@@ -1,5 +1,11 @@
 Revision history for Test::MockModule
 
+v0.14
+    - Fixes a bug where the `redefine()` function was dying when attempting to
+      mock a function that was defined further up a module's inheritance chain.
+      It now only dies when the mocked function does not exist in the module 
being
+      mocked, or any of its parent modules. Thanks @atoomic for the 
improvement!
+
 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/LICENSE 
new/Test-MockModule-0.14/LICENSE
--- old/Test-MockModule-0.13/LICENSE    2017-10-05 19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/LICENSE    2018-05-05 13:21:04.000000000 +0200
@@ -1,4 +1,4 @@
-This software is Copyright (c) 2017 by Current Maintainer: Geoff Franks 
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
+This software is Copyright (c) 2018 by Current Maintainer: Geoff Franks 
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
 
 This is free software, licensed under:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/META.json 
new/Test-MockModule-0.14/META.json
--- old/Test-MockModule-0.13/META.json  2017-10-05 19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/META.json  2018-05-05 13:21:04.000000000 +0200
@@ -17,7 +17,8 @@
    "prereqs" : {
       "build" : {
          "requires" : {
-            "Test::More" : "0.88"
+            "Test::More" : "0.88",
+            "Test::Warnings" : "0"
          }
       },
       "configure" : {
@@ -37,7 +38,7 @@
    "provides" : {
       "Test::MockModule" : {
          "file" : "lib/Test/MockModule.pm",
-         "version" : "0.13"
+         "version" : "0.14"
       }
    },
    "release_status" : "stable",
@@ -53,6 +54,6 @@
          "url" : "git://github.com/geofffranks/test-mockmodule.git"
       }
    },
-   "version" : "0.13",
+   "version" : "0.14",
    "x_serialization_backend" : "JSON::PP version 2.27400"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/META.yml 
new/Test-MockModule-0.14/META.yml
--- old/Test-MockModule-0.13/META.yml   2017-10-05 19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/META.yml   2018-05-05 13:21:04.000000000 +0200
@@ -5,6 +5,7 @@
   - 'Original Author: Simon Flack <simonflk _AT_ cpan.org>'
 build_requires:
   Test::More: '0.88'
+  Test::Warnings: '0'
 configure_requires:
   Module::Build: '0.38'
 dynamic_config: 1
@@ -17,7 +18,7 @@
 provides:
   Test::MockModule:
     file: lib/Test/MockModule.pm
-    version: '0.13'
+    version: '0.14'
 requires:
   Carp: '0'
   SUPER: '0'
@@ -28,5 +29,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.13'
+version: '0.14'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/lib/Test/MockModule.pm 
new/Test-MockModule-0.14/lib/Test/MockModule.pm
--- old/Test-MockModule-0.13/lib/Test/MockModule.pm     2017-10-05 
19:09:37.000000000 +0200
+++ new/Test-MockModule-0.14/lib/Test/MockModule.pm     2018-05-05 
13:21:04.000000000 +0200
@@ -1,10 +1,11 @@
 package Test::MockModule;
+use warnings;
 use strict qw/subs vars/;
 use vars qw/$VERSION/;
 use Scalar::Util qw/reftype weaken/;
 use Carp;
 use SUPER;
-$VERSION = '0.13';
+$VERSION = '0.14';
 
 my %mocked;
 sub new {
@@ -52,6 +53,14 @@
        while ( my ($name, $value) = splice @mocks, 0, 2 ) {
                my $sub_name = $self->_full_name($name);
                my $coderef = *{$sub_name}{'CODE'};
+               next if 'CODE' eq ref $coderef;
+
+               if ( $sub_name =~ qr{^(.+)::([^:]+)$} ) {
+                       my ( $pkg, $sub ) = ( $1, $2 );
+                       my $object = bless {}, $pkg;
+                       next if $object->can( $sub );
+               }
+
                if ('CODE' ne ref $coderef) {
                        croak "$sub_name does not exist!";
                }
@@ -333,7 +342,7 @@
 
        my $mymodule = Test::MockModule->new("MyModule", no_auto => 1);
        $mymodule->mock("strftime", "Yesterday");
-       is MyModule::minus_twentyfour(), "Yesterday", "`minus-tewntyfour` got 
mocked"; # suceeds
+       is MyModule::minus_twentyfour(), "Yesterday", "`minus-tewntyfour` got 
mocked"; # succeeds
 
 =item redefine($subroutine)
 
@@ -342,6 +351,9 @@
 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.
 
+Note that redefine is also now checking if one of the parent provides the sub
+and will not die if it's available in the chain.
+
 =item original($subroutine)
 
 Returns the original (unmocked) subroutine
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/t/inheritance.t 
new/Test-MockModule-0.14/t/inheritance.t
--- old/Test-MockModule-0.13/t/inheritance.t    2017-10-05 19:09:37.000000000 
+0200
+++ new/Test-MockModule-0.14/t/inheritance.t    2018-05-05 13:21:04.000000000 
+0200
@@ -3,6 +3,7 @@
 
 use Test::MockModule;
 use Test::More;
+use Test::Warnings;
 
 @Bar::ISA = 'Foo';
 @Baz::ISA = 'Bar';
@@ -39,4 +40,51 @@
 is(Foo->motto(), "Foo!", "post-unmock: Foo original motto is correct");
 is(Bar->motto(), "Foo!", "post-unmock: Bar inherit's Foo's motto");
 is(Baz->motto(), "Foo!", "post-unmock: Baz inherit's Bar's inheritance of 
Foo's motto");
+
+{
+       BEGIN {
+               $INC{'Mother.pm'} = '__MOCKED__';
+               $INC{'InvalidChild.pm'} = '__MOCKED__';
+               $INC{'ValidChild.pm'} = '__MOCKED__';
+       }
+       package Mother;
+
+       sub do_something { 1 }
+
+       package InvalidChild;
+
+       sub abcd { 1 }
+
+       package ValidChild;
+
+       use parent q{Mother};
+
+       sub abcd { 1 }
+}
+
+package main;
+
+{
+       my $mock_child = Test::MockModule->new( 'InvalidChild' );
+
+       local $@;
+       ok ! eval { $mock_child->redefine( 'do_something', sub { 42 } ); 1 }, 
"cannot redefine do_something";
+       like $@, qr{InvalidChild::do_something does not exist!}, "throw a die";
+}
+
+{
+       my $mock_child = Test::MockModule->new( 'ValidChild' );
+
+       local $@;
+       ok eval { $mock_child->redefine( 'do_something', sub { 42 } ); 1 }, 
"cann redefine do_something when parent define this function";
+       is $@, '', 'no warnings';
+
+       my $object = bless {}, 'ValidChild';
+       is $object->do_something(), 42, "mocked value from do_something";
+
+       $mock_child->unmock( 'do_something' );
+       is $object->do_something(), 1, "do_something is now unmocked";
+}
+
+
 done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.13/t/mockmodule.t 
new/Test-MockModule-0.14/t/mockmodule.t
--- old/Test-MockModule-0.13/t/mockmodule.t     2017-10-05 19:09:37.000000000 
+0200
+++ new/Test-MockModule-0.14/t/mockmodule.t     2018-05-05 13:21:04.000000000 
+0200
@@ -2,6 +2,7 @@
 use strict;
 
 use Test::More;
+use Test::Warnings;
 
 use lib "t/lib";
 


Reply via email to