mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-11-28 00:02:22 -05:00
Options become a bunch of session and connection level parameters, and requests do not need to maintain a separate Options object when they contain a body anymore, instead, objects is shared with the session, while request-only parameters get passed downwards to the request and its body. This reduces allocations of Options, currently the heaviest object to manage.
28 lines
678 B
Ruby
28 lines
678 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "multi_json"
|
|
require "test_helper"
|
|
|
|
class ResponseYajlTest < Minitest::Test
|
|
include HTTPX
|
|
|
|
def test_response_decoders
|
|
json_response = Response.new(request, 200, "2.0", { "content-type" => "application/json" })
|
|
json_response << %({"a": "b"})
|
|
assert json_response.json == { "a" => "b" }
|
|
assert json_response.json(symbolize_keys: true) == { :a => "b" }
|
|
json_response << "bogus"
|
|
assert_raises(MultiJson::ParseError) { json_response.json }
|
|
end
|
|
|
|
private
|
|
|
|
def request(verb = "GET", uri = "http://google.com")
|
|
Request.new(verb, uri, Options.new)
|
|
end
|
|
|
|
def response(*args)
|
|
Response.new(*args)
|
|
end
|
|
end
|