Sha256: e8665dd51efd71f30358afc2b0d3f2fd8f9b030528dfea9e0d4c08ee631f3995
Contents?: true
Size: 742 Bytes
Versions: 5
Compression:
Stored size: 742 Bytes
Contents
require "minitest_helper" module Hermod module Validators describe RegularExpression do subject do RegularExpression.new(/\A[A-Z]{2} [0-9]{6} [A-D]\z/x) end it "allows values that match the pattern" do expect(subject.valid?("AB123456C", {})).must_equal true end it "allows blank values" do expect(subject.valid?("", {})).must_equal true expect(subject.valid?(nil, {})).must_equal true end it "raises an error for values that don't match the pattern" do ex = expect { subject.valid?("fish", {}) }.must_raise InvalidInputError expect(ex.message).must_equal "\"fish\" does not match /\\A[A-Z]{2} [0-9]{6} [A-D]\\z/x" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems