@Test public void testRegexpValidator() { deleteAndPopulateTables("users", "addresses"); User u = new User(); // test good value u.set("email", "*****@*****.**"); u.validate(); a(u.errors().size()).shouldBeEqual(0); // test bad value u.set("email", "this is not email value"); u.validate(); a(u.errors().size()).shouldBeEqual(1); }
@Test public void testUniquenessValidator() { deleteAndPopulateTables("users", "addresses"); // create a new user new User().set("email", "*****@*****.**").saveIt(); // attempt creating another user with the same email User u = new User(); u.set("email", "*****@*****.**").saveIt(); a(u).shouldNotBe("valid"); a(u.errors().get("email")).shouldBeEqual("This email is already taken."); }