Sha256: 5214d8de074ea55a23486837816ae7982d40266d88f6c53ecf15e754a564fa16

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')

describe "Email Validation" do
  it "accepts valid emails" do
    model = Models::EmailValidatorModel.new
    model.email = 'franck@verrot.fr'
    model.valid?.should be(true)
    model.should have(0).errors
  end

  describe "for invalid emails" do
    let(:model) do
      Models::EmailValidatorModel.new.tap do |m|
        m.email = 'franck.fr'
      end
    end

    it "rejects invalid emails" do
      model.valid?.should be(false)
      model.should have(1).errors
    end

    it "generates an error message of type invalid" do
      model.valid?.should be(false)
      model.errors[:email].should == [model.errors.generate_message(:email, :invalid)]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activevalidators-1.2.0 spec/specs/email_spec.rb
activevalidators-1.1.0 spec/specs/email_spec.rb
activevalidators-1.0.2 spec/specs/email_spec.rb