Sha256: 309b65175308cce1e248cdb2f2bd3cf59b5931eee1af534527865d6f62659298
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe BrDocuments::Gtin do describe '#valid?' do context 'when the checksum is valid' do context 'when the GTIN has 8 digits' do subject { described_class.new('12345618') } it { is_expected.to be_valid } end context 'when the GTIN has 12 digits' do subject { described_class.new('114567854874') } it { is_expected.to be_valid } end context 'when the GTIN has 13 digits' do subject { described_class.new('1145678548719') } it { is_expected.to be_valid } end context 'when the GTIN has 14 digits' do subject { described_class.new('1234567891125') } it { is_expected.to be_valid } end context 'when the final digit is zero' do subject { described_class.new('7898417964120') } it { is_expected.to be_valid } end context 'when the number of digits is different of 8, 13 or 14' do subject { described_class.new('12345678901234560') } it { is_expected.not_to be_valid } end end context 'when the checksum is invald' do subject { described_class.new('1145678548712') } it { is_expected.not_to be_valid } end end end
Version data entries
5 entries across 5 versions & 1 rubygems