mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-09-21 00:00:49 -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.
28 lines
665 B
Ruby
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
|