File: 00_test_function_control.t

package info (click to toggle)
libscrappy-perl 0.94112090-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 988 kB
  • ctags: 122
  • sloc: perl: 2,247; makefile: 7
file content (20 lines) | stat: -rw-r--r-- 950 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl

use Scrappy;
use FindBin;
use Test::More $ENV{TEST_LIVE} ?
    (tests => 12) : (skip_all => 'env var TEST_LIVE not set, live testing is not enabled');

my  $s = Scrappy->new;
ok  $s->control->allow('http://search.cpan.org/');
ok  'HASH' eq ref $s->control->allowed->{'search.cpan.org'};
ok  $s->control->is_allowed('http://search.cpan.org/');
ok  $s->control->is_allowed('http://search.cpan.org/recent');
ok  $s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
ok  ! $s->control->is_allowed('http://www.google.com/');
ok  0 == keys %{$s->control->restricted}; # no restriction rules set
ok  $s->control->restrict('http://search.cpan.org');
ok  ! $s->control->is_allowed('http://search.cpan.org/');
ok  ! $s->control->is_allowed('http://search.cpan.org/recent');
ok  ! $s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
ok  $s->control->is_allowed('http://www.google.com/');