Sha256: cb955d07812ffedb9cd2e0c6e26531c5f181d451a3ce18359c22d0e0351e798f

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

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

module Stripe
  class RecipientCardTest < Test::Unit::TestCase
    FIXTURE = API_FIXTURES.fetch(:source)

    setup do
      @recipient =
        Stripe::Recipient.retrieve(API_FIXTURES.fetch(:transfer_recipient)[:id])
    end

    should "be listable" do
      cards = @recipient.cards.list
      assert cards.data.kind_of?(Array)
      assert cards.data[0].kind_of?(Stripe::Token)
    end

    should "be creatable" do
      card = @recipient.cards.create(
        card: API_FIXTURES.fetch(:token)[:id]
      )
      assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards"
      assert card.kind_of?(Stripe::Token)
    end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stripe-2.0.1 test/stripe/recipient_card_test.rb
stripe-2.0.0 test/stripe/recipient_card_test.rb