# 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