Sha256: 6ab93ab148ab4c2b7f788c953e25bdb0e54e6949e0b87ce1c4de8e5f1bdf372b

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe BankAccount do
  it { is_expected.to be_kind_of Unico::BankAccount }

  let(:subject) { BankAccount.new }
  let(:agency) { Agency.new }
  let(:bank) { double('bank') }

  it 'return description when converted to string' do
    subject.description = 'Banco do Brasil'
    expect(subject.description).to eq subject.to_s
  end

  it 'should delegate digit to agency' do
    allow(subject).to receive(:agency).and_return(double('Agency', digit: 9))
    expect(subject.agency_digit).to eq 9
  end

  it 'should delegate number to agency' do
    allow(subject).to receive(:agency).and_return(double('Agency', number: 1))
    expect(subject.agency_number).to eq 1
  end

  it { is_expected.to belong_to :agency }
  it { is_expected.to have_one(:bank).through :agency }

  it { is_expected.to validate_presence_of :description }
  it { is_expected.to validate_presence_of :agency }
  it { is_expected.to validate_presence_of :account_number }
  it { is_expected.to validate_presence_of :digit }
  it { is_expected.to validate_presence_of :kind }

  it { is_expected.to allow_value('0077').for(:account_number) }
  it { is_expected.to allow_value('77').for(:account_number) }
  it { is_expected.not_to allow_value('0a077').for(:account_number) }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unico-training-7.8.0 spec/models/bank_account_spec.rb