Sha256: ef1dbc6b12f89e7277492e24fd6baeb8315e77f20d0ab7508dc84705ddc85b09
Contents?: true
Size: 1.06 KB
Versions: 32
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' describe EmailValidator do class Tester include ActiveModel::Validations attr_accessor :email_address validates :email_address, email: true end let(:valid_emails) { [ 'valid@email.com', 'valid@email.com.uk', 'e@email.com', 'valid+email@email.com', 'valid-email@email.com', 'valid_email@email.com', 'valid.email@email.com' ] } let(:invalid_emails) { [ 'invalid email@email.com', '.invalid.email@email.com', 'invalid.email.@email.com', '@email.com', '.@email.com', 'invalidemailemail.com', '@invalid.email@email.com', 'invalid@email@email.com', 'invalid.email@@email.com' ] } it 'validates valid email addresses' do tester = Tester.new valid_emails.each do |email| tester.email_address = email expect(tester.valid?).to be true end end it 'validates invalid email addresses' do tester = Tester.new invalid_emails.each do |email| tester.email_address = email expect(tester.valid?).to be false end end end
Version data entries
32 entries across 32 versions & 1 rubygems