Sha256: ce0de08e1ab1767fa6add4df4653ba3b8245570a89cc439280d50ad2d6b74678

Contents?: true

Size: 1.31 KB

Versions: 19

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

module Stripe
  class StripeErrorTest < Test::Unit::TestCase
    context "StripeError" do
      context "#initialize" do
        should "initialize error if json_body is set" do
          e = StripeError.new("message", json_body: { error: { code: "some_error" } })
          assert_not_nil e.error
          assert_equal "some_error", e.error.code
          assert_nil e.error.charge
        end
      end

      context "#to_s" do
        should "convert to string" do
          e = StripeError.new("message")
          assert_equal "message", e.to_s

          e = StripeError.new("message", http_status: 200)
          assert_equal "(Status 200) message", e.to_s

          e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { "request-id" => "request-id" })
          assert_equal "(Request request-id) message", e.to_s
        end
      end
    end

    context "OAuth::OAuthError" do
      context "#initialize" do
        should "initialize error if json_body is set" do
          e = OAuth::OAuthError.new("message", "description", json_body: { error: "some_oauth_error" })
          assert_not_nil e.error
          assert_equal "some_oauth_error", e.error.error
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
stripe-5.16.0 test/stripe/errors_test.rb
stripe-5.15.0 test/stripe/errors_test.rb
stripe-5.14.0 test/stripe/errors_test.rb
stripe-5.13.0 test/stripe/errors_test.rb
stripe-5.12.1 test/stripe/errors_test.rb
stripe-5.12.0 test/stripe/errors_test.rb
stripe-5.11.0 test/stripe/errors_test.rb
stripe-5.10.0 test/stripe/errors_test.rb
stripe-5.9.0 test/stripe/errors_test.rb
stripe-5.8.0 test/stripe/errors_test.rb
stripe-5.7.1 test/stripe/errors_test.rb
stripe-5.7.0 test/stripe/errors_test.rb
stripe-5.6.0 test/stripe/errors_test.rb
stripe-5.5.0 test/stripe/errors_test.rb
stripe-5.4.1 test/stripe/errors_test.rb
stripe-5.4.0 test/stripe/errors_test.rb
stripe-5.3.0 test/stripe/errors_test.rb
stripe-5.2.0 test/stripe/errors_test.rb
stripe-5.1.1 test/stripe/errors_test.rb