Sha256: b913c32bdea7dc48a337657dd011902c0925eb71cd88dcfcce398bc76c5985fe

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

require 'spec_helper'

describe Egn::Validator do
  describe '#validate' do
    it 'fails for strings with incorrect size' do
      expect(Egn::Validator.validate('123456789')).to be_false
      expect(Egn::Validator.validate('12345678901')).to be_false
    end

    it 'fails for incorrect dates' do
      expect(Egn::Validator.validate('6101347500')).to be_false
    end
    
    it 'fails for dates during gregorian calendar adoption' do
      expect(Egn::Validator.validate('1604010886')).to be_false
    end

    it 'checks 10 000 of the generated numbers' do
      Array.new(10_000) { |_| Egn.generate }.each do |egn|
        result = Egn::Validator.validate(egn)
        expect(result).to be_true, "Failed for #{egn}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
egn-1.3.4 spec/egn/validator_spec.rb