00_test_function_control.t 943 B

123456789101112131415161718192021
  1. #!/usr/bin/env perl
  2. use Scrappy;
  3. use FindBin;
  4. use Test::More $ENV{TEST_LIVE} ?
  5. (tests => 12) : (skip_all => 'env var TEST_LIVE not set, live testing is not enabled');
  6. my $s = Scrappy->new;
  7. ok $s->control->allow('http://search.cpan.org/');
  8. ok 'HASH' eq ref $s->control->allowed->{'search.cpan.org'};
  9. ok $s->control->is_allowed('http://search.cpan.org/');
  10. ok $s->control->is_allowed('http://search.cpan.org/recent');
  11. ok $s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
  12. ok ! $s->control->is_allowed('http://www.google.com/');
  13. ok 0 == keys %{$s->control->restricted}; # no restriction rules set
  14. ok $s->control->restrict('search.cpan.org');
  15. ok ! $s->control->is_allowed('http://search.cpan.org/');
  16. ok ! $s->control->is_allowed('http://search.cpan.org/recent');
  17. ok ! $s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
  18. ok $s->control->is_allowed('http://www.google.com/');