Sha256: d09a278ee7df5cdea2896109eeb5bd6845ba2ec13da52a355f320dee647e4bee

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require "spec_helper"

describe CNPJ do
  it "blacklists common numbers" do
    expect(CNPJ).not_to be_valid("11111111111111")
    expect(CNPJ).not_to be_valid("22222222222222")
    expect(CNPJ).not_to be_valid("33333333333333")
    expect(CNPJ).not_to be_valid("44444444444444")
    expect(CNPJ).not_to be_valid("55555555555555")
    expect(CNPJ).not_to be_valid("66666666666666")
    expect(CNPJ).not_to be_valid("77777777777777")
    expect(CNPJ).not_to be_valid("88888888888888")
    expect(CNPJ).not_to be_valid("99999999999999")
  end

  it "rejects blank strings" do
    expect(CNPJ).not_to be_valid("")
  end

  it "rejects nil values" do
    expect(CNPJ).not_to be_valid(nil)
  end

  it "validates formatted strings" do
    number = "54.550.752/0001-55"
    expect(CNPJ).to be_valid(number)
  end

  it "validates unformatted strings" do
    number = "54550752000155"
    expect(CNPJ).to be_valid(number)
  end

  it "validates messed strings" do
    number = "54550[752#0001..$55"
    expect(CNPJ).to be_valid(number)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cpf_cnpj-0.1.0 spec/cnpj_spec.rb