Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

4 minor fixes #11

Merged
merged 4 commits into from

2 participants

@bricas
  1. Warnings were thrown in a test due to a stray comma in the dies_ok calls.
  2. When munging the spec/options, a variable was declared but not used, also the logic was overly complex.
  3. Although you can read a spec from a url, the response was not checked for success.
  4. Minor pod fix.
@franckcuny franckcuny merged commit 69b0ad9 into from
@franckcuny
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 11 deletions.
  1. +7 −8 lib/Net/HTTP/Spore.pm
  2. +3 −3 t/spore/02_enable.t
View
15 lib/Net/HTTP/Spore.pm
@@ -88,13 +88,8 @@ sub _attach_spec_to_class {
};
try {
- my $base_url;
- if ( $spec->{base_url} && !$opts->{base_url} ) {
- $opts->{base_url} = $spec->{base_url};
- }
- elsif ( !$opts->{base_url} ) {
- die "base_url is missing!";
- }
+ $opts->{base_url} ||= $spec->{base_url};
+ die "base_url is missing!" if !$opts->{base_url};
if ( $spec->{formats} ) {
$opts->{formats} = $spec->{formats};
@@ -126,6 +121,10 @@ sub _read_spec {
my $req = HTTP::Request->new( GET => $spec_file );
my $ua = LWP::UserAgent->new();
my $res = $ua->request($req);
+ unless( $res->is_success ) {
+ my $status = $res->status_line;
+ Carp::confess("Unabled to fetch $spec_file ($status)");
+ }
$content = $res->content;
}
else {
@@ -215,7 +214,7 @@ L<Net::HTTP::Spore> provides a way to trace what's going on when doing a request
=head3 Enabling Trace
-You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E-<GT> 1> when calling B<new_from_spec>.
+You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E<gt> 1> when calling B<new_from_spec>.
=head3 Trace Output
View
6 t/spore/02_enable.t
@@ -26,15 +26,15 @@ is scalar @{$client->middlewares}, 0, 'no middleware';
dies_ok {
$client->enable();
-}, 'middleware name is required';
+} 'middleware name is required';
dies_ok {
$client->enable('FOOBARBAZAWESOMEMIDDLEWARE');
-}, 'middleware should be loadable';
+} 'middleware should be loadable';
dies_ok {
$client->enable_if('Format::JSON');
-}, 'enable if require a coderef';
+} 'enable if require a coderef';
$client->enable('Dummy');
is scalar @{$client->middlewares}, 1, 'middleware dummy added';
Something went wrong with that request. Please try again.