Sha256: 62636b9a54dc3b66df91d7e89236b129a98222c21e34c1b0ea3d4217db67d7e5

Contents?: true

Size: 1.82 KB

Versions: 52

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

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

module Stripe
  class TopupTest < Test::Unit::TestCase
    should "be listable" do
      topups = Stripe::Topup.list
      assert_requested :get, "#{Stripe.api_base}/v1/topups"
      assert topups.data.is_a?(Array)
      assert topups.data[0].is_a?(Stripe::Topup)
    end

    should "be retrievable" do
      topup = Stripe::Topup.retrieve("tu_123")
      assert_requested :get, "#{Stripe.api_base}/v1/topups/tu_123"
      assert topup.is_a?(Stripe::Topup)
    end

    should "be creatable" do
      topup = Stripe::Topup.create(
        amount: 100,
        currency: "USD",
        source: "src_123",
        description: "description",
        statement_descriptor: "statement descriptor"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/topups"
      assert topup.is_a?(Stripe::Topup)
    end

    should "be saveable" do
      topup = Stripe::Topup.retrieve("tu_123")
      topup.metadata["key"] = "value"
      topup.save
      assert_requested :post, "#{Stripe.api_base}/v1/topups/#{topup.id}"
    end

    should "be updateable" do
      topup = Stripe::Topup.update("tu_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/topups/tu_123"
      assert topup.is_a?(Stripe::Topup)
    end

    context "#cancel" do
      should "cancel the topup" do
        topup = Stripe::Topup.retrieve("tu_123")
        topup = topup.cancel
        assert_requested :post, "#{Stripe.api_base}/v1/topups/#{topup.id}/cancel"
        assert topup.is_a?(Stripe::Topup)
      end
    end

    context ".cancel" do
      should "cancel the topup" do
        topup = Stripe::Topup.cancel("tu_123")
        assert_requested :post, "#{Stripe.api_base}/v1/topups/tu_123/cancel"
        assert topup.is_a?(Stripe::Topup)
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
stripe-5.31.0 test/stripe/topup_test.rb
stripe-5.30.0 test/stripe/topup_test.rb
stripe-5.29.1 test/stripe/topup_test.rb
stripe-5.29.0 test/stripe/topup_test.rb
stripe-5.28.0 test/stripe/topup_test.rb
stripe-5.27.0 test/stripe/topup_test.rb
stripe-5.26.0 test/stripe/topup_test.rb
stripe-5.25.0 test/stripe/topup_test.rb
stripe-5.24.0 test/stripe/topup_test.rb
stripe-5.23.1 test/stripe/topup_test.rb
stripe-5.23.0 test/stripe/topup_test.rb
stripe-5.22.0 test/stripe/topup_test.rb
stripe-5.21.0 test/stripe/topup_test.rb
stripe-5.20.0 test/stripe/topup_test.rb
stripe-5.19.0 test/stripe/topup_test.rb
stripe-5.18.0 test/stripe/topup_test.rb
stripe-5.17.0 test/stripe/topup_test.rb
stripe-5.16.0 test/stripe/topup_test.rb
stripe-5.15.0 test/stripe/topup_test.rb
stripe-5.14.0 test/stripe/topup_test.rb