Sha256: 1cdb6ae75403a2144e2a56b71cbb1d1158c99b201c307739689f097019e2791f

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::PayPalAccount do
  describe "self.create" do
    it "raises an exception if attributes contain an invalid key" do
      expect do
        Braintree::PayPalAccount.create(
          :invalid_key => "bad stuff",
          :options => {
            :invalid_option => "bad option",
          },
        )
      end.to raise_error(ArgumentError, "invalid keys: invalid_key, options[invalid_option]")
    end
  end

  describe "self.update" do
    it "raises an exception if attributes contain an invalid key" do
      expect do
        Braintree::PayPalAccount.update("some_token", :invalid_key => "val")
      end.to raise_error(ArgumentError, "invalid keys: invalid_key")
    end
  end

  describe "default?" do
    it "is true if the paypal account is the default payment method for the customer" do
      expect(Braintree::PayPalAccount._new(:gateway, :default => true).default?).to eq(true)
    end

    it "is false if the paypal account is not the default payment methodfor the customer" do
      expect(Braintree::PayPalAccount._new(:gateway, :default => false).default?).to eq(false)
    end
  end

  describe "timestamps" do
    it "exposes created_at and updated_at" do
      now = Time.now
      paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)

      expect(paypal_account.created_at).to eq(now)
      expect(paypal_account.updated_at).to eq(now)
    end
  end

  describe "edit_paypal_vault_id" do
    it "exposes edit_paypal_vault_id" do
      mock_edit_paypal_vault_id = "ENCR-BA-ID1"
      paypal_account = Braintree::PayPalAccount._new(:gateway, :edit_paypal_vault_id => mock_edit_paypal_vault_id)

      expect(paypal_account.edit_paypal_vault_id).to eq(mock_edit_paypal_vault_id)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
braintree-4.23.0 spec/unit/braintree/paypal_account_spec.rb
braintree-4.22.0 spec/unit/braintree/paypal_account_spec.rb