Sha256: 1625bb5aab711c248135b725240f77cda5eb17a3e044ccc5e782073f990c3cf8
Contents?: true
Size: 1.39 KB
Versions: 8
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true require_relative "../test_helper" module Telnyx class TelnyxResponseTest < Test::Unit::TestCase context ".from_faraday_hash" do should "converts to TelnyxResponse" do body = '{"foo": "bar"}' headers = { "X-Request-Id" => "request-id" } http_resp = { body: body, headers: headers, status: 200, } resp = TelnyxResponse.from_faraday_hash(http_resp) assert_equal JSON.parse(body, symbolize_names: true), resp.data assert_equal body, resp.http_body assert_equal headers, resp.http_headers assert_equal 200, resp.http_status assert_equal "request-id", resp.request_id end end context ".from_faraday_response" do should "converts to TelnyxResponse" do body = '{"foo": "bar"}' headers = { "X-Request-Id" => "request-id" } env = Faraday::Env.from( status: 200, body: body, response_headers: headers ) http_resp = Faraday::Response.new(env) resp = TelnyxResponse.from_faraday_response(http_resp) assert_equal JSON.parse(body, symbolize_names: true), resp.data assert_equal body, resp.http_body assert_equal headers, resp.http_headers assert_equal 200, resp.http_status assert_equal "request-id", resp.request_id end end end end
Version data entries
8 entries across 8 versions & 1 rubygems