Hello community,

here is the log from the commit of package perl-Test-MockModule for 
openSUSE:Factory checked in at 2015-06-09 12:25:01
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Test-MockModule (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Test-MockModule.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Test-MockModule"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/perl-Test-MockModule/perl-Test-MockModule.changes    
    2015-04-25 09:54:27.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-Test-MockModule.new/perl-Test-MockModule.changes
   2015-06-09 12:25:02.000000000 +0200
@@ -1,0 +2,6 @@
+Sun Jun  7 09:06:50 UTC 2015 - co...@suse.com
+
+- updated to 0.10
+   see /usr/share/doc/packages/perl-Test-MockModule/Changes
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ perl-Test-MockModule.spec ++++++
--- /var/tmp/diff_new_pack.N7ST9V/_old  2015-06-09 12:25:02.000000000 +0200
+++ /var/tmp/diff_new_pack.N7ST9V/_new  2015-06-09 12:25:02.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           perl-Test-MockModule
-Version:        0.09
+Version:        0.10
 Release:        0
 #Upstream: GPL-1.0+
 %define cpan_name Test-MockModule

++++++ Test-MockModule-0.09.tar.gz -> Test-MockModule-0.10.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.09/Changes 
new/Test-MockModule-0.10/Changes
--- old/Test-MockModule-0.09/Changes    2015-03-15 16:51:18.000000000 +0100
+++ new/Test-MockModule-0.10/Changes    2015-05-31 16:57:49.000000000 +0200
@@ -1,7 +1,10 @@
 Revision history for Test::MockModule
 $Id: Changes,v 1.5 2005/03/24 22:23:38 simonflack Exp $
 
-v0.08 2015-03-15
+v0.10 2015-05-30
+    - Updated docs for mocking when using exported functions
+
+v0.09 2015-03-15
     - Ensure LICENSE autogenerates for distribution, fixed license issues in 
Build.PL
 
 v0.08 2015-03-14
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.09/META.json 
new/Test-MockModule-0.10/META.json
--- old/Test-MockModule-0.09/META.json  2015-03-15 16:51:18.000000000 +0100
+++ new/Test-MockModule-0.10/META.json  2015-05-31 16:57:49.000000000 +0200
@@ -36,7 +36,7 @@
    "provides" : {
       "Test::MockModule" : {
          "file" : "lib/Test/MockModule.pm",
-         "version" : "0.09"
+         "version" : "0.10"
       }
    },
    "release_status" : "stable",
@@ -52,5 +52,5 @@
          "url" : "git://github.com/geofffranks/test-mockmodule.git"
       }
    },
-   "version" : "0.09"
+   "version" : "0.10"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.09/META.yml 
new/Test-MockModule-0.10/META.yml
--- old/Test-MockModule-0.09/META.yml   2015-03-15 16:51:18.000000000 +0100
+++ new/Test-MockModule-0.10/META.yml   2015-05-31 16:57:49.000000000 +0200
@@ -17,7 +17,7 @@
 provides:
   Test::MockModule:
     file: lib/Test/MockModule.pm
-    version: '0.09'
+    version: '0.10'
 requires:
   Carp: '0'
   SUPER: '0'
@@ -27,4 +27,4 @@
   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.09'
+version: '0.10'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Test-MockModule-0.09/lib/Test/MockModule.pm 
new/Test-MockModule-0.10/lib/Test/MockModule.pm
--- old/Test-MockModule-0.09/lib/Test/MockModule.pm     2015-03-15 
16:51:18.000000000 +0100
+++ new/Test-MockModule-0.10/lib/Test/MockModule.pm     2015-05-31 
16:57:49.000000000 +0200
@@ -5,7 +5,7 @@
 use Scalar::Util qw/reftype weaken/;
 use Carp;
 use SUPER;
-$VERSION = '0.09';
+$VERSION = '0.10';
 
 my %mocked;
 sub new {
@@ -266,6 +266,53 @@
 C<unmock()>, the original subroutine is restored (not the last mocked
 instance).
 
+B<MOCKING + EXPORT>
+
+If you are trying to mock a subroutine exported from another module, this may
+not behave as you initialy would expect, since Test::MockModule is only mocking
+at the target module, not anything importing that module. If you mock the local
+package, or use a fully qualified function name, you will get the behavior you
+desire:
+
+       use Test::MockModule;
+       use Test::More;
+       use POSIX qw/strftime/;
+
+       my $posix = Test::MockModule->new("POSIX");
+
+       $posix->mock("strftime", "Yesterday");
+       is strftime("%D", localtime(time)), "Yesterday", "`strftime` was mocked 
successfully"; # Fails
+       is POSIX::strftime("%D", localtime(time)), "Yesterday", "`strftime` was 
mocked successfully"; # Succeeds
+
+       my $main = Test::MockModule->new("main", no_auto => 1);
+       $main->mock("strftime", "today");
+       is strftime("%D", localtime(time)), "today", "`strftime` was mocked 
successfully"; # Succeeds
+
+If you are trying to mock a subroutine that was exported into a module that 
you're
+trying to test, rather than mocking the subroutine in its originating module,
+you can instead mock it in the module you are testing:
+
+       package MyModule;
+       use POSIX qw/strftime/;
+
+       sub minus_twentyfour
+       {
+               return strftime("%a, %b %d, %Y", localtime(time - 86400));
+       }
+
+       package main;
+       use Test::More;
+       use Test::MockModule;
+
+       my $posix = Test::MockModule->new("POSIX");
+       $posix->mock("strftime", "Yesterday");
+
+       is MyModule::minus_twentyfour(), "Yesterday", "`minus-tewntyfour` got 
mocked"; # fails
+
+       my $mymodule = Test::MockModule->new("MyModule", no_auto => 1);
+       $mymodule->mock("strftime", "Yesterday");
+       is MyModule::minus_twentyfour(), "Yesterday", "`minus-tewntyfour` got 
mocked"; # suceeds
+
 =item original($subroutine)
 
 Returns the original (unmocked) subroutine


Reply via email to