Sha256: 1fbff6c47f8189255d5d9b2e914a2c5354612a90e06afa2d3ceb6be11661ba67

Contents?: true

Size: 1.43 KB

Versions: 16

Compression:

Stored size: 1.43 KB

Contents

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

module Stripe
  class CustomerCardTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:card)

    setup do
      @customer =
        Stripe::Customer.retrieve(API_FIXTURES.fetch(:customer)[:id])
    end

    should "be listable" do
      sources = @customer.sources.list
      assert sources.data.kind_of?(Array)
      # because of the terrible :wildcard nature of sources, the API stub
      # cannot currently replace this response with anything meaningful so we
      # don't assert on the type of individual items like we do in other tests
    end

    should "be creatable" do
      card = @customer.sources.create(
        source: API_FIXTURES.fetch(:token)[:id]
      )
      assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
      assert card.kind_of?(Stripe::BankAccount)
    end

    should "be deletable" do
      card = Stripe::Card.construct_from(FIXTURE.merge(customer: @customer.id))
      card = card.delete
      assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/#{FIXTURE[:id]}"
      assert card.kind_of?(Stripe::Card)
    end

    should "be saveable" do
      card = Stripe::Card.construct_from(FIXTURE.merge(customer: @customer.id))
      card.metadata['key'] = 'value'
      card.save
      assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/#{FIXTURE[:id]}"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
stripe-3.0.3 test/stripe/customer_card_test.rb
stripe-3.0.1 test/stripe/customer_card_test.rb
stripe-3.0.0 test/stripe/customer_card_test.rb
stripe-2.12.0 test/stripe/customer_card_test.rb
stripe-2.11.0 test/stripe/customer_card_test.rb
stripe-2.10.0 test/stripe/customer_card_test.rb
stripe-2.9.0 test/stripe/customer_card_test.rb
stripe-2.8.0 test/stripe/customer_card_test.rb
stripe-2.7.0 test/stripe/customer_card_test.rb
stripe-2.6.0 test/stripe/customer_card_test.rb
stripe-2.5.0 test/stripe/customer_card_test.rb
stripe-2.4.0 test/stripe/customer_card_test.rb
stripe-2.3.0 test/stripe/customer_card_test.rb
stripe-2.2.1 test/stripe/customer_card_test.rb
stripe-2.2.0 test/stripe/customer_card_test.rb
stripe-2.1.0 test/stripe/customer_card_test.rb