Sha256: b9753be08f0b18fdb697314bdb2d72d5ab16bf325440be5535e4710a876e7693

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

require 'rspec'

require File.join(File.dirname(__FILE__), '../../lib/mail_validation')

describe MailValidation::EmailValidator do
  class User
    include ActiveModel::Model
    attr_accessor :email
    validates :email, 'MailValidation::Email' => true
  end

  it 'adds an error if the email is blank' do
    user = User.new
    expect(user).to_not be_valid
  end

  it 'adds an error if the email is localized' do
    user = User.new.tap do |u|
      u.email = 'bademail'
    end

    expect(user).to_not be_valid
  end

  it 'adds an error if the email is invalid' do
    user = User.new.tap do |u|
      u.email = '@.com'
    end

    expect(user).to_not be_valid
  end

  it 'does not add an error for a valid, nonlocal email' do
    user = User.new.tap do |u|
      u.email = 'johnny@example.com'
    end

    expect(user).to be_valid
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mail_validation-0.0.1 spec/mail_validation/email_validator_spec.rb