Sha256: 8b89a5bca793f028aa3eee4c6a66cac947cc40656c454a2e6b2c7cda3d7fb1da

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require_relative 'shared_examples_for_to_remove_all_masks'

RSpec.describe BrDocuments::IE::MT do
  describe '#formatted' do
    it 'returns a formatted ie' do
      ie = described_class.new('12345678901')
      expect(ie.formatted).to eq '1234567890-1'
    end

    it 'returns empty when ie is empty' do
      ie = described_class.new('')
      expect(ie.formatted).to eql ''
    end
  end

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

    context 'when the number is greater than 11' do
      subject { described_class.new('123456789012') }

      it 'is invalid' do
        expect(subject).not_to be_valid
      end
    end

    it 'is invalid with invalid check number' do
      ['00404609123', '83646580222'].each do |number|
        ie = described_class.new(number)
        expect(ie).not_to be_valid
      end
    end

    it 'is valid with valid number' do
      ['0013000001-9', '82060187373', '132631946', '13.263.194-6'].each do |number|
        ie = described_class.new(number)
        expect(ie).to be_valid
      end
    end

    include_examples 'for to remove all masks', '0013000001-9'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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