From df5691aa94f209a59945d60d750a5040b24dbc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 11 Apr 2011 17:47:55 +0200 Subject: No need to rescue here. Invoking the wrong method in an object can happen anywhere if you are not careful. In other words, test your shit. --- activemodel/lib/active_model/validations/exclusion.rb | 2 -- activemodel/lib/active_model/validations/format.rb | 2 -- activemodel/lib/active_model/validations/inclusion.rb | 2 -- 3 files changed, 6 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index abc1bfae78..d135d0164a 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -19,8 +19,6 @@ module ActiveModel if exclusions.send(inclusion_method(exclusions), value) record.errors.add(attribute, :exclusion, options.except(:in).merge!(:value => value)) end - rescue NoMethodError - raise ArgumentError, "Exclusion validation for :#{attribute} in #{record.class.name}: #{ERROR_MESSAGE}" end private diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 2ec052c74b..349e110a4b 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -19,8 +19,6 @@ module ActiveModel raise ArgumentError, "A proc or lambda given to :without option must returns a regular expression" end end - rescue TypeError - raise ArgumentError, "A proc or lambda given to :with or :without option must returns a regular expression" end def check_validity! diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index cb46547e92..43b1d87d0b 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -19,8 +19,6 @@ module ActiveModel unless exclusions.send(inclusion_method(exclusions), value) record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value)) end - rescue NoMethodError - raise ArgumentError, "Exclusion validation for :#{attribute} in #{record.class.name}: #{ERROR_MESSAGE}" end private -- cgit v1.2.3