Skip to content
Browse files

Merge branch 'bricas'

* bricas:
  use eq and ne instead of a regex
  pod fix
  confess when we are unable to fetch a spec via LWP
  remove unused var; simplify conditions
  fix warnings in test
  • Loading branch information...
2 parents d41d8b6 + 84acaa5 commit f61a039c9d376baff3c54577d5c65abd6a857e85 @franckcuny committed Jan 2, 2012
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';

0 comments on commit f61a039

Please sign in to comment.
Something went wrong with that request. Please try again.