Sha256: b3224032f4ac2c8031cf169481f382dcc7f9f8116f0febaf373d2e0ba127f50e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe EmailValidator do
  before :each do
    @validator = EmailValidator.new({ attributes: [ :foo, :bar ] })
  end
  
  it "should validate an email address" do
    @validator.valid?(nil, nil, 'foo@bar.com').should be_true
  end
  
  it "should validate a name and email pair" do
    @validator.valid?(nil, nil, 'Foo Bar <foo@bar.com>').should be_true
  end
  
  it "should not validate an improper email address" do
    @validator.valid?(nil, nil, 'foo@bar').should be_false
    @validator.valid?(nil, nil, 'fo oo@bar.com').should be_false
    @validator.valid?(nil, nil, 'foo@bar@bar.com').should be_false
    @validator.valid?(nil, nil, 'foo@.com').should be_false
  end
  
  it "should not validate an improper name and email pair" do
    @validator.valid?(nil, nil, 'Foo Bar <foo@bar>').should be_false
    @validator.valid?(nil, nil, 'Foo Bar <fo oo@bar.com>').should be_false
    @validator.valid?(nil, nil, 'Foo Bar <foo@bar@bar.com>').should be_false
    @validator.valid?(nil, nil, 'Foo Bar <foo@.com>').should be_false
    @validator.valid?(nil, nil, '<foo@bar.com> Foo Bar').should be_false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
email_validation-1.1.1 spec/email_validator_spec.rb
email_validation-1.1.0 spec/email_validator_spec.rb