Sha256: 3ea8ae0835879605fef07dec66c233ca54e7e8a7bc2d47761eb2569858aee48b

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

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

module Stripe
  class CustomerSourcesOperationsTest < Test::Unit::TestCase
    setup do
      @customer_id = "cus_123"
      @source_id = "ba_123"
    end

    context "#create_source" do
      should "create a source" do
        source = Stripe::Customer.create_source(
          @customer_id,
          source: "tok_123"
        )
        assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
        assert source.is_a?(Stripe::BankAccount)
      end
    end

    context "#retrieve_source" do
      should "retrieve a source" do
        source = Stripe::Customer.retrieve_source(
          @customer_id,
          @source_id
        )
        assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
        assert source.is_a?(Stripe::BankAccount)
      end
    end

    context "#update_source" do
      should "update a source" do
        source = Stripe::Customer.update_source(
          @customer_id,
          @source_id,
          metadata: { foo: "bar" }
        )
        assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
        assert source.is_a?(Stripe::Card)
      end
    end

    context "#delete_source" do
      should "delete a source" do
        source = Stripe::Customer.delete_source(
          @customer_id,
          @source_id
        )
        assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
        assert source.is_a?(Stripe::BankAccount)
      end
    end

    context "#list_sources" do
      should "list the customer's sources" do
        sources = Stripe::Customer.list_sources(
          @customer_id
        )
        assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
        assert sources.is_a?(Stripe::ListObject)
        assert sources.data.is_a?(Array)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stripe-3.28.0 test/stripe/customer_sources_operations_test.rb
stripe-3.27.0 test/stripe/customer_sources_operations_test.rb
stripe-3.26.1 test/stripe/customer_sources_operations_test.rb
stripe-3.26.0 test/stripe/customer_sources_operations_test.rb
stripe-3.25.0 test/stripe/customer_sources_operations_test.rb
stripe-3.24.0 test/stripe/customer_sources_operations_test.rb