root/Web-Scraper/trunk/t/01_process.t

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

added unit tests

Line 
1 use strict;
2 use Test::Base;
3
4 use Web::Scraper;
5 plan tests => 1 * blocks;
6
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, text => 'TEXT';
17         result 'text';
18     };
19     my $text = $s->($block->html);
20     is $text, $block->expected, $block->name;
21 };
22
23 __DATA__
24
25 ===
26 --- html
27 <div id="foo">bar</div>
28 --- selector
29 div#foo
30 --- expected
31 bar
32
33 ===
34 --- html
35 <span><a href="foo">baz</a></span>
36 --- selector
37 span a[href]
38 --- expected
39 baz
Note: See TracBrowser for help on using the browser.