Sha256: 1636971ae070aa0db0d40ea9bd964f0ac8bae593e18c5133d415b11a41e3481e

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

require "spec_helper"

describe Balanced::Credit, :vcr do
  before do
    api_key = Balanced::ApiKey.new.save
    Balanced.configure api_key.secret
    @marketplace = Balanced::Marketplace.new.save
    card = Balanced::Card.new(
      :card_number      => "5105105105105100",
      :expiration_month => "12",
      :expiration_year  => "2015"
    ).save

    # An initial balance for the marketplace
    @buyer = @marketplace.create_buyer(
        :email_address => 'buyer@example.org',
        :card_uri => card.uri
    )
    @buyer.debit :amount => 10000000
  end

  describe "#create", :vcr do
    before do
      @credit = Balanced::Credit.new(
        :amount => 5000,
        :description => "A sweet ride",
        :bank_account => {
          :account_number => "0987654321",
          :bank_code => "321174851",
          :name => "Timmy T. McTimmerson",
          :type => "savings"
        }
      ).save
    end

    describe 'amount', :vcr do
      subject { @credit.amount }
      it { should == 5000 }
    end

    describe 'account', :vcr do
      subject { @credit.account }
      it { should be_nil }
    end

    describe 'bank_account', :vcr do
      subject { @credit.bank_account }
      its([:account_number]) { should end_with '4321' }
    end
  end

  describe "#reverse", :vcr do
    before do
      @credit = Balanced::Credit.new(
        :amount => 5000,
        :description => "A sweet ride",
        :bank_account => {
          :account_number => "0987654321",
          :bank_code => "321174851",
          :name => "Timmy T. McTimmerson",
          :type => "savings"
        }
      ).save
      @reverse = @credit.reverse

    end

    describe 'amount', :vcr do
      subject { @reverse.amount }
      it { should == 5000 }
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
balanced-0.8.2 spec/balanced/resources/credit_spec.rb
balanced-0.8.1 spec/balanced/resources/credit_spec.rb
balanced-0.7.5 spec/balanced/resources/credit_spec.rb
balanced-0.7.4 spec/balanced/resources/credit_spec.rb