Skip to content

Instantly share code, notes, and snippets.

@Hates
Created May 21, 2009 14:42
Show Gist options
  • Save Hates/115494 to your computer and use it in GitHub Desktop.
Save Hates/115494 to your computer and use it in GitHub Desktop.
describe "validation" do
it 'requires password' do
user = Factory.build(:user, :password => nil)
user.should_not be_valid
user.errors.on(:password).should_not be_nil
end
it 'requires password confirmation' do
user = Factory.build(:user, :password => 'password', :password_confirmation => ' ')
user.should_not be_valid
user.errors.on(:password).should_not be_nil
end
it "requires a password that matches" do
user = Factory.build(:user, :password => "password", :password_confirmation => "password_confirmation")
user.should_not be_valid
user.errors.on(:password).should_not be_nil
end
it "requires firstname" do
user = Factory.build(:user, :firstname => nil)
user.should_not be_valid
user.errors.on(:firstname).should_not be_nil
end
it "requires lastname" do
user = Factory.build(:user, :lastname => nil)
user.should_not be_valid
user.errors.on(:lastname).should_not be_nil
end
it "requires telephone" do
user = Factory.build(:user, :telephone => nil)
user.should_not be_valid
user.errors.on(:telephone).should_not be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment