Sha256: 373b761895be0a54df8c7e81a11062a0ec0927dd0eec735bad9412af6ce4fa02

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe MrCommon::Registration, type: :model do
  describe "telephone" do
    [
      "754-3010",
      "(541) 754-3010",
      "+1-541-754-3010",
      "1-541-754-3010",
      "001-541-754-3010",
      "191 541 754 3010",
      "(089) / 636-48018",
      "+49-89-636-48018",
      "19-49-89-636-48018"
    ].each do |number|
      it "accepts telephone number like #{number}" do
        registration = build(:registration, telephone: number)
        registration.valid?
        errors = registration.errors[:telephone]
        expect(errors).to be_empty
      end
    end

    it "doesn't accept empty telephone number" do
      registration = build(:registration, telephone: "")
      registration.validate
      errors = registration.errors[:telephone]
      expect(errors).to_not be_empty
    end

    it "doesn't accept invalid telephone number" do
      registration = build(:registration, telephone: "123 123")
      registration.validate
      errors = registration.errors[:telephone]
      expect(errors).to_not be_empty
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mr_common-2.1.0 spec/models/registration_spec.rb
mr_common-2.0.0 spec/models/registration_spec.rb