File Coverage

blib/lib/Test/Mojo/Role/Debug.pm
Criterion Covered Total %
statement 30 30 100.0
branch 8 8 100.0
condition 6 7 85.7
subroutine 8 8 100.0
pod 2 2 100.0
total 54 55 98.1


line stmt bran cond sub pod time code
1             package Test::Mojo::Role::Debug;
2              
3 1     1   1228 use Mojo::Base -base;
  1         3  
  1         8  
4 1     1   218 use Mojo::File qw/path/;
  1         3  
  1         52  
5 1     1   6 use Mojo::Util qw/encode/;
  1         2  
  1         43  
6 1     1   5 use Role::Tiny;
  1         2  
  1         6  
7 1     1   182 use Carp qw/croak/;
  1         2  
  1         48  
8 1     1   6 use Test::More ();
  1         2  
  1         404  
9              
10             our $VERSION = '1.004001'; # VERSION
11              
12             sub d {
13 11     11 1 50339 my ( $self, $selector, $dump_file ) = @_;
14 11 100       26 return $self->success ? $self : $self->da( $selector, $dump_file );
15             }
16              
17             sub da {
18 8     8 1 4011 my ( $self, $selector, $dump_file ) = @_;
19 8 100 100     45 my $markup = length($selector//'')
20             ? $self->tx->res->dom->at($selector)
21             : $self->tx->res->dom;
22              
23 8 100 66     1539 unless ( defined $markup and length $markup ) {
24 4         29 Test::More::diag "\nDEBUG DUMPER: the selector ($selector) you provided "
25             . "did not match any elements\n\n";
26 4         697 return $self;
27             }
28              
29 4 100 100     543 if (length($dump_file//'')) {
30 2         20 Test::More::diag "\nDEBUG DUMPER: dumping data to $dump_file\n\n";
31 2         344 path($dump_file)->spurt(encode 'utf-8', $markup);
32             }
33             else {
34 2         9 Test::More::diag "\nDEBUG DUMPER:\n$markup\n\n";
35             }
36              
37 4         1486 $self;
38             }
39              
40             q|
41             The optimist says: "The glass is half full"
42             The pessimist says: "The glass is half empty"
43             The programmer says: "The glass is twice as large necessary"
44             |;
45              
46             __END__