Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Addressed github issue #1. #2

Merged
merged 1 commit into from Sep 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist.ini
Expand Up @@ -3,4 +3,6 @@ author = Zoffix Znet <cpan@zoffix.com>
license = Perl_5
copyright_holder = Zoffix Znet <cpan@zoffix.com>

[@Author::ZOFFIX]
[@Author::ZOFFIX]
[Prereqs / TestRequires]
Test::RequiresInternet = 0
32 changes: 32 additions & 0 deletions t/0-load.t
@@ -0,0 +1,32 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More tests => 6;
use Test::Deep;

BEGIN {
use_ok('WWW::Pastebin::Base::Retrieve');
use_ok('HTML::TokeParser::Simple');
use_ok('HTML::Entities');
use_ok('WWW::Pastebin::PastebinCa::Retrieve');
}

diag( "Testing WWW::Pastebin::PastebinCa::Retrieve $WWW::Pastebin::PastebinCa::Retrieve::VERSION, Perl $], $^X" );

use WWW::Pastebin::PastebinCa::Retrieve;
my $paster = WWW::Pastebin::PastebinCa::Retrieve->new( timeout => 10 );

isa_ok($paster, 'WWW::Pastebin::PastebinCa::Retrieve');
can_ok($paster, qw(
new
retrieve
error
results
id
uri
ua
_parse
_set_error
)
);
97 changes: 0 additions & 97 deletions t/00-load.t

This file was deleted.

39 changes: 39 additions & 0 deletions t/01-unit-test.t
@@ -0,0 +1,39 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use Test::RequiresInternet ('pastebin.ca' => 80);
use Test::Deep;
use WWW::Pastebin::PastebinCa::Retrieve;

my $ID = '931145';
my $PASTE_DUMP = {
"language" => "Perl Source",
"desc" => "perl stuff",
"content" => "{\r\n\ttrue => sub { 1 },\r\n\tfalse => sub { 0 },\r\n\ttime => scalar localtime(),\r\n}",
"post_date" => re('Thursday, March 6th, 2008 at \d{1,2}:\d{2}:\d{2}(pm)? [A-Z]{2,4}'),
"name" => "Zoffix"
};

my $paster = WWW::Pastebin::PastebinCa::Retrieve->new(timeout => 10);

my $ret1 = $paster->retrieve($ID);
my $ret2 = $paster->retrieve("http://pastebin.ca/$ID");
cmp_deeply($ret1, $ret2, 'calls with ID and URI must return the same');

is($paster->content, $ret1->{content}, 'content() method');
is("$paster", $ret1->{content}, 'content() overloads');
cmp_deeply($ret1, $PASTE_DUMP, q|dump from Dumper must match ->retrieve()'s response|);

for (qw(language content post_date name)) {
ok(exists $ret1->{$_}, "$_ key must exist in the return");
}
cmp_deeply($ret1, $paster->results, '->results() must now return whatever ->retrieve() returned');

is($paster->id, $ID, 'paste ID must match the return from ->id()');
isa_ok($paster->uri, 'URI::http', '->uri() method');
is($paster->uri, "http://pastebin.ca/$ID", 'uri() must contain a URI to the paste');
isa_ok($paster->ua, 'LWP::UserAgent', '->ua() method');

done_testing();