diff --git a/lib/docs/core/response.rb b/lib/docs/core/response.rb index aff5308d..9959ded3 100644 --- a/lib/docs/core/response.rb +++ b/lib/docs/core/response.rb @@ -8,8 +8,8 @@ module Docs code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599 end - def empty? - body.empty? + def blank? + body.blank? end def mime_type diff --git a/lib/docs/core/scrapers/url_scraper.rb b/lib/docs/core/scrapers/url_scraper.rb index 1d5c6786..0da11cf1 100644 --- a/lib/docs/core/scrapers/url_scraper.rb +++ b/lib/docs/core/scrapers/url_scraper.rb @@ -35,7 +35,9 @@ module Docs def process_response?(response) if response.error? - raise "Error status code (#{response.code}): #{response.url}" + raise "Error status code (#{response.code}): #{response.return_message}\n#{response.url}" + elsif response.blank? + raise "Empty response body: #{response.url}" end response.success? && response.html? && process_url?(response.effective_url) diff --git a/test/lib/docs/core/response_test.rb b/test/lib/docs/core/response_test.rb index 744020fc..4e13b67a 100644 --- a/test/lib/docs/core/response_test.rb +++ b/test/lib/docs/core/response_test.rb @@ -51,15 +51,15 @@ class DocsResponseTest < MiniTest::Spec end end - describe "#empty?" do - it "returns true when the body is empty" do - options.body = '' - assert response.empty? + describe "#blank?" do + it "returns true when the body is blank" do + options.body = ' ' + assert response.blank? end - it "returns false when the body isn't empty" do + it "returns false when the body isn't blank" do options.body = 'body' - refute response.empty? + refute response.blank? end end