Sha256: d4eddafdb088d0667bd17584cd54c80e4a89257a99dd6ea44ce4ddb1d6a719d1

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require_relative 'shared_examples_for_to_remove_all_masks'

describe BrDocuments::IE::SP do
  describe '#formatted' do
    context 'when having 12 digits' do
      it 'returns a formatted ie' do
        ie = described_class.new('110042490114')
        expect(ie.formatted).to eq '110.042.490.114'
      end
    end

    context 'when having 13 digits' do
      it 'returns a formatted ie' do
        ie = described_class.new('P011004243002')
        expect(ie.formatted).to eq 'P-01100424.3/002'
      end
    end
  end

  describe '#valid?' do
    it 'is invalid with malformed number' do
      ['36.9107.395114', '527.08212.8110'].each do |number|
        ie = described_class.new(number)
        expect(ie).not_to be_valid
      end
    end

    it 'is invalid with invalid check number' do
      ['110042490113', '110.042.491.114', 'P-01100424.4/002'].each do |number|
        ie = described_class.new(number)
        expect(ie).not_to be_valid
      end
    end

    it 'is valid with valid number' do
      ['110042490114', '110.042.490.114', 'P-01100424.3/002'].each do |number|
        ie = described_class.new(number)
        expect(ie).to be_valid
      end
    end

    include_examples 'for to remove all masks', 'P-01100424.3/002'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
br_documents-0.2.5 spec/br_documents/ie/sp_spec.rb
br_documents-0.2.4 spec/br_documents/ie/sp_spec.rb
br_documents-0.2.3 spec/br_documents/ie/sp_spec.rb
br_documents-0.2.2 spec/br_documents/ie/sp_spec.rb
br_documents-0.2.1 spec/br_documents/ie/sp_spec.rb