提交 b078f7fd 编写于 作者: J José Valim

Fix typos and add tests to ensure they will be caught the next time.

上级 cccb9988
......@@ -10,8 +10,8 @@ def initialize(options)
end
def check_validity!
keys = CHECKS.keys - [:odd, :event]
options.slice(*keys) do |option, value|
keys = CHECKS.keys - [:odd, :even]
options.slice(*keys).each do |option, value|
next if value.is_a?(Numeric) || value.is_a?(Proc) || value.is_a?(Symbol)
raise ArgumentError, ":#{option} must be a number, a symbol or a proc"
end
......
......@@ -54,7 +54,7 @@ module ClassMethods
# The validators hash can also handle regular expressions, ranges and arrays:
#
# validates :email, :format => /@/
# validates :gender, :inclusion => %w(mail female)
# validates :gender, :inclusion => %w(male female)
# validates :password, :length => 6..20
#
# Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can be given
......
......@@ -154,6 +154,14 @@ def test_validates_numericality_of_for_ruby_class
Person.reset_callbacks(:validate)
end
def test_validates_numericality_with_invalid_args
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than_or_equal_to => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than_or_equal_to => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :equal_to => "foo" }
end
private
def invalid!(values, error = nil)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册