File Coverage

blib/lib/Test/Mojo/Role/DOMinizer.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 3 3 100.0
pod 1 1 100.0
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Test::Mojo::Role::DOMinizer;
2              
3 1     1   1138 use Mojo::Base -base;
  1         2  
  1         6  
4 1     1   193 use Role::Tiny;
  1         2  
  1         5  
5              
6             our $VERSION = '1.001001'; # VERSION
7              
8             sub in_DOM {
9 2     2 1 31995 my ($self, $code) = @_;
10 2         5 my $res = do {
11 2         7 local $_ = $self->tx->res->dom;
12 2         2150 $code->($_, $self);
13             };
14              
15             # Don't know a better way to test whether the returned object is
16             # a Test::Mojo when it does arbitrary roles, so doing this hack:
17 2         17069 my $ref = ref $res;
18 2 100 66     52 $ref && (
19             $ref eq 'Test::Mojo' or $ref =~ /^Test::Mojo__WITH__Test::Mojo::Role/
20             ) ? $res : $self
21             }
22              
23             1;
24             __END__