From 275f922a23b780600a32f70de5b661371c8ffdf4 Mon Sep 17 00:00:00 2001 From: Obie Fernandez Date: Mon, 20 Sep 2010 21:35:41 -0400 Subject: Better shortcut options for custom validators [#5672 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activemodel/test/cases/validations/validates_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activemodel/test/cases') diff --git a/activemodel/test/cases/validations/validates_test.rb b/activemodel/test/cases/validations/validates_test.rb index db023f6169..666c48c8a0 100644 --- a/activemodel/test/cases/validations/validates_test.rb +++ b/activemodel/test/cases/validations/validates_test.rb @@ -111,4 +111,13 @@ class ValidatesTest < ActiveModel::TestCase person.valid? assert_equal ['Local validator please'], person.errors[:title] end + + def test_validates_with_included_validator_and_wildcard_shortcut + # Shortcut for PersonWithValidator.validates :title, :like => { :with => "Mr." } + PersonWithValidator.validates :title, :like => "Mr." + person = PersonWithValidator.new + person.title = "Ms. Pacman" + person.valid? + assert_equal ['does not appear to be like Mr.'], person.errors[:title] + end end -- cgit v1.2.3