mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-06 00:02:08 -04:00
The reference for a request verb is now the string which is used everywhere else, instead of the symbol corresponding to it. This was an artifact from the import from httprb, and there is no advantage in it, since these strings are frozen in most use cases, and the transformations from symbol to strings being performed everywhere are prooof that keeping the atom isn't really bringing any benefit.
37 lines
938 B
Ruby
37 lines
938 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "test_helper"
|
|
|
|
class ErrorResponseTest < Minitest::Test
|
|
include HTTPX
|
|
|
|
def test_error_response_status
|
|
r1 = ErrorResponse.new(request_mock, RuntimeError.new("wow"), {})
|
|
assert r1.status == "wow"
|
|
end
|
|
|
|
def test_error_response_error
|
|
error = RuntimeError.new("wow")
|
|
r1 = ErrorResponse.new(request_mock, error, {})
|
|
assert r1.error == error
|
|
end
|
|
|
|
def test_error_response_raise_for_status
|
|
some_error = Class.new(RuntimeError)
|
|
r1 = ErrorResponse.new(request_mock, some_error.new("wow"), {})
|
|
assert_raises(some_error) { r1.raise_for_status }
|
|
end
|
|
|
|
def test_error_response_to_s
|
|
r = ErrorResponse.new(request_mock, RuntimeError.new("wow"), {})
|
|
str = r.to_s
|
|
assert str.match(/wow \(.*RuntimeError.*\)/), "expected \"wow (RuntimeError)\" in \"#{str}\""
|
|
end
|
|
|
|
private
|
|
|
|
def request_mock
|
|
Request.new("GET", "http://example.com/")
|
|
end
|
|
end
|