Sha256: 80cfb2c463849e556fdcd0cca7e990728d8a20e6788c481d390598c1c0e31202

Contents?: true

Size: 1.43 KB

Versions: 4

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(:source)

    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

4 entries across 4 versions & 1 rubygems

Version Path
stripe-2.0.3 test/stripe/customer_card_test.rb
stripe-2.0.2 test/stripe/customer_card_test.rb
stripe-2.0.1 test/stripe/customer_card_test.rb
stripe-2.0.0 test/stripe/customer_card_test.rb