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.
|
# and instead be made available through the +attributes+ reader.
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
@attributes = Array(options.delete(:attributes))
|
@attributes = Array(options.delete(:attributes))
|
||||||
raise ":attributes cannot be blank" if @attributes.empty?
|
raise ArgumentError, ":attributes cannot be blank" if @attributes.empty?
|
||||||
super
|
super
|
||||||
check_validity!
|
check_validity!
|
||||||
end
|
end
|
||||||
|
@ -151,7 +151,7 @@ def check_validity!
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "each validator expects attributes to be given" do
|
test "each validator expects attributes to be given" do
|
||||||
assert_raise RuntimeError do
|
assert_raise ArgumentError do
|
||||||
Topic.validates_with(ValidatorPerEachAttribute)
|
Topic.validates_with(ValidatorPerEachAttribute)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user