Sha256: 5b36beea42c0f677221a0b472f20a1a4247e98e9ad744051193c774916963d9e
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
require "validates_phone_format_of" describe ValidatesPhoneFormatOf do before(:each) do @user_class = Class.new do include ActiveModel::Validations attr_reader :phone def initialize(phone) @phone = phone.freeze end def self.model_name ActiveModel::Name.new(self, nil, "user") end validates_phone_format_of :phone end end ['+12223335555', '+33123456789', '+13125551212'].each do |phone| it "#{phone} is valid" do user = @user_class.new(phone) expect(user.valid?).to be_truthy end end ['test', '0000', '(312) 555-1212', '3125551212'].each do |phone| it "#{phone} is not valid" do user = @user_class.new(phone) expect(user.valid?).to_not be_truthy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_phone_format_of-3.0.0 | spec/validates_phone_format_of_spec.rb |