Sha256: b27de7a85519814495fa73f3eb491fc05defab87261a8925d562322b96d49b8f

Contents?: true

Size: 1.37 KB

Versions: 25

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

module Stripe
  class StripeResponseTest < Test::Unit::TestCase
    context ".from_faraday_hash" do
      should "converts to StripeResponse" do
        body = '{"foo": "bar"}'
        headers = { "Request-Id" => "request-id" }

        http_resp = {
          body: body,
          headers: headers,
          status: 200,
        }

        resp = StripeResponse.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 StripeResponse" do
        body = '{"foo": "bar"}'
        headers = { "Request-Id" => "request-id" }

        env = Faraday::Env.from(
          :status => 200, :body => body,
          :response_headers => headers)
        http_resp = Faraday::Response.new(env)

        resp = StripeResponse.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

25 entries across 25 versions & 1 rubygems

Version Path
stripe-3.3.2 test/stripe/stripe_response_test.rb
stripe-3.3.1 test/stripe/stripe_response_test.rb
stripe-3.3.0 test/stripe/stripe_response_test.rb
stripe-3.2.0 test/stripe/stripe_response_test.rb
stripe-3.1.0 test/stripe/stripe_response_test.rb
stripe-3.0.3 test/stripe/stripe_response_test.rb
stripe-3.0.1 test/stripe/stripe_response_test.rb
stripe-3.0.0 test/stripe/stripe_response_test.rb
stripe-2.12.0 test/stripe/stripe_response_test.rb
stripe-2.11.0 test/stripe/stripe_response_test.rb
stripe-2.10.0 test/stripe/stripe_response_test.rb
stripe-2.9.0 test/stripe/stripe_response_test.rb
stripe-2.8.0 test/stripe/stripe_response_test.rb
stripe-2.7.0 test/stripe/stripe_response_test.rb
stripe-2.6.0 test/stripe/stripe_response_test.rb
stripe-2.5.0 test/stripe/stripe_response_test.rb
stripe-2.4.0 test/stripe/stripe_response_test.rb
stripe-2.3.0 test/stripe/stripe_response_test.rb
stripe-2.2.1 test/stripe/stripe_response_test.rb
stripe-2.2.0 test/stripe/stripe_response_test.rb