SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

perl-Test-MockPackages rpm build for : openSUSE Tumbleweed. For other distributions click perl-Test-MockPackages.

Name : perl-Test-MockPackages
Version : 0.5 Vendor : obs://build_opensuse_org/devel:languages:perl
Release : 1.7 Date : 2017-05-17 16:28:33
Group : Development/Libraries/Perl Source RPM : perl-Test-MockPackages-0.5-1.7.src.rpm
Size : 0.04 MB
Packager : (none)
Summary : Mock external dependencies in tests
Description :
Test::MockPackages is a package for mocking other packages as well as
ensuring those packages are being used correctly.

Say we have a Weather class that can return the current degrees in
Fahrenheit. In order to do this it uses another class, Weather::Fetcher
which makes an external call. When we want to write a unit test for
Weather, we want to mock the functionality of Weather::Fetcher.

Here is the sample code for our Weather class:

package Weather;
use Moose;
use Weather::Fetcher;
sub degrees_f {
my ( $self, $zip_code ) = AATT_;

my $data = eval { Weather::Fetcher::fetch_weather( $zip_code ) };
if ( !$data ) {
return;
}

return $data->{temp_f} . \"�F\";
}

And here\'s how we may choose to test this class. In the \'success\' subtest,
we use the mock() helper subroutine, and in the \'failure\' method we use the
OOP approach. Both provide identical functionality.

use Test::More;
use Test::MockPackages qw(mock);
subtest \'degrees_f\' => sub {
subtest \'success\' => sub {
my $m = mock({
\'Weather::Fetcher\' => {
fetch_weather => [
expects => [ \'14202\' ],
returns => [ { temp_f => 80 } ],
],
},
});

isa_ok( my $weather = Weather->new, \'Weather\' );
is( $weather->degrees_f( 14202 ), \'80�F\', \'correct temperature returned\' );
};

subtest \'failure\' => sub {
my $m = Test::MockPackages->new();
$m->pkg( \'Weather::Fetcher\' )
->mock( \'fetch_weather\' )
->expects( \'14202\' )
->returns();

my $weather = Weather->new;
is( $weather->degrees_f( 14202 ), undef, \'no temperature returned\' );
};
};
done_testing();

When we run our tests, you can see that Test::MockPackages validates the
following for us: 1. the subroutine is called with the correct arguments,
2. the subroutine was called the correct number of times. Lastly,
Test::MockPackages allows us to have this mocked subroutine return a
consistent value.

ok 1 - The object isa Weather
ok 2 - Weather::Fetcher::fetch_weather expects is correct
ok 3 - correct temperature returned
ok 4 - Weather::Fetcher::fetch_weather called 1 time
1..4
ok 1 - success
ok 1 - Weather::Fetcher::fetch_weather expects is correct
ok 2 - no temperature returned
ok 3 - Weather::Fetcher::fetch_weather called 1 time
1..3
ok 2 - failure
1..2
ok 1 - degrees_f
1..1

For more information on how to properly configure your mocks, see
Test::MockPackages::Mock.

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/openSUSE_Tumbleweed/noarch

Content of RPM  Provides Requires

Download
ftp.icm.edu.pl  perl-Test-MockPackages-0.5-1.7.noarch.rpm
     

Provides :
perl(Test::MockPackages)
perl(Test::MockPackages::Mock)
perl(Test::MockPackages::Package)
perl(Test::MockPackages::Returns)
perl-Test-MockPackages

Requires :
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsLzma) <= 4.4.6-1
perl(Test::Exception)
perl(:MODULE_COMPAT_5.24.1)
perl(Const::Fast)
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
perl(Test::Tester)
perl(Lingua::EN::Inflect)


Content of RPM :
/usr/lib/perl5/vendor_perl/5.24.1/Test
/usr/lib/perl5/vendor_perl/5.24.1/Test/MockPackages
/usr/lib/perl5/vendor_perl/5.24.1/Test/MockPackages.pm
/usr/lib/perl5/vendor_perl/5.24.1/Test/MockPackages/Mock.pm
/usr/lib/perl5/vendor_perl/5.24.1/Test/MockPackages/Package.pm
/usr/lib/perl5/vendor_perl/5.24.1/Test/MockPackages/Returns.pm
/usr/lib/perl5/vendor_perl/5.24.1/x86_64-linux-thread-multi
/usr/share/doc/packages/perl-Test-MockPackages
/usr/share/doc/packages/perl-Test-MockPackages/Changes
/usr/share/doc/packages/perl-Test-MockPackages/README
/usr/share/doc/packages/perl-Test-MockPackages/ignore.txt
/usr/share/man/man3/Test::MockPackages.3pm.gz
/usr/share/man/man3/Test::MockPackages::Mock.3pm.gz
/usr/share/man/man3/Test::MockPackages::Package.3pm.gz
/usr/share/man/man3/Test::MockPackages::Returns.3pm.gz

 
ICM