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

Version Path
solidus_core-2.3.1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.2.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.1.1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.0.3 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.4.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.3.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.3.0 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.3.0.rc3 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.3.0.rc2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.3.0.rc1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.3.0.beta1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.0.2 spec/lib/spree/core/validators/email_spec.rb
solidus_core-1.4.1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.2.1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.2.0 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.2.0.rc1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.2.0.beta1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.1.0 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.1.0.rc1 spec/lib/spree/core/validators/email_spec.rb
solidus_core-2.0.1 spec/lib/spree/core/validators/email_spec.rb