Sha256: e2547fddef73f9c35abc6bd3c2142a5600903772b89d7d29c619a8f0b1959d6a

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

class FakeBankAccount < BankAccount
  include CatarsePagarme::BankAccountConcern
end

describe FakeBankAccount do
  let(:user) { create(:user) }
  let(:bank) { create(:bank) }

  let(:valid_attr) do
    vb = build(:bank_account, bank: bank, owner_name: 'fo', user: user)
    vb.attributes
  end

  let(:valid_attr_on_pagarme) do
    {
      bank_id: bank.id,
      agency: '1732',
      agency_dv: '8',
      account: '25483',
      account_dv: 'X',
      owner_name: 'Lorem Ipsum',
      owner_document: '111.111.111-11'
    }
  end

  describe "validate :must_be_valid_on_pagarme" do
    context "when bank account has invalid data on pagarme" do
      let(:bank_account_on_pagarme) { FakeBankAccount.new(valid_attr) }
      let(:local_bank_account) { BankAccount.new(valid_attr) }

      it "local_bank_account should be valid" do
        expect(local_bank_account.valid?).to be_truthy
      end

      it "bank_account_on_pagarme should be not valid with these attrs" do
        expect(bank_account_on_pagarme.valid?).to be_falsy
      end

      it "bank_account_on_pagarme should be valid with another attrs" do
        subject { FakeBankAccount.new(valid_attr_on_pagarme).valid? }
        expect(subject).to be_truthy
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
catarse_pagarme-2.10.9 spec/models/catarse_pagarme/bank_account_concern_spec.rb
catarse_pagarme-2.10.8 spec/models/catarse_pagarme/bank_account_concern_spec.rb
catarse_pagarme-2.10.7 spec/models/catarse_pagarme/bank_account_concern_spec.rb
catarse_pagarme-2.10.6 spec/models/catarse_pagarme/bank_account_concern_spec.rb
catarse_pagarme-2.10.5 spec/models/catarse_pagarme/bank_account_concern_spec.rb
catarse_pagarme-2.10.4 spec/models/catarse_pagarme/bank_account_concern_spec.rb