File Coverage

lib/Test/Chai/Core/Assertions/Increase.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Test::Chai::Core::Assertions::Increase;
2 2     2   11 use strict;
  2         4  
  2         56  
3 2     2   10 use warnings;
  2         4  
  2         48  
4 2     2   10 use utf8;
  2         3  
  2         11  
5              
6 2     2   50 use Exporter qw/import/;
  2         4  
  2         111  
7             our @EXPORT_OK = qw/assert_increase/;
8              
9 2     2   11 use Test::Chai::Util::Flag qw/flag/;
  2         4  
  2         413  
10              
11             sub assert_increase {
12 3     3 0 7 my ($self, $object, $prop, $msg) = @_;
13              
14 3 50       8 flag($self, 'message', $msg) if defined $msg;
15 3         8 my $fn = flag($self, 'object');
16              
17 3         11 ref($self)->new($object, $msg)->to->have->property($prop);
18 3         18 ref($self)->new($fn)->is->a('CodeRef');
19              
20 3         12 my $initial = $object->{$prop};
21 3         8 $fn->();
22              
23             return $self->assert(
24 3         24 $object->{$prop} - $initial > 0,
25             'expected .' . $prop . ' to increase',
26             'expected .' . $prop . ' to not increase'
27             );
28             }
29              
30             1;