Hello community,
here is the log from the commit of package perl-Test-Spec for openSUSE:Factory checked in at 2015-04-15 16:25:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Test-Spec (Old)
and /work/SRC/openSUSE:Factory/.perl-Test-Spec.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-Spec"
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Test-Spec/perl-Test-Spec.changes 2013-11-26 14:42:09.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Test-Spec.new/perl-Test-Spec.changes 2015-04-15 16:25:08.000000000 +0200
@@ -1,0 +2,23 @@
+Tue Apr 14 19:54:09 UTC 2015 - coolo@suse.com
+
+- updated to 0.49
+ see /usr/share/doc/packages/perl-Test-Spec/Changes
+
+ 0.49 Sun Jan 18 12:56:00 EST 2015
+ - Added with_deep
+ Contributed by Andy Jones (issue #21)
+ - Documented memory leak in stub()
+ Reported by Victor Efimov (issue #14)
+ - Added Travis CI info
+ Contributed by Andy Jones (issue #23)
+ - Fixed mock() example documentation
+ Reported by Victor Efimov (issue #15)
+ Contributed by Andy Jones (issue #22)
+
+ 0.48 Tue Jan 06 22:52:00 EST 2015
+ - Testing fixes for Alpha branch of Test::More
+ Contributed by Chad Granum (issue #18)
+ - Metadata fixes
+ Contributed by Graham Knop (issue #19)
+
+-------------------------------------------------------------------
Old:
----
Test-Spec-0.47.tar.gz
New:
----
Test-Spec-0.49.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Test-Spec.spec ++++++
--- /var/tmp/diff_new_pack.um8qC3/_old 2015-04-15 16:25:08.000000000 +0200
+++ /var/tmp/diff_new_pack.um8qC3/_new 2015-04-15 16:25:08.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-Test-Spec
#
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 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,7 +17,7 @@
Name: perl-Test-Spec
-Version: 0.47
+Version: 0.49
Release: 0
%define cpan_name Test-Spec
Summary: Write tests in a declarative specification style
@@ -32,17 +32,13 @@
BuildRequires: perl(Package::Stash) >= 0.23
BuildRequires: perl(TAP::Parser)
BuildRequires: perl(Test::Deep) >= 0.103
+BuildRequires: perl(Test::More) >= 0.88
BuildRequires: perl(Test::Trap)
BuildRequires: perl(Tie::IxHash)
-#BuildRequires: perl(Test::Spec)
-#BuildRequires: perl(Test::Spec::Context)
-#BuildRequires: perl(Test::Spec::Mocks)
-#BuildRequires: perl(Test::Spec::Mocks::Expectation)
-#BuildRequires: perl(Test::Spec::SharedHash)
-#BuildRequires: perl(Tie::StdHash)
Requires: perl(Package::Stash) >= 0.23
Requires: perl(TAP::Parser)
Requires: perl(Test::Deep) >= 0.103
+Requires: perl(Test::More) >= 0.88
Requires: perl(Test::Trap)
Requires: perl(Tie::IxHash)
%{perl_requires}
++++++ Test-Spec-0.47.tar.gz -> Test-Spec-0.49.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/.travis.yml new/Test-Spec-0.49/.travis.yml
--- old/Test-Spec-0.47/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/Test-Spec-0.49/.travis.yml 2015-01-18 19:01:51.000000000 +0100
@@ -0,0 +1,10 @@
+language: perl
+
+perl:
+ - "5.20"
+ - "5.18"
+ - "5.16"
+ - "5.14"
+ - "5.12"
+ - "5.10"
+ - "5.8"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/Changes new/Test-Spec-0.49/Changes
--- old/Test-Spec-0.47/Changes 2013-10-11 07:23:38.000000000 +0200
+++ new/Test-Spec-0.49/Changes 2015-01-18 19:01:51.000000000 +0100
@@ -1,5 +1,22 @@
Revision history for Perl extension Test::Spec.
+0.49 Sun Jan 18 12:56:00 EST 2015
+ - Added with_deep
+ Contributed by Andy Jones (issue #21)
+ - Documented memory leak in stub()
+ Reported by Victor Efimov (issue #14)
+ - Added Travis CI info
+ Contributed by Andy Jones (issue #23)
+ - Fixed mock() example documentation
+ Reported by Victor Efimov (issue #15)
+ Contributed by Andy Jones (issue #22)
+
+0.48 Tue Jan 06 22:52:00 EST 2015
+ - Testing fixes for Alpha branch of Test::More
+ Contributed by Chad Granum (issue #18)
+ - Metadata fixes
+ Contributed by Graham Knop (issue #19)
+
0.47 Fri Oct 11 01:22:00 EDT 2012
- added repository metadata for CPAN
Contributed by David Steinbrunner (issue #13)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/MANIFEST new/Test-Spec-0.49/MANIFEST
--- old/Test-Spec-0.47/MANIFEST 2013-10-11 07:24:49.000000000 +0200
+++ new/Test-Spec-0.49/MANIFEST 2015-01-18 19:03:18.000000000 +0100
@@ -1,3 +1,4 @@
+.travis.yml
Changes
lib/Test/Spec.pm
lib/Test/Spec/Context.pm
@@ -29,4 +30,5 @@
t/subset_spec.pl
t/test_helper.pl
t/uncompilable_spec.pl
-META.yml Module meta-data (added by MakeMaker)
+META.yml Module YAML meta-data (added by MakeMaker)
+META.json Module JSON meta-data (added by MakeMaker)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/META.json new/Test-Spec-0.49/META.json
--- old/Test-Spec-0.47/META.json 1970-01-01 01:00:00.000000000 +0100
+++ new/Test-Spec-0.49/META.json 2015-01-18 19:03:18.000000000 +0100
@@ -0,0 +1,61 @@
+{
+ "abstract" : "Write tests in a declarative specification style",
+ "author" : [
+ "Philip Garrett "
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.143240",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Test-Spec",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "inc"
+ ]
+ },
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Carp" : "0",
+ "Exporter" : "0",
+ "List::Util" : "0",
+ "Package::Stash" : "0.23",
+ "Scalar::Util" : "1.11",
+ "TAP::Parser" : "0",
+ "Test::Deep" : "0.103",
+ "Test::More" : "0.88",
+ "Test::Trap" : "0",
+ "Tie::IxHash" : "0",
+ "constant" : "0"
+ }
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "bugtracker" : {
+ "web" : "https://github.com/kingpong/perl-Test-Spec/issues"
+ },
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/kingpong/perl-Test-Spec",
+ "web" : "https://github.com/kingpong/perl-Test-Spec"
+ }
+ },
+ "version" : "0.49"
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/META.yml new/Test-Spec-0.49/META.yml
--- old/Test-Spec-0.47/META.yml 2013-10-11 07:24:49.000000000 +0200
+++ new/Test-Spec-0.49/META.yml 2015-01-18 19:03:18.000000000 +0100
@@ -1,34 +1,35 @@
---- #YAML:1.0
-name: Test-Spec
-version: 0.47
-abstract: Write tests in a declarative specification style
+---
+abstract: 'Write tests in a declarative specification style'
author:
- - Philip Garrett
-license: perl
-distribution_type: module
-configure_requires:
- ExtUtils::MakeMaker: 0
+ - 'Philip Garrett '
build_requires:
- ExtUtils::MakeMaker: 0
+ ExtUtils::MakeMaker: '0'
+configure_requires:
+ ExtUtils::MakeMaker: '0'
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.143240'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: '1.4'
+name: Test-Spec
+no_index:
+ directory:
+ - t
+ - inc
requires:
- Carp: 0
- constant: 0
- Exporter: 0
- List::Util: 0
- Package::Stash: 0.23
- Scalar::Util: 0
- TAP::Parser: 0
- Test::Deep: 0.103
- Test::More: 0
- Test::Trap: 0
- Tie::IxHash: 0
+ Carp: '0'
+ Exporter: '0'
+ List::Util: '0'
+ Package::Stash: '0.23'
+ Scalar::Util: '1.11'
+ TAP::Parser: '0'
+ Test::Deep: '0.103'
+ Test::More: '0.88'
+ Test::Trap: '0'
+ Tie::IxHash: '0'
+ constant: '0'
resources:
- repository: https://github.com/kingpong/perl-Test-Spec
-no_index:
- directory:
- - t
- - inc
-generated_by: ExtUtils::MakeMaker version 6.56
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ bugtracker: https://github.com/kingpong/perl-Test-Spec/issues
+ repository: https://github.com/kingpong/perl-Test-Spec
+version: '0.49'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/Makefile.PL new/Test-Spec-0.49/Makefile.PL
--- old/Test-Spec-0.47/Makefile.PL 2013-10-11 07:20:55.000000000 +0200
+++ new/Test-Spec-0.49/Makefile.PL 2015-01-07 04:56:23.000000000 +0100
@@ -1,8 +1,8 @@
-use 5.008008;
+use 5.008005;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-WriteMakefile(
+my %MM_ARGS = (
NAME => 'Test::Spec',
VERSION_FROM => 'lib/Test/Spec.pm', # finds $VERSION
PREREQ_PM => {
@@ -10,21 +10,36 @@
'Exporter' => 0,
'List::Util' => 0,
'Package::Stash' => 0.23,
- 'Scalar::Util' => 0,
- 'TAP::Parser' => 0,
+ 'Scalar::Util' => 1.11,
'Test::Deep' => 0.103, # earlier versions clash with UNIVERSAL::isa
- 'Test::More' => 0,
+ 'Test::More' => 0.88,
'Test::Trap' => 0,
'Tie::IxHash' => 0,
'constant' => 0,
},
- ($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'lib/Test/Spec.pm', # retrieve abstract from module
- AUTHOR => 'Philip Garrett ') : ()),
+ TEST_REQUIRES => {
+ 'TAP::Parser' => 0,
+ },
+ ABSTRACT_FROM => 'lib/Test/Spec.pm', # retrieve abstract from module
+ AUTHOR => 'Philip Garrett ',
LICENSE => 'perl',
META_MERGE => {
+ 'meta-spec' => { version => 2.0 },
resources => {
- repository => 'https://github.com/kingpong/perl-Test-Spec',
+ repository => {
+ type => 'git',
+ web => 'https://github.com/kingpong/perl-Test-Spec',
+ url => 'https://github.com/kingpong/perl-Test-Spec',
+ },
+ bugtracker => {
+ web => 'https://github.com/kingpong/perl-Test-Spec/issues',
+ },
},
},
);
+
+$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
+ if $eumm_version < 6.63_03;
+$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
+ if $eumm_version < 6.55_01;
+WriteMakefile(%MM_ARGS);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/lib/Test/Spec/Mocks.pm new/Test-Spec-0.49/lib/Test/Spec/Mocks.pm
--- old/Test-Spec-0.47/lib/Test/Spec/Mocks.pm 2013-10-11 07:11:13.000000000 +0200
+++ new/Test-Spec-0.49/lib/Test/Spec/Mocks.pm 2015-01-18 19:01:51.000000000 +0100
@@ -3,6 +3,7 @@
use warnings;
use Carp ();
use Scalar::Util ();
+use Test::Deep::NoTest ();
require Test::Spec;
@@ -265,14 +266,31 @@
sub with {
my $self = shift;
- $self->_args(\@_);
+ return $self->with_eq(@_);
+ }
+
+ sub with_eq {
+ my $self = shift;
+ $self->_eq_args(\@_);
+ return $self;
+ }
+
+ sub with_deep {
+ my $self = shift;
+ $self->_deep_args(\@_);
return $self;
}
- sub _args {
+ sub _eq_args {
+ my $self = shift;
+ $self->{__eq_args} = shift if @_;
+ return $self->{__eq_args} ||= undef;
+ }
+
+ sub _deep_args {
my $self = shift;
- $self->{__args} = shift if @_;
- return $self->{__args} ||= undef;
+ $self->{__deep_args} = shift if @_;
+ return $self->{__deep_args} ||= undef;
}
sub _given_args {
@@ -281,16 +299,16 @@
return $self->{__given_args} ||= undef;
}
- sub _check_arguments {
+ sub _check_eq_args {
my $self = shift;
- return unless defined $self->_args;
+ return unless defined $self->_eq_args;
- if (!defined $self->_given_args || scalar(@{$self->_args}) != scalar(@{$self->_given_args})) {
+ if (!defined $self->_given_args || scalar(@{$self->_eq_args}) != scalar(@{$self->_given_args})) {
return "Number of arguments don't match expectation";
}
my @problems = ();
- for my $i (0..$#{$self->_args}) {
- my $a = $self->_args->[$i];
+ for my $i (0..$#{$self->_eq_args}) {
+ my $a = $self->_eq_args->[$i];
my $b = $self->_given_args->[$i];
unless ($self->_match_arguments($a, $b)) {
$a = 'undef' unless defined $a;
@@ -309,6 +327,19 @@
return $a eq $b;
}
+ sub _check_deep_args {
+ my $self = shift;
+ return unless defined $self->_deep_args;
+
+ my @got = $self->_given_args;
+ my @expected = $self->_deep_args;
+ my ($same, $stack) = Test::Deep::cmp_details(\@got, \@expected);
+ if ( !$same ) {
+ return Test::Deep::deep_diag($stack);
+ }
+ return; # args are the same
+ }
+
#
# EXCEPTIONS
#
@@ -445,7 +476,10 @@
$self->_method, $message, $self->_call_count,
);
}
- for my $message ($self->_check_arguments()) {
+ for my $message ($self->_check_eq_args) {
+ push @prob, $message;
+ }
+ for my $message ($self->_check_deep_args) {
push @prob, $message;
}
return @prob;
@@ -738,7 +772,9 @@
once (the default for mocks).
it "returns true when a yes_or_no question is answered 'yes'" => sub {
- my $console_mock = mock()->expects('read_line')->returns("yes");
+ my $console_mock = mock();
+ $console_mock->expects('read_line')
+ ->returns("yes");
# $console_mock->read_line returns "yes"
ok( $asker->yes_or_no($console_mock, "Am I awesome?") );
};
@@ -968,7 +1004,7 @@
I<This method is alpha and will probably change in a future release.>
-=item with(@arguments)
+=item with(@arguments) / with_eq(@arguments)
Configures the mocked method so that it must be called with arguments as
specified. The arguments will be compared using the "eq" operator, so it works
@@ -976,6 +1012,21 @@
they must be the exact same instance or you must overload the "eq" operator to
provide the behavior you desire.
+=item with_deep(@arguments)
+
+Similar to C except the arguments are compared using LTest::Deep: scalars are
+compared by value, arrays and hashes must have the same elements and references
+must be blessed into the same class.
+
+ $cache->expects('set')
+ ->with_deep($customer_id, { name => $customer_name });
+
+Use LTest::Deep's comparison functions for more flexibility:
+
+ use Test::Deep::NoTest ();
+ $s3->expects('put')
+ ->with_deep('test-bucket', 'my-doc', Test::Deep::ignore());
+
=item raises($exception)
Configures the mocked method so that it raises C<$exception> when called.
@@ -999,6 +1050,20 @@
=back
+=head1 KNOWN ISSUES
+
+=over 4
+
+=item Memory leaks
+
+Because of the way the mock objects (C<stubs>, C<stub>, C<expects>, and C<mock>)
+are integrated into the Test::Spec runtime they will leak memory. It is
+not recommended to use the Test::Spec mocks in any long-running program.
+
+Patches welcome.
+
+=back
+
=head1 SEE ALSO
There are other less sugary mocking systems for Perl, including
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/lib/Test/Spec.pm new/Test-Spec-0.49/lib/Test/Spec.pm
--- old/Test-Spec-0.47/lib/Test/Spec.pm 2013-10-11 07:21:46.000000000 +0200
+++ new/Test-Spec-0.49/lib/Test/Spec.pm 2015-01-18 19:01:51.000000000 +0100
@@ -3,7 +3,7 @@
use warnings;
use Test::Trap (); # load as early as possible to override CORE::exit
-our $VERSION = '0.47';
+our $VERSION = '0.49';
use base qw(Exporter);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/t/define.t new/Test-Spec-0.49/t/define.t
--- old/Test-Spec-0.47/t/define.t 2013-10-11 07:11:13.000000000 +0200
+++ new/Test-Spec-0.49/t/define.t 2015-01-07 04:56:23.000000000 +0100
@@ -10,7 +10,6 @@
package Testcase::Spec::Define;
use strict;
use warnings;
-use Test::Deep;
use Test::More tests => 18;
# builds a hash of "parent name" => { "child name" => ... }
@@ -114,11 +113,16 @@
is( A->phase, Test::Spec::DEFINITION_PHASE, "definition phase" );
{
- no warnings 'once';
- my $stub = Stub->new;
- local *A::builder = sub { $stub };
- local *Test::More::builder = sub { $stub };
- A->runtests;
+ if ($INC{'Test/Stream.pm'}) {
+ Test::Stream->intercept(sub { A->runtests });
+ }
+ else {
+ no warnings 'once';
+ my $stub = Stub->new;
+ local *A::builder = sub { $stub };
+ local *Test::More::builder = sub { $stub };
+ A->runtests;
+ }
}
is( A->phase, Test::Spec::EXECUTION_PHASE, "execution phase" );
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/t/disabled.t new/Test-Spec-0.49/t/disabled.t
--- old/Test-Spec-0.47/t/disabled.t 2013-10-11 07:11:13.000000000 +0200
+++ new/Test-Spec-0.49/t/disabled.t 2015-01-07 04:56:23.000000000 +0100
@@ -13,7 +13,6 @@
BEGIN { require "$Bin/test_helper.pl" };
use Test::More;
-use TAP::Parser;
my @results = parse_tap("disabled_spec.pl");
my %passing = map { $_->description => $_ } grep { $_->is_test } @results;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/t/mocks.t new/Test-Spec-0.49/t/mocks.t
--- old/Test-Spec-0.47/t/mocks.t 2013-10-11 07:11:13.000000000 +0200
+++ new/Test-Spec-0.49/t/mocks.t 2015-01-18 19:01:51.000000000 +0100
@@ -273,6 +273,7 @@
describe "argument matching" => sub {
my ($stub, $expectation);
+ my ($with_method, $num_args_mismatch_err, $args_mismatch_err);
before each => sub {
$stub = stub();
@@ -280,68 +281,124 @@
$expectation->cancel; # don't verify
};
- it "passes when expecting no arguments" => sub {
- $expectation->with();
- $stub->run();
- is(scalar($expectation->problems), 0);
+ shared_examples_for "number of arguments" => sub {
+ it "passes when expecting no arguments" => sub {
+ $expectation->$with_method();
+ $stub->run();
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "fails when expecting no arguments and one argument given" => sub {
+ $expectation->$with_method();
+ $stub->run(1);
+ contains_ok([$expectation->problems], $num_args_mismatch_err);
+ };
+
+ it "fails when expecting one argument but given none" => sub {
+ $expectation->$with_method("Foo");
+ $stub->run();
+ contains_ok([$expectation->problems], $num_args_mismatch_err);
+ };
+
+ it "fails when expecting one argument but given two" => sub {
+ $expectation->$with_method("Foo");
+ $stub->run("Foo", "Bar");
+ contains_ok([$expectation->problems], $num_args_mismatch_err);
+ };
+
+ };
+
+ shared_examples_for "shallow string comparisons" => sub {
+ it "passes when expecting one String('Foo') argument" => sub {
+ $expectation->$with_method("Foo");
+ $stub->run("Foo");
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "fails when expecting one String('Foo') argument but given a different String" => sub {
+ $expectation->$with_method("Foo");
+ $stub->run("Bar");
+ contains_ok([$expectation->problems], $args_mismatch_err);
+ };
+
+ it "fails when expecting many string arguments but given different arguments" => sub {
+ $expectation->$with_method('Foo', 'Bar', 'Baz');
+ $stub->run('Foo', 'Bar', 'Bat');
+ contains_ok([$expectation->problems], $args_mismatch_err);
+ };
+ };
+
+ describe "with eq" => sub {
+ before all => sub {
+ $with_method = 'with';
+ $num_args_mismatch_err = qr/^Number of arguments don't match expectation$/;
+ $args_mismatch_err = qr/^Expected argument in position/;
+ };
+
+ it_should_behave_like "number of arguments";
+ it_should_behave_like "shallow string comparisons";
+
+ it "passes when expecting an object argument that was given" => sub {
+ my $obj = TestOO->new;
+ $expectation->with($obj);
+ $stub->run($obj);
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "fails when expecting an object argument but given a different one" => sub {
+ $expectation->with(TestOO->new);
+ $stub->run(TestOO->new);
+ contains_ok([$expectation->problems], qr/^Expected argument in position 0 to be 'TestOO=HASH.+ but it was 'TestOO=HASH/);
+ };
+
+ it "passes when expecting an object argument and given a different one that compares with eq operator" => sub {
+ $expectation->with(TestProduct->new);
+ $stub->run(TestProduct->new);
+ is(scalar($expectation->problems), 0);
+ };
+ };
+
+ describe "with Test::Deep" => sub {
+ before all => sub {
+ $with_method = 'with_deep';
+ $num_args_mismatch_err = qr/^Compared array length/;
+ $args_mismatch_err = qr/^Compared .*(?!length)/;
+ };
+
+ it_should_behave_like "number of arguments";
+ it_should_behave_like "shallow string comparisons";
+
+ it "passes when expecting an object argument that was given" => sub {
+ my $obj = TestOO->new;
+ $expectation->with_deep($obj);
+ $stub->run($obj);
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "passes when expecting an empty hash and given a different one" => sub {
+ $expectation->with_deep({});
+ $stub->run({});
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "passes when given a copy of the data structure it is expecting" => sub {
+ $expectation->with_deep({ key => 'value' });
+ $stub->run({ key => 'value' });
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "passes when expecting an object and given a clone" => sub {
+ $expectation->with_deep(TestOO->new);
+ $stub->run(TestOO->new);
+ is(scalar($expectation->problems), 0);
+ };
+
+ it "does a deep comparison of nested structures" => sub {
+ $expectation->with_deep({ product => TestProduct->new });
+ $stub->run({ product => TestProduct->new });
+ is(scalar($expectation->problems), 0);
+ };
};
-
- it "fails when expecting no arguments and one argument given" => sub {
- $expectation->with();
- $stub->run(1);
- contains_ok([$expectation->problems], qr/^Number of arguments don't match expectation$/);
- };
-
- it "passes when expecting one String('Foo') argument" => sub {
- $expectation->with("Foo");
- $stub->run("Foo");
- is(scalar($expectation->problems), 0);
- };
-
- it "fails when expecting one String('Foo') argument but given none" => sub {
- $expectation->with("Foo");
- $stub->run();
- contains_ok([$expectation->problems], qr/^Number of arguments don't match expectation$/);
- };
-
- it "fails when expecting one String('Foo') argument but given two" => sub {
- $expectation->with("Foo");
- $stub->run("Foo", "Bar");
- contains_ok([$expectation->problems], qr/^Number of arguments don't match expectation$/);
- };
-
- it "fails when expecting one String('Foo') argument but given a different String" => sub {
- $expectation->with("Foo");
- $stub->run("Bar");
- contains_ok([$expectation->problems], qr/^Expected argument in position 0 to be 'Foo', but it was 'Bar'$/);
- };
-
- it "passes when expecting an object argument that was given" => sub {
- my $obj = TestOO->new;
- $expectation->with($obj);
- $stub->run($obj);
- is(scalar($expectation->problems), 0);
- };
-
- it "fails when expecting an object argument but given none" => sub {
- my $obj = TestOO->new;
- $expectation->with($obj);
- $stub->run();
- contains_ok([$expectation->problems], qr/^Number of arguments don't match expectation$/);
- };
-
- it "fails when expecting an object argument but given a different one" => sub {
- $expectation->with(TestOO->new);
- $stub->run(TestOO->new);
- contains_ok([$expectation->problems], qr/^Expected argument in position 0 to be 'TestOO=HASH.+ but it was 'TestOO=HASH/);
- };
-
- it "passes when expecting an object argument and given a different one that compares with eq operator" => sub {
- $expectation->with(TestProduct->new);
- $stub->run(TestProduct->new);
- is(scalar($expectation->problems), 0);
- };
-
};
describe "call count expectation" => sub {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.47/t/shared_examples.t new/Test-Spec-0.49/t/shared_examples.t
--- old/Test-Spec-0.47/t/shared_examples.t 2013-10-11 07:11:13.000000000 +0200
+++ new/Test-Spec-0.49/t/shared_examples.t 2015-01-07 04:56:23.000000000 +0100
@@ -13,7 +13,6 @@
BEGIN { require "$Bin/test_helper.pl" };
use Test::More;
-use TAP::Parser;
my @results = parse_tap("shared_examples_spec.pl");
my %passing = map { $_->description => 1 } grep { $_->is_test } @results;