Raise ArgumentError when no attribute is given to AMo::EachValidator
ArgumentError is better suited than RuntimeError for this.
This commit is contained in:
parent
d9f20c575a
commit
b1fe78e0cb
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user