Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise ArgumentError when no attribute is given to AMo::EachValidator

ArgumentError is better suited than RuntimeError for this.
  • Loading branch information...
commit b1fe78e0cb81d6d291b982927353c4fa39d8e269 1 parent d9f20c5
@carlosantoniodasilva carlosantoniodasilva authored
View
2  activemodel/lib/active_model/validator.rb
@@ -135,7 +135,7 @@ class EachValidator < Validator #:nodoc:
# and instead be made available through the +attributes+ reader.
def initialize(options)
@attributes = Array(options.delete(:attributes))
- raise ":attributes cannot be blank" if @attributes.empty?
+ raise ArgumentError, ":attributes cannot be blank" if @attributes.empty?
super
check_validity!
end
View
2  activemodel/test/cases/validations/with_validation_test.rb
@@ -151,7 +151,7 @@ def check_validity!
end
test "each validator expects attributes to be given" do
- assert_raise RuntimeError do
+ assert_raise ArgumentError do
Topic.validates_with(ValidatorPerEachAttribute)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.