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

ArgumentError is better suited than RuntimeError for this.
This commit is contained in:
Carlos Antonio da Silva 2012-11-04 11:41:05 -02:00
parent d9f20c575a
commit b1fe78e0cb
2 changed files with 2 additions and 2 deletions

@ -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