From d62cbf4592b1771552cbac5e7fd1efc9a22324cb Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Mon, 23 Jun 2008 13:55:28 +0200 Subject: [PATCH] make custom spec macro `it_should_validate_length_of' accepts a message argument --- spec/spec_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dfc0af68..e4b28edd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,14 +18,14 @@ module LuckySneaks it "should not be valid if #{attribute} length is more than #{maximum}" do instance.send "#{attribute}=", 'x'*(maximum+1) instance.errors_on(attribute).should include( - ActiveRecord::Errors.default_error_messages[:too_long] % maximum + options[:message_too_long] || ActiveRecord::Errors.default_error_messages[:too_long] % maximum ) end if maximum it "should not be valid if #{attribute} length is less than #{minimum}" do instance.send "#{attribute}=", 'x'*(minimum-1) instance.errors_on(attribute).should include( - ActiveRecord::Errors.default_error_messages[:too_short] % minimum + options[:message_to_short] || ActiveRecord::Errors.default_error_messages[:too_short] % minimum ) end if minimum end