Skip to content

Commit

Permalink
refactor 03_keeps_comparing into mocktest
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Dec 30, 2013
1 parent 42045c4 commit 419f3dc
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions t/03_keep_comparing_keeps_comparing.t
Expand Up @@ -2,44 +2,32 @@ use strict;
use warnings;

use Test::More 0.96;
use Test::MockObject;
use FindBin;

my $mock = Test::MockObject->new();

my @events;

$mock->mock(
'ok' => sub {
my ( $self, @args ) = @_;
push @events, [ 'ok', @args ];
}
);

$mock->mock(
'diag' => sub {
my ( $self, @args ) = @_;
push @events, [ 'diag', @args ];
use lib "$FindBin::Bin/lib";
use mocktest;

my $mock = mocktest->new();

use Test::CPAN::Changes::ReallyStrict ();
my $res = Test::CPAN::Changes::ReallyStrict::_real_changes_file_ok(
$mock,
{
delete_empty_groups => undef,
keep_comparing => 1,
filename => "$FindBin::Bin/../corpus/Changes_02.txt",
}
);

use Test::CPAN::Changes::ReallyStrict;

ok(
!Test::CPAN::Changes::ReallyStrict::_real_changes_file_ok(
$mock,
{
delete_empty_groups => undef,
keep_comparing => 1,
filename => "$FindBin::Bin/../corpus/Changes_02.txt",
}
),
"Expected bad file is bad ( In progress"
)
or do {
note explain \@events;
};

is( scalar @events, 579, "There is 579 events sent to the test system with this option on" ) or note explain \@events;
my $need_diag;

if ( not ok( !$res, "Expected bad file is bad ( In progress )" ) ) {
$need_diag = 1;
}
if ( not is( $mock->num_events, 708, "There is 708 events sent to the test system with this option on" ) ) {
$need_diag = 1;
}
if ($need_diag) {
diag $_ for $mock->ls_events;
}

done_testing;

0 comments on commit 419f3dc

Please sign in to comment.