Last active
August 29, 2015 14:07
-
-
Save 2shortplanks/1311a130cc4738550876 to your computer and use it in GitHub Desktop.
CSS selector problem with Mojo::DOM and dd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Test::More tests => 2; | |
use Mojo::DOM; | |
# passes | |
{ | |
my $dom = Mojo::DOM->new(<<'ENDOFHTML'); | |
<p> | |
<b>bold</b> | |
<i>italic</i> | |
</div> | |
ENDOFHTML | |
is $dom->at("b + i")->text, "italic"; | |
} | |
# passes | |
{ | |
my $dom = Mojo::DOM->new(<<'ENDOFHTML'); | |
<dl> | |
<dt>term</dt> | |
<dd>description</dd> | |
</dl> | |
ENDOFHTML | |
is $dom->at("dt + dd")->text, "description"; | |
} | |
# fails | |
{ | |
my $dom = Mojo::DOM->new(<<'ENDOFHTML'); | |
<dl> | |
<dt>term</dt> | |
<dd> | |
<dl> | |
<dt>term 2</dt> | |
<dd>description</dd> | |
</dl> | |
</dd> | |
</dl> | |
ENDOFHTML | |
is $dom->at("dt + dd")->text, "description"; | |
} | |
__END__ | |
1..2 | |
ok 1 | |
ok 2 | |
not ok 3 | |
# Failed test at /tmp/barney.pl line 42. | |
# got: '' | |
# expected: 'description' | |
# Looks like you planned 2 tests but ran 3. | |
# Looks like you failed 1 test of 3 run. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment