Sha256: 50a180b953b2254ba18d17404b0c63bf146065d318e380d7a923aeed90fe1ead

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

require 'minitest_helper'

class TestFakeEmailValidator < Minitest::Test

  @@user_class = Class.new do
    include ActiveModel::Validations

    attr_accessor :email

    validates :email, fake_email: true
  end

  def setup
    @user = @@user_class.new
  end

  def test_incorrect_email
    @user.email = 'test@b@d.com'

    assert !@user.valid?
    assert_equal 'has invalid format', @user.errors[:email].first
  end

  def test_fake_email
    @user.email = 'test@mailinator.com'

    assert !@user.valid?
    assert_equal 'has fake domain', @user.errors[:email].first
  end

  def test_fake_email_with_third_sub_domain
    @user.email = 'test@gsrv.co.uk'

    assert !@user.valid?
    assert_equal 'has fake domain', @user.errors[:email].first
  end

  def test_fake_email_with_fake_sub_domain
    @user.email = 'test@a.10mail.org'

    assert !@user.valid?
    assert_equal 'has fake domain', @user.errors[:email].first
  end

  def test_real_email
    @user.email = 'test@gmail.com'

    assert @user.valid?
  end

  def test_real_email_with_third_sub_domain
    @user.email = 'test@mail.co.uk'

    assert @user.valid?
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fake_email_validator-1.0.11 test/test_fake_email_validator.rb
fake_email_validator-1.0.10 test/test_fake_email_validator.rb
fake_email_validator-1.0.9 test/test_fake_email_validator.rb
fake_email_validator-1.0.8 test/test_fake_email_validator.rb
fake_email_validator-1.0.7 test/test_fake_email_validator.rb
fake_email_validator-1.0.6 test/test_fake_email_validator.rb
fake_email_validator-1.0.5 test/test_fake_email_validator.rb
fake_email_validator-1.0.4 test/test_fake_email_validator.rb