Sha256: 96bdfb209c18ddb8630bc1cf59d3c8fd5f94722a3d943ad92d45b3d79fef629a

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 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

16 entries across 16 versions & 1 rubygems

Version Path
solidus_core-1.2.3 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.1.4 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.0.7 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.0.6 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.1.3 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.0.5 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.0 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.0.rc2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.0.4 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.1.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.0.rc1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.2.0.beta1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.0.3 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.1.1 spec/lib/spree/core/validators/email_spec.rb