Sha256: 413d89e774f3297a4dd2187f4573470949cb3f14b464b9e5feac2f9b3b7ab5ee

Contents?: true

Size: 1.74 KB

Versions: 24

Compression:

Stored size: 1.74 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
        Stripe::Customer.create_source(
          @customer_id,
          source: "tok_123"
        )
        assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
      end
    end

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

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

    context "#delete_source" do
      should "delete a source" do
        Stripe::Customer.delete_source(
          @customer_id,
          @source_id
        )
        assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
      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

24 entries across 24 versions & 1 rubygems

Version Path
stripe-4.12.0 test/stripe/customer_sources_operations_test.rb
stripe-4.11.0 test/stripe/customer_sources_operations_test.rb
stripe-4.10.0 test/stripe/customer_sources_operations_test.rb
stripe-4.9.1 test/stripe/customer_sources_operations_test.rb
stripe-4.9.0 test/stripe/customer_sources_operations_test.rb
stripe-4.8.1 test/stripe/customer_sources_operations_test.rb
stripe-4.8.0 test/stripe/customer_sources_operations_test.rb
stripe-4.7.1 test/stripe/customer_sources_operations_test.rb
stripe-4.7.0 test/stripe/customer_sources_operations_test.rb
stripe-4.6.0 test/stripe/customer_sources_operations_test.rb
stripe-4.5.0 test/stripe/customer_sources_operations_test.rb
stripe-4.4.1 test/stripe/customer_sources_operations_test.rb
stripe-4.4.0 test/stripe/customer_sources_operations_test.rb
stripe-4.3.0 test/stripe/customer_sources_operations_test.rb
stripe-4.2.0 test/stripe/customer_sources_operations_test.rb
stripe-4.1.0 test/stripe/customer_sources_operations_test.rb
stripe-4.0.3 test/stripe/customer_sources_operations_test.rb
stripe-4.0.2 test/stripe/customer_sources_operations_test.rb
stripe-4.0.1 test/stripe/customer_sources_operations_test.rb
stripe-4.0.0 test/stripe/customer_sources_operations_test.rb