Unified · Split
| @@ -8,8 +8,8 @@ module Docs · 7 unmodified lines | |||
| 8 | code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599 | 8 | code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599 |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | def empty? | 11 | def blank? |
| 12 | body.empty? | 12 | body.blank? |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | def mime_type | 15 | def mime_type |
| @@ -35,7 +35,9 @@ module Docs · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | def process_response?(response) | 36 | def process_response?(response) |
| 37 | if response.error? | 37 | if response.error? |
| 38 | raise "Error status code (#{response.code}): #{response.url}" | 38 | raise "Error status code (#{response.code}): #{response.return_message}\n#{response.url}" |
| 39 | elsif response.blank? | ||
| 40 | raise "Empty response body: #{response.url}" | ||
| 39 | end | 41 | end |
| 40 | 42 | ||
| 41 | response.success? && response.html? && process_url?(response.effective_url) | 43 | response.success? && response.html? && process_url?(response.effective_url) |
| @@ -51,15 +51,15 @@ class DocsResponseTest < MiniTest::Spec · 50 unmodified lines | |||
| 51 | end | 51 | end |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | describe "#empty?" do | 54 | describe "#blank?" do |
| 55 | it "returns true when the body is empty" do | 55 | it "returns true when the body is blank" do |
| 56 | options.body = '' | 56 | options.body = ' ' |
| 57 | assert response.empty? | 57 | assert response.blank? |
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | it "returns false when the body isn't empty" do | 60 | it "returns false when the body isn't blank" do |
| 61 | options.body = 'body' | 61 | options.body = 'body' |
| 62 | refute response.empty? | 62 | refute response.blank? |
| 63 | end | 63 | end |
| 64 | end | 64 | end |
| 65 | 65 | ||