Sha256: d0003c132154e71828e10fff08e0a2ff469bf1d3dccb835c8089059444b2b009
Contents?: true
Size: 1.68 KB
Versions: 11
Compression:
Stored size: 1.68 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe RegistrationValidator do it 'should not be valid if name is missing' do form = RegistrationFormBuilder.new.build() form.update(:address => "123 blah st", :email => "sarah@me.com") RegistrationValidator.new.validate(form) form.is_valid?.should be_false end it 'should not be valid if email is missing' do form = RegistrationFormBuilder.new.build() form.update(:address => "123 blah st", :name => "sarah@me.com") RegistrationValidator.new.validate(form) form.is_valid?.should be_false end it 'should not be valid if the provided phone number is not in the correct format' do form = RegistrationFormBuilder.new.build() form.update(:name => "123 blah st", :email => "sarah@me.com", :phone => "not valid") RegistrationValidator.new.validate(form) form.is_valid?.should be_false end it 'should not be valid if the email is in the incorrect format' do form = RegistrationFormBuilder.new.build() form.update(:name => "123 blah st", :email => "sarah without the at me.com") RegistrationValidator.new.validate(form) form.is_valid?.should be_false form.errors_for(:email).should be_a_kind_of(Enumerable) form.errors_for(:email).size.should eql(1) form.errors_for(:email).first.should be_a_kind_of(IncorrectEmailFormatError) end it 'should be valid if all fields correctly filled in' do form = RegistrationFormBuilder.new.build() form.update(:name => "sarah", :address => "123 blah st", :email => "sarah@me.com") RegistrationValidator.new.validate(form) form.is_valid?.should be_true end end
Version data entries
11 entries across 11 versions & 2 rubygems