Sha256: b7740a53bd3e44d65c4a30ecf8a9b2f9b75a3d79244a0b6f43c647d73d993300

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8
require_relative '../test_helper'

module PagarMe
  class BankAccountTest < Test::Unit::TestCase
    should 'be able to create a bank_account' do
      bank_account = test_bank_account
      bank_account.create

      assert bank_account.bank_code == '237'
    end

    should 'be able to search by anything' do
      bank_account = test_bank_account()
      bank_account.create

      bank_accounts = PagarMe::BankAccount.find_by({ bank_code: '237' })

      assert bank_accounts.size
      bank_accounts.each do |b|
        assert b.bank_code == '237'
      end
    end

    [
      { bank_code: 'foo' },
      { agencia: 'abcd' },
      { agencia_dv: 'Y'},
      { conta: 'ABCD' },
      { conta_dv: ''},
      { legal_name: '' },
      { document_number: 'foooo'}
    ].each do |attrs|
      attr_key = attrs.keys.first

      should "validate bank_account - #{attr_key.to_s}" do
        exception = assert_raises PagarMeError do
          bank_account = BankAccount.new(attrs)
          bank_account.create
        end

        assert exception.errors.map(&:parameter_name).include?(attr_key.to_s)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pagarme-2.0.2 test/pagarme/bank_account.rb
pagarme-2.0.1 test/pagarme/bank_account.rb
pagarme-2.0.0 test/pagarme/bank_account.rb
pagarme-1.10.0 test/pagarme/bank_account.rb
pagarme-1.9.9 test/pagarme/bank_account.rb
pagarme-1.9.8 test/pagarme/bank_account.rb