line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mojo::Trim; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
247199
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use Mojo::DOM; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
6
|
1
|
|
|
1
|
|
2
|
use Mojo::Base 'Test::Mojo'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
3797
|
use Mojo::Util 'trim'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
293
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Trim strings for Test::Mojo |
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
11
|
|
|
|
|
|
|
our $VERSION = '0.1000'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub trimmed_content_is { |
14
|
1
|
|
|
1
|
1
|
17430
|
my $self = shift; |
15
|
1
|
|
|
|
|
10
|
my $value = squish(Mojo::DOM->new(shift)->to_string); |
16
|
1
|
|
|
|
|
9
|
my $desc = shift; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
3
|
my $dom = $self->tx->res->dom; |
19
|
1
|
|
|
|
|
102
|
my $got = squish($dom->to_string); |
20
|
1
|
50
|
|
|
|
5
|
my $error = defined $dom->at('#error') ? $dom->at('#error')->text : undef; |
21
|
1
|
50
|
|
|
|
260
|
chomp $error if $error; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
$value =~ s{> <}{><}g; |
24
|
1
|
|
|
|
|
4
|
$got =~ s{> <}{><}g; |
25
|
1
|
|
50
|
|
|
2
|
$desc ||= 'exact match for trimmed content'; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
33
|
|
|
6
|
if(defined $error && length $error) { |
28
|
0
|
0
|
0
|
|
|
0
|
$desc .= (defined $error && length $error ? " (Error: $error)" : ''); |
29
|
|
|
|
|
|
|
my $table = $dom->find('#context table')->each(sub { |
30
|
0
|
|
|
0
|
|
0
|
$desc .= $_->find('td')->map(sub { $_->text })->join(' '); |
|
0
|
|
|
|
|
0
|
|
31
|
0
|
|
|
|
|
0
|
}); |
32
|
0
|
|
|
|
|
0
|
$got = ''; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
4
|
return $self->_test('is', $got, $value, $desc); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub squish { |
39
|
2
|
|
|
2
|
0
|
313
|
my $string = trim @_; |
40
|
2
|
|
|
|
|
25
|
$string =~ s{\s+}{ }g; |
41
|
2
|
|
|
|
|
3
|
return $string; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |