]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 18; | |
6 | BEGIN { use_ok('Zeal') }; | |
7 | ||
8 | note 'Working with t/ds/b.docset'; | |
9 | my $ds = Zeal::Docset->new('t/ds/b.docset'); | |
10 | is $ds->name, 'B', 'docset name is B'; | |
11 | is $ds->id, 'b', 'docset id is b'; | |
12 | is $ds->family, 'consonants', 'docset family is consonants'; | |
13 | ||
14 | my @results = $ds->query('buil%'); | |
15 | is @results, 2, 'query(buil%) returns two results'; | |
16 | my $doc = $ds->query('building'); | |
17 | is $doc->name, 'building', 'document name is building'; | |
18 | is $doc->type, 'Word', 'document type is Word'; | |
19 | like $doc->fetch, qr/^Dummy/, 'document HTML starts with "Dummy"'; | |
20 | ||
21 | @results = sort {$a->name cmp $b->name} $ds->list; | |
22 | is @results, 2, 'docset contains two documents'; | |
23 | is $results[0]->name, 'building', 'first result is "building"'; | |
24 | ||
25 | note 'Working with all docsets in t/ds/'; | |
26 | my $zeal = Zeal->new('t/ds/'); | |
27 | my @sets = $zeal->sets; | |
28 | is @sets, 3, '3 docsets loaded'; | |
29 | @results = $zeal->query('buil%'); | |
30 | is @results, 2, '2 documents begin with "buil"'; | |
31 | @results = $zeal->query('%t%'); | |
32 | is @results, 3, '3 documents contain letter t'; | |
33 | @results = $zeal->query('consonants:%t%'); | |
34 | is @results, 2, '2 documents from the consonants family contain letter t'; | |
35 | @results = $zeal->query('%t%', 'vowels'); | |
36 | is @results, 1, '1 document from the vowels family contain letter t'; | |
37 | ||
38 | note 'Working with t/ds/a.docset via Zeal and ->add'; | |
39 | $zeal = Zeal->new; | |
40 | $zeal->add('t/ds/a.docset'); | |
41 | @sets = $zeal->sets; | |
42 | is @sets, 1, '1 docset loaded'; | |
43 | like $sets[0]->get('abou%'), qr/word/, 'HTML for abou% contains the word "word"'; | |
44 | ||
45 | note 'Working with t/ds/a.docset via ZEAL_PATH'; | |
46 | $ENV{ZEAL_PATH} = 't/ds/a.docset'; | |
47 | $zeal = Zeal->new; | |
48 | is $zeal->query('about')->name, 'about'; |