Sha256: c47ecad88f42eda449dba37eebb97a8b385eb3388a0dc68db8d900c3060cf549

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

require 'spec_helper'

describe TwidValidator do

  describe "#valid?" do
    context "when id not valid" do
      it "returns false if id too short" do
        expect( TwidValidator.valid?("E123") ).to be false
      end

      it "returns false if id too long" do
        expect( TwidValidator.valid?("Y144713411000") ).to be false
      end

      it "returns false if id calculation is wrong" do
        expect( TwidValidator.valid?("Y144713412") ).to be false
      end

      it "returns false if format is wrong" do
        expect( TwidValidator.valid?("YAC4713412") ).to be false
      end
    end

    context "when id is valid" do
      let(:id) { "Y144713411" }

      it "returns true" do
        expect( TwidValidator.valid?(id) ).to be true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
taiwanese_id_validator-0.0.2 spec/taiwanese_id_validator/twid_validator_spec.rb