httpx/standalone_tests/response_json_multi_json_test.rb
HoneyryderChuck 092e594a4b Request.verb is now an upcased string (ex: "GET")
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.
2023-04-17 16:54:31 +03:00

28 lines
665 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)
end
def response(*args)
Response.new(*args)
end
end