root/Web-Scraper/trunk/t/12_html.t

Revision 2356 (checked in by miyagawa, 13 years ago)

make absolute URI return value as a string, not URI object to be consistent.

Line 
1 use strict;
2 use Test::Base;
3
4 use utf8;
5 use Web::Scraper;
6 plan tests => 1 * blocks;
7
8 filters {
9     selector => 'chomp',
10     expected => 'chomp',
11 };
12
13 run {
14     my $block = shift;
15     my $s = scraper {
16         process $block->selector, want => 'HTML';
17         result 'want';
18     };
19     my $want = $s->scrape($block->html);
20     is $want, $block->expected, $block->name;
21 };
22
23 __DATA__
24
25 === script
26 --- html
27 <script>function foo() {
28   return bar;
29 }
30 </script>
31 --- selector
32 script
33 --- expected
34 function foo() {
35   return bar;
36 }
37
38 === a
39 --- html
40 <a id="foo"><span>foo</span> bar</a>
41 --- selector
42 a
43 --- expected
44 <span>foo</span> bar
45
46 === div
47 --- html
48 <div id="foo">
49 <p>foo
50 bar</p>
51 <p>bar</p>
52 </div>
53 --- selector
54 #foo
55 --- expected
56 <p>foo bar</p><p>bar</p>
57
58 === non-ascii
59 --- html
60 <p id="foo">テスト</p>
61 --- selector
62 #foo
63 --- expected
64 テスト
Note: See TracBrowser for help on using the browser.