Sha256: c86fbf0d68ad596d88b9d15d6b28103b3b9a7158362640e9613e0e8a7e216eb9

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

describe 'NIB validation' do
  it 'passes for valid NIBs', focus: true do
    nib = '003503730000539151280'

    expect(Citizenship.valid_nib!(nib)).to eq(nib)
    expect(Citizenship.valid_nib?(nib)).to be_truthy
    expect(Citizenship.valid_nib?('0035-03730000539-1512-80')).to be_truthy
    expect(Citizenship.valid_nib?('0035.03730000539.1512.80')).to be_truthy
  end

  it 'fails for invalid NIBs' do
    nib = '003503730000539151200'

    expect{ Citizenship.valid_nib!(nib) }.to raise_error(Citizenship::Error)
    expect{ Citizenship.valid_nib!('000003730000539151252') }.to raise_error(Citizenship::Error) #invalid bank code
    expect(Citizenship.valid_nib?(nib)).to be_falsy
    expect(Citizenship.valid_nib?('')).to be_falsy
  end

  it 'strict validation disallow whitspaces, dashes and dots' do
    expect(Citizenship.valid_nib?('0035-03730000539-1512-80', strict: true)).to be_falsy
    expect(Citizenship.valid_nib?('0035.03730000539.1512.80', strict: true)).to be_falsy
    expect(Citizenship.valid_nib?('0035 03730000539 1512 80', strict: true)).to be_falsy
    expect(Citizenship.valid_nib?('0035 03730000539 1512 80 ', strict: true)).to be_falsy
    expect(Citizenship.valid_nib?('003503730000539151280', strict: true)).to be_truthy
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
citizenship-1.0.0 spec/citizenship/nib_spec.rb