Sha256: 06160df0d4853ea456b4323b00d8d1f81f3a641f06c22d2587d058ecdde6f7ce
Contents?: true
Size: 843 Bytes
Versions: 9
Compression:
Stored size: 843 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require 'active_model' require 'phonie/railties/validator' class SomeModel < Struct.new(:phone) include ActiveModel::Validations validates :phone, phone: true end class PhoneValidatorTest < Phonie::TestCase def test_blank_phone assert SomeModel.new(nil).valid? assert SomeModel.new('').valid? end def test_valid_model model = SomeModel.new('+1 251 123 4567') assert model.valid? assert model.phone == '+12511234567' end def test_valid_number_with_extension model = SomeModel.new('+1 251 123 4567 ex 1234') assert model.valid? assert model.phone == '+12511234567x1234' end def test_invalid_model model = SomeModel.new('+1 251 123 456') assert model.invalid? assert !model.errors[:phone].empty? end end
Version data entries
9 entries across 9 versions & 1 rubygems