Skip to content

Instantly share code, notes, and snippets.

@konobi
Created June 22, 2009 03:13
Show Gist options
  • Save konobi/133789 to your computer and use it in GitHub Desktop.
Save konobi/133789 to your computer and use it in GitHub Desktop.
NAME: Make sure search.cpan.org has Test::A8N
SUMMARY: If a tree falls in a forest, does the cpan indexer fall on it's ass?
PRECONDITIONS:
- ensure search.cpan.org is available
INSTRUCTIONS:
- goto page: Homepage
- search for: Test::A8N
- verify search results contain: Test::A8N
- verify author is: Michael A. Nachbaur
POSTCONDITIONS:
- party
package CPANSearchTest::Foo;
use Moose;
BEGIN { extends 'Test::A8N::Fixture'; }
use WWW::Mechanize;
has mech => (is => 'rw', default => sub { WWW::Mechanize->new() });
sub ensure_site_is_available {
my ($self) = @_;
my $output = `host search.cpan.org`;
die "Not available" if $output !~ /NXDOMAIN/;
}
my %pages = (Homepage => '/');
sub goto_page {
my ($self, $page) = @_;
$self->mech->get('http://search.cpan.org' . $pages{$page});
}
sub search_for {
my ($self, $target) = @_;
$self->mech->submit_form(
form_name => 'f',
fields => { query => $target, mode => 'all' },
button => 'CPAN Search',
);
}
sub verify_search_results_contain : Test {
my ($self, $target) = @_;
$self->mech->find_link( text_regex => qr/\Q$target\E/ );
}
sub verify_author_is : Test {
my ($self, $author) = @_;
$self->mech->find_link( text_regex => qr/\Q$author\E/ );
}
sub party {
warn "PARTY TIME!!!";
}
1;
00000000 2d 2d 2d 0a 4e 41 4d 45 3a 20 4d 61 6b 65 20 73 |---.NAME: Make s|
00000010 75 72 65 20 63 70 61 6e 20 73 65 61 72 63 68 20 |ure cpan search |
00000020 68 61 73 20 54 65 73 74 3a 3a 41 38 4e 0a 49 44 |has Test::A8N.ID|
00000030 3a 20 66 6f 6f 0a 53 55 4d 4d 41 52 59 3a 20 49 |: foo.SUMMARY: I|
00000040 66 20 61 20 74 72 65 65 20 66 61 6c 6c 73 20 69 |f a tree falls i|
00000050 6e 20 61 20 66 6f 72 65 73 74 20 64 6f 65 73 20 |n a forest does |
00000060 74 68 65 20 63 70 61 6e 20 69 6e 64 65 78 65 72 |the cpan indexer|
00000070 20 66 61 6c 6c 20 6f 6e 20 69 74 73 20 61 73 73 | fall on its ass|
00000080 0a 50 52 45 43 4f 4e 44 49 54 49 4f 4e 53 3a 0a |.PRECONDITIONS:.|
00000090 c2 a0 c2 a0 c2 a0 c2 a0 2d 20 65 6e 73 75 72 65 |    - ensure|
000000a0 20 73 69 74 65 20 69 73 20 61 76 61 69 6c 61 62 | site is availab|
000000b0 6c 65 3a 20 73 65 61 72 63 68 2e 63 70 61 6e 2e |le: search.cpan.|
000000c0 6f 72 67 0a 49 4e 53 54 52 55 43 54 49 4f 4e 53 |org.INSTRUCTIONS|
000000d0 3a 0a c2 a0 c2 a0 c2 a0 c2 a0 2d 20 67 6f 74 6f |:.    - goto|
000000e0 20 70 61 67 65 3a 20 48 6f 6d 65 70 61 67 65 0a | page: Homepage.|
000000f0 c2 a0 c2 a0 c2 a0 c2 a0 2d 20 73 65 61 72 63 68 |    - search|
00000100 20 66 6f 72 3a 20 54 65 73 74 3a 3a 41 38 4e 0a | for: Test::A8N.|
00000110 c2 a0 c2 a0 c2 a0 c2 a0 2d 20 76 65 72 69 66 79 |    - verify|
00000120 20 73 65 61 72 63 68 20 72 65 73 75 6c 74 73 20 | search results |
00000130 63 6f 6e 74 61 69 6e 3a 20 54 65 73 74 3a 3a 41 |contain: Test::A|
00000140 38 4e 0a c2 a0 c2 a0 c2 a0 c2 a0 2d 20 76 65 72 |8N.    - ver|
00000150 69 66 79 20 61 75 74 68 6f 72 20 69 73 3a 20 4d |ify author is: M|
00000160 69 63 68 61 65 6c 20 41 2e 20 4e 61 63 68 62 61 |ichael A. Nachba|
00000170 75 72 0a 50 4f 53 54 43 4f 4e 44 49 54 49 4f 4e |ur.POSTCONDITION|
00000180 53 3a 0a c2 a0 c2 a0 c2 a0 c2 a0 2d 20 70 61 72 |S:.    - par|
00000190 74 79 3a 0a |ty:.|
00000194
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment