Sha256: b4cf566f5c9292755bc05a66cff18ca9d3197d5eb3f4fa00e25644f46e18d4e5

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __FILE__)

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

14 entries across 14 versions & 1 rubygems

Version Path
telnyx-2.6.0 test/telnyx/telnyx_response_test.rb
telnyx-2.5.0 test/telnyx/telnyx_response_test.rb
telnyx-2.4.0 test/telnyx/telnyx_response_test.rb
telnyx-2.3.0 test/telnyx/telnyx_response_test.rb
telnyx-2.2.0 test/telnyx/telnyx_response_test.rb
telnyx-0.1.0 test/telnyx/telnyx_response_test.rb
telnyx-0.0.8 test/telnyx/telnyx_response_test.rb
telnyx-0.0.7 test/telnyx/telnyx_response_test.rb
telnyx-0.0.6 test/telnyx/telnyx_response_test.rb
telnyx-0.0.5 test/telnyx/telnyx_response_test.rb
telnyx-0.0.4 test/telnyx/telnyx_response_test.rb
telnyx-0.0.3 test/telnyx/telnyx_response_test.rb
telnyx-0.0.2 test/telnyx/telnyx_response_test.rb
telnyx-0.0.1 test/telnyx/telnyx_response_test.rb